Ejemplo n.º 1
0
    //The main function! This EXACT coroutine will be executed, even across frames.
    //See GameAction.cs for more information on how this function should work!
    public override IEnumerator TakeAction()
    {
        yield return(GameAction.StateCheck);

        CustomTile tile = Map.current.GetTile(intendedLocation);

        if (tile.BlocksMovement())
        {
            Debug.Log("Console Message: You don't can't do that.");
            yield break;
        }

        caller.connections.OnMove.Invoke();

        if (tile.currentlyStanding != null)
        {
            AttackAction attack = new AttackAction(tile.currentlyStanding);
            attack.Setup(caller);
            while (attack.action.MoveNext())
            {
                yield return(attack.action.Current);
            }
            yield break;
        }

        caller.SetPosition(intendedLocation);

        if (costs)
        {
            caller.energy -= caller.energyPerStep * tile.movementCost;
        }

        caller.UpdateLOS();
    }