Exemplo n.º 1
0
        private void InvokeChildren(StateChildMethods method)
        {
            foreach (var state in Substates)
            {
                IStateBehavior behavior = state.Value;

                switch (method)
                {
                case StateChildMethods.Enter:
                    behavior.OnStateEnter();
                    break;

                case StateChildMethods.Update:
                    behavior.OnStateUpdate();
                    break;

                case StateChildMethods.Render:
                    behavior.OnStateRender();
                    break;

                case StateChildMethods.Exit:
                    behavior.OnStateExit();
                    break;

                default:
                    Debug.WriteLine("Cannot invoke this method as sync.");
                    break;
                }
            }
        }
Exemplo n.º 2
0
        public void PushSubstate(IStateBehavior behavior, int priority)
        {
            Substates.Add(priority, behavior);

            //Sort the dictionary based on the key values.
            Substates = Substates.OrderBy(e => e.Key)
                        .ToDictionary(obj => obj.Key, obj => obj.Value);
        }
Exemplo n.º 3
0
        private async Task InvokeChildrenAsync(StateChildMethods method)
        {
            foreach (var state in Substates)
            {
                IStateBehavior behavior = state.Value;

                switch (method)
                {
                case StateChildMethods.UpdateAsync:
                    await behavior.OnStateUpdateAsync();

                    break;

                case StateChildMethods.RenderAsync:
                    await behavior.OnStateRenderAsync();

                    break;

                default:
                    Debug.WriteLine("Cannot invoke this method as async.");
                    break;
                }
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Mit diesem Konstruktor kann das Standardverhalten im Fehlerfall (= Endzustand)
 /// übersteuert werden.
 /// </summary>
 /// <param name="beahvior"></param>
 public Error(IStateBehavior beahvior, params State[] Next) : base(beahvior, Next)
 {
 }
        //=================================================================================================

        /// <summary>
        /// Adds a new behavior definition to the state machine.
        /// </summary>
        /// <param name="s">The state whose behavior is being described</param>
        /// <param name="behavior">The behavior class used to get the behavior at the given state</param>
        public void AddStateBehavior(State s, IStateBehavior behavior)
        {
            StateBehaviors.Add(s, behavior);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Konstruktor
 /// </summary>
 /// <param name="behavior">Definiert das grundsätzlich Verhalten des Zustandes (Start-, Normal- oder Finaler Zustand)</param>
 /// <param name="Next">Liste der möglichen Folgezustände</param>
 public State(IStateBehavior behavior, params State[] Next)
 {
     InitBehavior(behavior);
     InitNext(Next);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Initialisiert das Verhalten eines Zustandes
 /// </summary>
 /// <param name="behavior"></param>
 protected virtual void InitBehavior(IStateBehavior behavior)
 {
     _IsFinal = behavior.IsFinal;
     _IsStart = behavior.IsStart;
 }
Exemplo n.º 8
0
 public Cancel(IStateBehavior beahvior, params State[] Next) : base(beahvior, Next)
 {
 }