factory pattern for zombie error
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using Darkmatter.Core;
|
||||
using UnityEngine;
|
||||
using VContainer;
|
||||
|
||||
namespace Darkmatter.Presentation
|
||||
{
|
||||
public class EnemiesSpawnner : MonoBehaviour
|
||||
{
|
||||
[Inject] IEnemyFactory _enemyFactory;
|
||||
public int enemiesCount = 2;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
for (int i = 0;i< enemiesCount;i++)
|
||||
{
|
||||
_enemyFactory.GetEnemy(ZombieType.Fat);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a025e89a66ec0f147a00c91dcb63c22f
|
||||
@@ -10,13 +10,11 @@ namespace Darkmatter.Presentation
|
||||
public class EnemyMotor : MonoBehaviour, IEnemyPawn
|
||||
{
|
||||
[SerializeField] private NavMeshAgent enemyAI;
|
||||
[SerializeField] private Transform playerTransform;
|
||||
[SerializeField] private List<Transform> patrolPoints = new List<Transform>();
|
||||
[Inject] private EnemyConfigSO enemyConfig;
|
||||
|
||||
public Transform PlayerTarget => playerTransform;
|
||||
public Transform PlayerTarget { get; private set; }
|
||||
public NavMeshAgent EnemyAI => enemyAI;
|
||||
public List<Transform> PatrolPoints => patrolPoints;
|
||||
public List<Transform> PatrolPoints { get; private set; } = new List<Transform>();
|
||||
|
||||
public float Health { get; set; } = 100;
|
||||
|
||||
@@ -61,5 +59,10 @@ namespace Darkmatter.Presentation
|
||||
Gizmos.DrawWireSphere(transform.position, enemyConfig.attackRange);
|
||||
}
|
||||
|
||||
public void InitializeFromFactory(Transform player, List<Transform> patrolPoints)
|
||||
{
|
||||
this.PlayerTarget = player;
|
||||
this.PatrolPoints = patrolPoints;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user