コード例 #1
0
    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>();
    }
コード例 #2
0
ファイル: EnemyLocator.cs プロジェクト: hellblade/LudumDare42
    private void Awake()
    {
        if (Instance != null)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
        Instance = this;
    }
コード例 #3
0
 void Start()
 {
     if (this.transform.parent.name == "RocketTower(Clone)")
     {
         rocketTower = GetComponent <RocketTowerSpin>();
     }
     else
     {
         movement = GetComponent <TurretMovement>();
     }
     locator = GetComponent <EnemyLocator>();
 }
コード例 #4
0
    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);
    }
コード例 #5
0
    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);
    }
コード例 #6
0
ファイル: ServiceLocator.cs プロジェクト: Mojopon/360Shooter
 public ServiceLocator()
 {
     enemyLocator = new EnemyLocator();
 }
コード例 #7
0
ファイル: ServiceLocator.cs プロジェクト: Mojopon/360Shooter
 public ServiceLocator()
 {
     enemyLocator = new EnemyLocator();
 }