Beispiel #1
0
        public MenuCube(MenuController app, Cube cube, int seq)
        {
            mApp = app;
            mCube = cube;
            mCube.userData = this;
            mSpriteIndex = 0;
            mRectColor = new Color (36, 182, 255);
            mSelectColor = new Color (255, 0, 0);
            mRotation = 0;
            mCube.TiltEvent += OnTilt;
            mIndex = seq;

            mCube.ButtonEvent += HandleCubeButtonEvent;

            //mCubeStateController
        }
        // 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;
        }