Esempio n. 1
0
 public void ResumeFSM(FSMElement element)
 {
     if (this.Root != null)
     {
         this.Root.ResumeFSM(Root.MapElement2Canvas(element));
     }
 }
Esempio n. 2
0
 public void FinishFSM(FSMElement e)
 {
     if (this.Root != null)
     {
         this.Root.FinishFSM(Root.MapElement2Canvas(e));
     }
 }
Esempio n. 3
0
 public void ReStart(FSMElement element)
 {
     if (Root != null)
     {
         this.Root.Restart(Root.MapElement2Canvas(element));
     }
 }
Esempio n. 4
0
        public FSMElement LastFSMElement(FSMElement e)
        {
            if (this.Root == null)
            {
                return(null);
            }

            return(this.Root.LastFSMElement(Root.MapElement2Canvas(e)));
        }
Esempio n. 5
0
 public bool TryGetCanvas(FSMElement e, out NodeCanvas outcanvas)
 {
     if (Root != null)
     {
         outcanvas = Root.MapElement2Canvas(e);
         return(true);
     }
     outcanvas = null;
     return(false);
 }
Esempio n. 6
0
 private static void CallEnter(AbstractParams p)
 {
     if (p.ArgCount > 0)
     {
         FSMElement e = p.ReadObject() as FSMElement;
         if (e != null)
         {
             e.OnEnter();
         }
     }
     else
     {
         LogMgr.LogError("参数异常");
     }
 }
Esempio n. 7
0
            internal NodeCanvas MapElement2Canvas(FSMElement e)
            {
                List <NodeCanvas> values = GetAllFSM();

                for (int i = 0; i < values.Count; ++i)
                {
                    NodeCanvas canvas = values[i];
                    for (int j = 0; j < canvas.nodes.Count; ++j)
                    {
                        Node node = canvas.nodes[j];
                        if (node == e)
                        {
                            ListPool.TryDespawn(values);
                            return(canvas);
                        }
                    }
                }
                ListPool.TryDespawn(values);
                return(null);
            }
Esempio n. 8
0
                internal void Reset(NodeCanvas nodecanvas)
                {
                    this.current   = null;
                    this.laststate = null;
                    this.isRunning = true;

                    if (nodecanvas != null && nodecanvas.nodes.Count > 0)
                    {
                        if (cachecanvas == null || cachecanvas != nodecanvas)
                        {
                            cachecanvas = nodecanvas;
                            for (int i = 0; i < nodecanvas.nodes.Count; ++i)
                            {
                                Node nd = nodecanvas.nodes[i];
                                this.nodequeue.Add(nd);
                            }
                            current = nodequeue[0] as FSMElement;
                        }
                        else
                        {
                            nodecanvas.nodes.Clear();
                            for (int i = 0; i < nodequeue.Count; ++i)
                            {
                                Node nd = nodequeue[i];
                                if (nd is FSMElement)
                                {
                                    ((FSMElement)nd).ResetValues();
                                }
                                nodecanvas.nodes.Add(nd);
                            }

                            current = nodequeue[0] as FSMElement;
                        }
                    }
                    else
                    {
                        LogMgr.LogErrorFormat("结点异常 :{0}", nodecanvas);
                    }
                }
Esempio n. 9
0
            internal void UpdateInFrame(long cnt)
            {
                if (runners.Count == 0)
                {
                    return;
                }

                List <NodeCanvas> values = GetAllFSM();

                for (int i = 0; i < values.Count; ++i)
                {
                    NodeCanvas nodecanvas = values[i];
                    if (nodestates.ContainsKey(nodecanvas))
                    {
                        FSMRunerState runningstate = nodestates[nodecanvas];
                        if (runningstate.isRunning && runningstate.current != null)
                        {
                            FSMElement current   = runningstate.current;
                            FSMElement laststate = runningstate.laststate;

                            if (laststate != null)
                            {
                                if (laststate != current)
                                {
                                    // LogMgr.LogError("this is  " + nodecanvas);
                                    ScriptCommand exitcmd = ScriptCommand.Create((int)FrameWorkCmdDefine.FSMCallExit);
                                    exitcmd.CallParams.WriteObject(laststate);
                                    exitcmd.ExcuteAndRelease();

                                    ScriptCommand entercmd = ScriptCommand.Create((int)FrameWorkCmdDefine.FSMCallEnter);
                                    entercmd.CallParams.WriteObject(current);
                                    entercmd.ExcuteAndRelease();
                                }
                            }
                            else
                            {
                                // LogMgr.LogError("this is  " + nodecanvas);
                                ScriptCommand cmd = ScriptCommand.Create((int)FrameWorkCmdDefine.FSMCallEnter);
                                cmd.CallParams.WriteObject(current);
                                cmd.ExcuteAndRelease();
                            }

                            runningstate.laststate = current;

                            bool ret = current.UpdateFrameInFSM(cnt);
                            if (!ret && runningstate.isRunning)
                            {
                                FSMElement next = current.SelectForNext();
                                if (next != null)
                                {
                                    runningstate.current = next;
                                }
                                else
                                {
                                    ScriptCommand exitcmd = ScriptCommand.Create((int)FrameWorkCmdDefine.FSMCallExit);
                                    exitcmd.CallParams.WriteObject(current);
                                    exitcmd.ExcuteAndRelease();

                                    runningstate.isRunning = false;
                                    this.CallFinishCanvas(nodecanvas);
                                }
                            }
                        }
                    }
                }

                ListPool.TryDespawn(values);
            }
Esempio n. 10
0
 protected override bool Select(FSMElement element)
 {
     return(true);
 }
Esempio n. 11
0
 protected override void From(FSMElement element)
 {
 }
Esempio n. 12
0
 protected abstract void From(FSMElement element);
Esempio n. 13
0
 protected abstract bool Select(FSMElement element);