Beispiel #1
0
    public void ChangeTrueBossBehavior(int pattern)
    {
        ChrController chr = GameManager.Instance._enemies.Find(e => e._name == "Mercurius");

        //Debug.Log(chr);
        if (chr != null)
        {
            chr.ChangeAIPattern(pattern);
        }
    }
Beispiel #2
0
    void PatrolToPoint()
    {
        if (_curUnit._position == _curUnit._patrolPt)
        {
            if (MissionManager.Instance._enemyPatrolDest.Count <= 1)
            {
                _curUnit.ChangeAIPattern(2);
            }
            else
            {
                bool ret = false;
                for (int i = 0; i < MissionManager.Instance._enemyPatrolDest.Count && !ret; i++)
                {
                    if (_curUnit._position != MissionManager.Instance._enemyPatrolDest[i])
                    {
                        _curUnit._patrolPt = MissionManager.Instance._enemyPatrolDest[i];
                        ret = true;
                    }
                }
                if (!ret)
                {
                    _curUnit.ChangeAIPattern(2);
                }
            }
        }
        if (_curUnit._AIPattern != ChrController.AIPatterns.Patrol)
        {
            DecideActionDelay();
            return;
        }
        Vector2 Path = new Vector2();

        if (AStarPathfinding.Instance.GenerateNextStepOnTrueAStarPath(_curUnit._position, _curUnit._patrolPt, 60, out Path))
        {
            AStarPathfinding.Instance.GeneratePath(Path);
        }
        else
        {
            RandomWander();
        }
    }
Beispiel #3
0
 /*
  * Phase
  * 0: PlayerPhase
  * 1: EnemyPhase
  * */
 public void SpawnUnit(int round)
 {
     if (_active && round >= _startRound && _numSpawn < _totalSpawn && _mission == GameManager.Instance._level)
     {
         if (_coolDownCount >= _coolDown)
         {
             Cell curCell = GameManager.Instance.GetCell(_locationX, _locationY);
             if (curCell != null && curCell._cost < 10)
             {
                 GameObject toInstantiate = _spawnList[Random.Range(0, _spawnList.Count)];
                 GameObject instance      = Instantiate(toInstantiate, new Vector3(_locationX, _locationY, 0f), Quaternion.identity) as GameObject;
                 GameManager.Instance.ChangeCellCost(_locationX, _locationY, _playerSide ? 1 : 2, 10);
                 ChrController chr = instance.GetComponent <ChrController>();
                 if (chr != null)
                 {
                     if (_playerSide)
                     {
                         GameManager.Instance._heros.Add(chr);
                         MissionManager.Instance._numHeroes++;
                         GameObject heroHolder = GameObject.Find("Hero");
                         if (heroHolder != null)
                         {
                             instance.transform.SetParent(heroHolder.transform);
                         }
                     }
                     else
                     {
                         //chr._AIPattern = ChrController.AIPatterns.Approach;
                         chr.ChangeAIPattern((int)_SpawnAIPattern);
                         GameManager.Instance._enemies.Add(chr);
                         MissionManager.Instance._numEnemies++;
                         GameObject enemyHolder = GameObject.Find("Enemy");
                         if (enemyHolder != null)
                         {
                             instance.transform.SetParent(enemyHolder.transform);
                         }
                     }
                 }
                 _coolDownCount = 0;
                 _numSpawn++;
                 if (_spawnDialogue)
                 {
                     _spawnDialogue = false;
                     MissionManager.Instance._spawnEvent = _spawnEvent;
                 }
             }
         }
         else
         {
             _coolDownCount++;
         }
     }
 }