Exemple #1
0
    void Patroling()
    {
        //esta patrulhando e o PLAYER entra no raio de alcance
        if (Eye.playerNear)
        {
            Target = Player;
            if (life.life >= 30)
            {
                navAgent.ResetPath();
                state = new AIDelegate(Chasing);
            }
            else
            {
                navAgent.ResetPath();
                state = new AIDelegate(RunningAway);
            }
        }
        //esta patrulhando e a TORRE entra no raio de alcance
        else if (Eye.towerNear)
        {
            if (life.life <= 30)
            {
                navAgent.ResetPath();
                state = new AIDelegate(RunningAway);
            }
        }
        //esta patrulhando e um MINION entra no raio de alcance
        else if (Eye.minionNear)
        {
            Target = Eye.closestMinion;
            if (life.life >= 10)
            {
                navAgent.ResetPath();
                state = new AIDelegate(Chasing);
            }
            else
            {
                navAgent.ResetPath();
                state = new AIDelegate(RunningAway);
            }
        }

        //patrulhando
        attack.SetActive(false);
        if (navAgent.remainingDistance <= distanceToChangeWaypoint)
        {
            navAgent.Resume();
            if (currentWaypoint < Waypoints.Length - 1)
            {
                navAgent.ResetPath();
                currentWaypoint++;
            }
            else
            {
                navAgent.ResetPath();
                currentWaypoint = 0;
            }
            navAgent.SetDestination(Waypoints[currentWaypoint].position);
        }
    }
Exemple #2
0
    public void ChangeState(STATE newState)
    {
        State = newState;
        switch (State)
        {
        case STATE.FORCEDANIMATION:
            AI = AI_ForcedAnimation;
            break;

        case STATE.IDLE:
            AI = AI_Idle;
            break;

        case STATE.COMBAT:
            AI = AI_Combat;
            if (DynamicWaypoint == null)
            {
                DynamicWaypoint           = new Spatial();
                DynamicWaypoint.Transform = new Transform(DynamicWaypoint.Transform.basis, new Vector3(0, 0, 0));
                GetTree().GetRoot().AddChild(DynamicWaypoint);
            }
            WayPoint = DynamicWaypoint;
            break;

        case STATE.DEATH:
            StateMachine.Travel("Death");
            BodyCollisionShape.SetDisabled(true);
            AI = null;
            break;

        case STATE.PLAYER:
            AI = null;
            break;
        }
    }
Exemple #3
0
 void Start()
 {
     Range    = GetComponentInChildren <Player_Minion_Range>();
     navAgent = GetComponent <NavMeshAgent>();
     state    = new AIDelegate(Progress);
     Attack.SetActive(false);
 }
Exemple #4
0
 void Recovering()
 {
     if (life.life >= 100)
     {
         state = new AIDelegate(Patroling);
     }
 }
Exemple #5
0
 void Start()
 {
     //trocar para nome do player na cena original
     Player   = GameObject.Find("Player");
     Eye      = GetComponentInChildren <Enemy_Hero_01_Eye>();
     navAgent = GetComponent <NavMeshAgent>();
     state    = new AIDelegate(Patroling);
     attack.SetActive(false);
     life = GetComponent <LivingEntity>();
 }
Exemple #6
0
        private void RunAIDelegate(FDCreature creature)
        {
            AIDelegate aiDelegate = null;

            switch (creature.Data.AIType)
            {
            case CreatureData.AITypes.AIType_Aggressive:
                if (creature.Definition.IsMagical())
                {
                    aiDelegate = new AIMagicalAggressiveDelegate(gameAction, creature);
                }
                else
                {
                    aiDelegate = new AIAggressiveDelegate(gameAction, creature);
                }
                break;

            case CreatureData.AITypes.AIType_Defensive:
                if (creature.Definition.IsMagical())
                {
                    aiDelegate = new AIMagicalDefensiveDelegate(gameAction, creature);
                }
                else
                {
                    aiDelegate = new AIDefensiveDelegate(gameAction, creature);
                }
                break;

            case CreatureData.AITypes.AIType_Guard:
                if (creature.Definition.IsMagical())
                {
                    aiDelegate = new AIMagicalGuardDelegate(gameAction, creature);
                }
                else
                {
                    aiDelegate = new AIGuardDelegate(gameAction, creature);
                }
                break;

            case CreatureData.AITypes.AIType_Escape:
                aiDelegate = new AIEscapeDelegate(gameAction, creature);
                break;

            case CreatureData.AITypes.AIType_Treasure:
                aiDelegate = new AITreasureDelegate(gameAction, creature);
                break;
            }

            if (aiDelegate != null)
            {
                lastOperatedCreatureId = creature.CreatureId;
                aiDelegate.TakeAction();
            }
        }
Exemple #7
0
 void Chasing()
 {
     if (navAgent.remainingDistance <= distanceToStartCombat)
     {
         navAgent.ResetPath();
         state = new AIDelegate(Attacking);
     }
     else
     {
         navAgent.SetDestination(Target.transform.position);
     }
 }
Exemple #8
0
 void RunningAway()
 {
     navAgent.ResetPath();
     navAgent.SetDestination(recoveryPoint.position);
     if (navAgent.remainingDistance <= distanceToRecovery)
     {
         state = new AIDelegate(Recovering);
     }
     else if (!Eye.towerNear)
     {
         state = new AIDelegate(Patroling);
     }
 }
Exemple #9
0
 void Chasing()
 {
     //enquanto não entra no alcance, continua tentando chegar perto
     if (navAgent.remainingDistance <= distanceToStartCombat)
     {
         navAgent.ResetPath();
         state = new AIDelegate(Attacking);
     }
     else
     {
         navAgent.SetDestination(Target.transform.position);
     }
 }
Exemple #10
0
 void Attacking()
 {
     navAgent.Stop();
     //se estiver com problemas de colisão lembre de ver a stoppingDistance do navmesh
     if (countToAttack >= attackDelay)
     {
         attack.SetActive(true);
         countToAttack = 0;
         if (Vector3.Distance(transform.position, Target.transform.position) >= distanceToStopCombat || Target == null)
         {
             state = new AIDelegate(Patroling);
         }
     }
     else
     {
         countToAttack += Time.deltaTime;
         attack.SetActive(false);
     }
 }
Exemple #11
0
 void Progress()
 {
     if (Range.enemyNear)
     {
         Target = Range.enemy;
         navAgent.ResetPath();
         state = new AIDelegate(Chasing);
     }
     else if (way == 0)
     {
         Debug.Log(currentWaypoint);
         Attack.SetActive(false);
         if (navAgent.remainingDistance <= distanceToChangeWaypoint)
         {
             if (currentWaypoint < waypointsA.Length - 1)
             {
                 navAgent.ResetPath();
                 currentWaypoint++;
             }
             else
             {
                 navAgent.ResetPath();
                 currentWaypoint = 0;
             }
             navAgent.SetDestination(waypointsA[currentWaypoint].position);
         }
     }
     else if (way == 1)
     {
         Attack.SetActive(false);
         if (navAgent.remainingDistance <= distanceToChangeWaypoint)
         {
             if (currentWaypoint < waypointsB.Length - 1)
             {
                 navAgent.ResetPath();
                 currentWaypoint++;
             }
             else
             {
                 navAgent.ResetPath();
                 currentWaypoint = 0;
             }
             navAgent.SetDestination(waypointsB[currentWaypoint].position);
         }
     }
     else if (way == 2)
     {
         Attack.SetActive(false);
         if (navAgent.remainingDistance <= distanceToChangeWaypoint)
         {
             if (currentWaypoint < waypointsC.Length - 1)
             {
                 navAgent.ResetPath();
                 currentWaypoint++;
             }
             else
             {
                 navAgent.ResetPath();
                 currentWaypoint = 0;
             }
             navAgent.SetDestination(waypointsC[currentWaypoint].position);
         }
     }
 }