Exemplo n.º 1
0
 //---------------------------------------------------------------------
 public string _onEvent(IEbEvent ev)
 {
     if (mMapAction.ContainsKey(ev.name))
     {
         return(mMapAction[ev.name].action(ev));
     }
     else
     {
         return("");
     }
 }
Exemplo n.º 2
0
        //---------------------------------------------------------------------
        void _rattleOn()
        {
            if (mbRattleOn)
            {
                return;
            }
            mbRattleOn = true;

            while (mQueEvent.Count > 0)
            {
                IEbEvent ev = mQueEvent.Dequeue();

                for (int i = mQueCurrentState.Count - 1; i >= 0; i--)
                {
                    var it = mQueCurrentState[i];

                    EbState state = it;

                    if (!state._isBindEvent(ev.name))
                    {
                        continue;
                    }

                    string next_state_name = state._onEvent(ev);

                    EbState next_state = null;
                    if (mMapState.ContainsKey(next_state_name))
                    {
                        next_state = mMapState[next_state_name];
                    }

                    if (null == next_state)
                    {
                        break;
                    }

                    while (mQueCurrentState.Count > 0)
                    {
                        EbState s = mQueCurrentState[mQueCurrentState.Count - 1];

                        if (next_state == s)
                        {
                            break;
                        }
                        else if (_isDirectLine(s, next_state))
                        {
                            mQueTmpState.Clear();

                            EbState p = next_state;
                            do
                            {
                                mQueTmpState.Add(p);
                                p = p._getParentState();
                            } while (p != s);

                            while (mQueTmpState.Count > 0)
                            {
                                EbState q = mQueTmpState[0];
                                q.enter();
                                mQueCurrentState.Add(q);
                                mQueTmpState.RemoveAt(0);
                            }
                        }
                        else
                        {
                            s.exit();
                            mQueCurrentState.RemoveAt(mQueCurrentState.Count - 1);
                        }
                    }

                    break;
                }
            }
            mbRattleOn = false;
        }
Exemplo n.º 3
0
 //---------------------------------------------------------------------
 public string action(IEbEvent ev)
 {
     return(mHandler(ev));
 }