protected object _StopCurrentMode() { // pop the current state from the stack and call it's end() // returns the result from end() // NOTE: nothing is currently done with the return val from end() object retVal = null; IGameMode oldMode = CurrentMode(); if (oldMode != null) { retVal = oldMode.End(); // should still be on the stack (for potential GetCurrentState() during pop) TODO: Is this true? _modeDataStack.Pop(); } return(retVal); }
public void SwitchGameMode(string name) { if (!modes.ContainsKey(name)) { return; } if (currentMode != null) { currentMode.End(); } currentMode = modes[name]; currentMode.Start(); }