Example #1
0
        //test for two player


        private GameMan()
        {
            this.poSpaceInvaders = null;
            this.pIntro          = new IntroState();
            this.pInGame         = new InGameState();
            this.pLVL2           = new InGameStateLV2();
            this.pEnd            = new EndGameState();
        }
Example #2
0
        //Grid Observer only worryies about moving the grid back and forth and down
        public override void Notify()
        {
            float movement;
            //Debug.WriteLine("Grid_Observer: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB);

            AlienGroup pGrid = (AlienGroup)this.pSubject.pObjA;

            WallCategory pWall = (WallCategory)this.pSubject.pObjB;

            if (pWall.GetCategoryType() == WallCategory.Type.Right)
            {
                //BAD HACK FIX LATER
                movement = pGrid.GetDeltaMove() * -1.0f;
                pGrid.SetDeltaMove(movement);
                pGrid.MoveAcross();
                pGrid.MoveDown();
            }

            else if (pWall.GetCategoryType() == WallCategory.Type.Left)
            {
                movement = pGrid.GetDeltaMove() * -1.0f;
                pGrid.SetDeltaMove(movement);
                pGrid.MoveAcross();
                pGrid.MoveDown();
            }

            else
            {
                //Bottom Wall hit, move aliens up and reset Waves before Game Over
                SpaceInvaders pGame  = GameMan.GetGame();
                GameState     pState = pGame.GetCurrentState();

                if (pState.GetStateName() == GameMan.State.InGame)
                {
                    InGameState pLvl1 = (InGameState)pState;
                    pLvl1.SetStateToggle(false);

                    TimerMan.Add(TimeEvent.Name.GameStateChange, new GameStateChange(false), 2.0f);
                }

                else if (pState.GetStateName() == GameMan.State.LVL2)
                {
                    InGameStateLV2 pLvl2 = (InGameStateLV2)pState;
                    pLvl2.SetStateToggle(false);

                    TimerMan.Add(TimeEvent.Name.GameStateChange, new GameStateChange(false), 2.0f);
                }
            }
        }
        public override void Notify()
        {
            // we need to revert lvl1 or lvl2 to original forms
            // because we lost and will need to re-load content

            //ship was hit take a life and subtract from score

            PlayerMan.P1TakeLife();
            PlayerMan.SetP1Score(-250);

            float P1lives = PlayerMan.GetP1Lives();

            SpaceInvaders pGame = GameMan.GetGame();

            //check if they have more lives
            if (P1lives == 0)
            {
                // last life i was stil able to shoot
                Ship pShip = ShipMan.GetShip();

                pShip.SetShootState(ShipMan.ShootState.End);
                pShip.SetMoveState(ShipMan.MoveState.NoMove);

                GameState pState = pGame.GetCurrentState();

                if (pState.GetStateName() == GameMan.State.InGame)
                {
                    InGameState pLvl1 = (InGameState)pState;
                    pLvl1.SetStateToggle(false);

                    TimerMan.Add(TimeEvent.Name.GameStateChange, new GameStateChange(false), 5.0f);
                }

                else if (pState.GetStateName() == GameMan.State.LVL2)
                {
                    InGameStateLV2 pLvl2 = (InGameStateLV2)pState;
                    pLvl2.SetStateToggle(false);

                    TimerMan.Add(TimeEvent.Name.GameStateChange, new GameStateChange(false), 5.0f);
                }
            }

            else
            {
                //do nothing
            }
        }