private IEnumerator Execute()
    {
        if (!GameManager.interfaceController.gameInterface.activeSelf)
        {
            yield return(new WaitForSeconds(1f));
        }
        TurnManager closestEnemy = FindClosestEnemy();

        if (closestEnemy == null)
        {
            GameManager.active.GameOver();
            yield break;
        }
        pathForEnemy = new NavMeshPath();
        navMeshAgent.CalculatePath(closestEnemy.transform.position, pathForEnemy);

        if (pathForEnemy.corners.Length < 2)
        {
            turnManager.PassAction();
            yield break;
        }

        Vector3 direction = pathForEnemy.corners[0] - pathForEnemy.corners[1];

        yield return(new WaitForSeconds(0.2f));

        SendMessage("Rotate", new float[] { -direction.z, direction.x });
        yield return(new WaitForSeconds(0.2f));

        Vector3 origin      = movementDetector.GetMagicBallOrigin();
        Vector3 destination = movementDetector.GetMagicBallDestination();

        if (CanAttackPlayer(origin, destination))
        {
            SendMessage("Attack");
        }
        else
        {
            SendMessage("Move");
        }
        if (!turnManager.executingAction)
        {
            SendMessage("Attack");
        }
    }
示例#2
0
 public void Attack()
 {
     if (!turnManager.IsTurn() || turnManager.executingAction)
     {
         return;
     }
     SendMessage("OnAttackEvent", SendMessageOptions.DontRequireReceiver);
     SendMessage("StartAction");
     BroadcastMessage("UnhighlightGroundAhead");
     if (ranged)
     {
         StartCoroutine(SpawnShoot(movementDetector.GetMagicBallOrigin(), movementDetector.GetMagicBallDestination(), delay));
     }
     else
     {
         StartCoroutine(HitAhead(movementDetector.GetGroundAhead().attachedCharacter, delay));
     }
 }