public void Init(Action <Enemy> ondead, float healthModifier, float speedModifier) { mMaxHP = mHP = mBaseHP * healthModifier; OnDead = ondead; mNavMeshAgent.speed = mMoveSpeed * speedModifier; mNavMeshAgent.destination = GameController.Instance.GetPlayerPos(); isInit = true; mLocator = UIManager.Instance.GenerateEnemyLocator().GetComponent <EnemyLocator>(); }
private void Awake() { if (Instance != null) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); Instance = this; }
void Start() { if (this.transform.parent.name == "RocketTower(Clone)") { rocketTower = GetComponent <RocketTowerSpin>(); } else { movement = GetComponent <TurretMovement>(); } locator = GetComponent <EnemyLocator>(); }
public void ShouldReturnNearestEnemy() { var enemyLocator = new EnemyLocator(); var enemyOne = Substitute.For<IEnemy>(); var enemyTwo = Substitute.For<IEnemy>(); var enemyThree = Substitute.For<IEnemy>(); enemyOne.GetPosition().Returns(new Vector3(0, -2)); enemyTwo.GetPosition().Returns(new Vector3(1, 2)); enemyThree.GetPosition().Returns(new Vector3(2, 4)); enemyLocator.AddEnemy(enemyOne); enemyLocator.AddEnemy(enemyTwo); enemyLocator.AddEnemy(enemyThree); var player = Substitute.For<IFieldEntity>(); player.GetPosition().Returns(new Vector3(0, 0)); var nearestEnemy = enemyLocator.GetNearestEnemyFromTheEntity(player); Assert.AreEqual(enemyOne, nearestEnemy); }
public void ShouldReturnNearestEnemy() { var enemyLocator = new EnemyLocator(); var enemyOne = Substitute.For <IEnemy>(); var enemyTwo = Substitute.For <IEnemy>(); var enemyThree = Substitute.For <IEnemy>(); enemyOne.GetPosition().Returns(new Vector3(0, -2)); enemyTwo.GetPosition().Returns(new Vector3(1, 2)); enemyThree.GetPosition().Returns(new Vector3(2, 4)); enemyLocator.AddEnemy(enemyOne); enemyLocator.AddEnemy(enemyTwo); enemyLocator.AddEnemy(enemyThree); var player = Substitute.For <IFieldEntity>(); player.GetPosition().Returns(new Vector3(0, 0)); var nearestEnemy = enemyLocator.GetNearestEnemyFromTheEntity(player); Assert.AreEqual(enemyOne, nearestEnemy); }
public ServiceLocator() { enemyLocator = new EnemyLocator(); }