Ejemplo n.º 1
0
 public void BeingAttacked(CombatAI attacker)
 {
     if (_currentTarget != attacker.Health) {
         Creature.ChangeState (State.Attack);
         GameController.CombatController.AddToCombat (this);
         _currentTarget = attacker.GetComponent<Health>();
         HasTarget = true;
     }
 }
Ejemplo n.º 2
0
    public void AddToCombat(CombatAI combatAI)
    {
        _engagedAI.Add (combatAI);

        if (combatAI.GetComponent<Monster>() != null) {
            GameController.LevelGeneration.RemoveFromGrid(gameObject);
            foreach (Dog dog in GameController.MainCharacter.DogInventory) {
                if (dog.Creature.CurrentState == State.Follow && !dog.CombatAI.HasTarget) {
                    dog.CombatAI.BeingAttacked(combatAI);
                }
            }
        } else if (combatAI.GetComponent<Dog>() != null) {
            foreach (CombatAI ai in EngagedAI) {
                if(ai != null && ai.GetComponent<Monster>() != null)
                    ai.GetNewDogTarget();
            }
        }
    }
Ejemplo n.º 3
0
    public void RemoveFromCombat(CombatAI aiToRemove)
    {
        aiToRemove.HasTarget = false;
        _engagedAI.Remove (aiToRemove);

        int numEngagedMonsters = 0;
        foreach(CombatAI AI in _engagedAI){

            if (AI != null && (AI.CurrentTarget == null || AI.CurrentTarget == aiToRemove.Health)) {
                AI.HasTarget = false;
            }
            if(AI != null && AI.GetComponent<Monster>() != null) {
                AI.GetNewDogTarget();
                numEngagedMonsters++;
            }

        }

        if (numEngagedMonsters == 0)
            CombatOver();
    }