Exemplo n.º 1
0
    protected IEnumerator MoveWaiter(IEnumerable <IPathNode <HexNode> > path, IReady controller)
    {
        if (path == null)
        {
            Debug.Log("Can't find path!!");
            yield break;
        }

        IEnumerator <IPathNode <HexNode> > enumerator = path.GetEnumerator();

        enumerator.MoveNext(); // Skips first;
        IPathNode <HexNode> lastNode = enumerator.Current;

        while (enumerator.MoveNext())
        {
            IPathNode <HexNode> node = enumerator.Current;
            float cost = node.GetCost();

            if (cost <= currentActionPoints)
            {
                yield return(Step(node));
            }
            else
            {
                break;
            }

            lastNode = enumerator.Current;
        }

        currentActionPoints -= lastNode.GetCost();

        controller.Ready();
    }