Ejemplo n.º 1
0
 // ### New Cube ###
 // When a new cube connects while the game is running, we need to create a
 // wrapper for it so that it is included in gameplay.
 //
 // If a new cube is added while the game is paused, this event will be
 // handled after the player unpauses, but before the unpause event is
 // handled.
 private void OnNewCube(Cube c)
 {
     Log.Debug ("New Cube {0}", c.UniqueId);
     CubeWrapper wrapper = (CubeWrapper)c.userData;
     if (wrapper == null) {
         wrapper = new CubeWrapper (this, c, lastIndex);
         lastIndex += 1;
         mWrappers.Add (wrapper);
         Log.Debug ("{0}", mWrappers);
     }
     mNeedCheck = true;
 }
Ejemplo n.º 2
0
        // called during intitialization, before the game has started to run
        public override void Setup()
        {
            Log.Debug ("Setup()");
            mNeedCheck = true;

            // Load up the list of images.
            mImageNames = LoadImageIndex ();

            System.Version myVersion = System.Reflection.Assembly.GetExecutingAssembly ().GetName ().Version;
            Log.Debug (myVersion.ToString ());

            //Init the State Machine
            sm = new StateMachine ();

            //Init the Controllers
            titleController = new TitleController ();
            menuController = new MenuController (this, CubeSet);
            gameController = new GameController ();
            gameBeginController = new GameBeginController (this, CubeSet);
            gameShuffleController = new GameShuffleController (this, CubeSet);
            gameEndController = new GameEndController (this, CubeSet);

            sm.State ("Title", titleController);
            sm.State ("Menu", menuController);
            sm.State ("Game", gameController);
            sm.State ("GameBegin", gameBeginController);
            sm.State ("GameShuffle", gameShuffleController);
            sm.State ("GameEnd", gameEndController);

            sm.Transition ("Title", "TitleToMenu", "Menu");
            sm.Transition ("Menu", tMenuToGameBegin, "GameBegin");
            sm.Transition ("GameBegin", tGameBeginToMenu, "Menu");
            sm.Transition ("GameBegin", tGameBeginToGameShuffle, "GameShuffle");
            sm.Transition ("GameShuffle", tGameShuffleToGameEnd, "GameEnd");
            sm.Transition ("GameEnd", tGameEndToMenu, "Menu");

            sm.SetState ("Menu", "MenuToGameBegin");

            // Loop through all the cubes and set them up.
            lastIndex = 1;

            foreach (Cube cube in CubeSet) {

                CubeWrapper wrapper = new CubeWrapper (this, cube, lastIndex);
                lastIndex += 1;
                mWrappers.Add (wrapper);
            }

            this.PauseEvent += OnPause;
            this.UnpauseEvent += OnUnpause;
            CubeSet.NewCubeEvent += OnNewCube;
            CubeSet.LostCubeEvent += OnLostCube;
            CubeSet.NeighborAddEvent += OnNeighborAdd;
            CubeSet.NeighborRemoveEvent += OnNeighborRemove;
        }