示例#1
0
    void CalcCore()
    {
        while (true)
        {
            waitEvent.WaitOne();

            if (quit)
            {
                break;
            }

            lock (pathQueue)
            {
                while (pathQueue.Count != 0)
                {
                    if (quit)
                    {
                        break;
                    }

                    PathPameter pameter = pathQueue[0];
                    pathQueue.RemoveAt(0);
                    PathMng.Ins.FindPath(pameter.context, pameter.startIndex, pameter.endIndex, pameter.ways);
                    pameter.state = 1;
                }
            }
        }

        lock (pathQueue) {
            pathQueue.Clear();
        }

        CalcThread = null;
    }
 static void OnPathCalcFinished(LocalMsg msg)
 {
     if (msg.context is PathPameter)
     {
         PathPameter pameter = msg.context as PathPameter;
         pameter.stateMachine.OnPathCalcFinished(pameter);
     }
 }
示例#3
0
    public void CalcPath(StateMachine machine, Vector3 start, Vector3 end)
    {
        PathPameter pameter = new PathPameter();

        pameter.stateMachine = machine;
        pameter.start        = start;
        pameter.end          = end;
        lock (pathQueue)
        {
            pathQueue.Add(pameter);
            waitEvent.Set();
        }
    }
示例#4
0
 void CalcCore()
 {
     while (true)
     {
         waitEvent.WaitOne();
         lock (pathQueue)
         {
             while (pathQueue.Count != 0)
             {
                 PathPameter pameter = pathQueue[0];
                 pathQueue.RemoveAt(0);
                 PathMng.Ins.FindPath(pameter.context, pameter.start, pameter.end, pameter.ways);
                 LocalMsg msg = new LocalMsg();
                 msg.Message = (int)LocalMsgType.PathCalcFinished;
                 msg.context = pameter;
                 ProtoHandler.PostMessage(msg);
             }
         }
     }
 }
 public void OnPathCalcFinished(PathPameter pameter)
 {
     Path = pameter;
 }