Open ugur-akin opened 3 years ago
Since we'll probably initialize GameManager
without awaiting fetching the level (in the future), I think it's best if we initialize it to a LOADING
state. We can expose a callback in the interface to indicate the UI is ready, and/or initialize with a promise that resolves into the much needed levelInformation
object.
Once the user selects a level and the level is loaded, game manager should start maintaining information about the game's current state. Game manager should also provide an interface to other components to modify game state (i.e.
Command Palette
needs a method to insert/delete commands).Currently, the game can be in
5
states:EDITING
: In this state, the game awaits the user to input a desired sequence(s). The game is idle -- the character isn't in motion, there is no simulation happening and only the sequences are being modified.SIMULATING
: While in this state, the user input sequence is being played out step by step. Each step should be made visible in the UI/Game Screen (i.e. with an appropriate length timeout). Keep in mind there will be animations playing out during the simulation later in the development stage. NOTE: Simulation logic isn't a part of the game manager.SIMULATION_INTERRUPTED
: This state is reached upon a user input to stop/interrupt simulation. This state should be an intermediary state that is maintained while the level is being reset (e.g. level state is reset back to its initial state and an animation plays as a visual representation). Afterwards, the state should be set toEDITING
.SIMULATION_FAILED
: This state is reached upon a failed sequence (i.e. character stepped out of bounds or an infinite loop is detected) and should indicate a transition into aGame Over
screen containingRetry
andBack To Levels
buttons (maybeHint
and/orHelp
as well in the future).SIMULATION_SUCCEEDED
: This state is reached upon simulating a sequence that lights up every tile at the same time. This state should indicate a transition into theGame Over
screen containingNext
,Restart
andBack To Levels
buttons.