Exemple #1
0
        public void ChangeGlobalState(string stateName)
        {
            if (!mStateDictionary.ContainsKey(stateName))
            {
                Console.WriteLine($"ChangeGlobalState({stateName}): state not found.");
                return;
            }
            if (mStateDictionary[stateName] == mCurrentState)
            {
                Console.WriteLine($"ChangeState({stateName}): new state is already the global state.");
                return;
            }
            mGlobalState?.Exit();

            mGlobalState = mStateDictionary[stateName];
            mGlobalState.Enter();
        }