示例#1
0
文件: Unit.cs 项目: v-free/hexMap
    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();
    }
 //Here is the decoupling. Note that any object passed
 //in with type IReady will be accepted in this method
 public void BeginWork(IReady readiness)
 {
     if (readiness.ComputeReadiness())
     {
         Start = true;
         Work();
     }
 }
示例#3
0
 public override void Move(IEnumerable <IPathNode <HexNode> > path, IReady controller)
 {
     StartCoroutine(MoveWaiter(path, controller));
 }
示例#4
0
文件: Unit.cs 项目: v-free/hexMap
 public abstract void Move(IEnumerable <IPathNode <HexNode> > path, IReady controller);