//this will be called if a wave is completed for better or worse
        public override void Execute(float deltaTime)
        {
            SpaceInvaders pGame = GameMan.GetGame();

            if (wonOrLost == true)
            {
                pGame.GetCurrentState().Handle();
            }

            else
            {
                pGame.SetGameState(GameMan.State.GameOver);
                pGame.GetCurrentState().Handle();
            }
        }
示例#2
0
        public override void Handle()
        {
            //handle is called before entering gamestate loops
            //fight the wave
            if (bWaveFinished == false)
            {
                Debug.WriteLine("Wave 1");
                Debug.WriteLine("-----------------------------------------------------------------");
                // De-activate sprite batch
                SpriteBatch pIntroScreen = SpriteBatchMan.Find(SpriteBatch.Name.IntroScreen);
                pIntroScreen.bToggle = false;

                this.bWaveFinished = true;
                LoadContent();
                //Update();
            }

            // wave is finished go to the next one
            else
            {
                Debug.WriteLine("Wave 2");
                Debug.WriteLine("-----------------------------------------------------------------");

                this.bWaveFinished = false;

                SpaceInvaders pGame = GameMan.GetGame();

                pGame.SetGameState(GameMan.State.LVL2);
                pGame.GetCurrentState().Handle();
            }
        }
示例#3
0
        public override void Notify()
        {
            //Debug.WriteLine("1 key pressed");
            //this is for the Intro
            //might be a bug here, if people press it again
            SpaceInvaders pGame = GameMan.GetGame();

            pGame.GetCurrentState().Handle();
        }
示例#4
0
        public override void Handle()
        {
            //when the person makes the choice we change states
            // then call the handle()
            SpaceInvaders pGame = GameMan.GetGame();

            pGame.SetGameState(GameMan.State.InGame);
            pGame.GetCurrentState().Handle();
        }
示例#5
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);
                }
            }
        }
示例#6
0
        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
            }
        }
        public override void Handle()
        {
            //handle is called before entering gamestate loops
            //fight the wave
            if (bWaveFinished == false)
            {
                this.bWaveFinished = true;
                LoadContent();
            }

            //wave complete and go to game over screen
            else
            {
                this.bWaveFinished = false;
                SpaceInvaders pGame = GameMan.GetGame();

                pGame.SetGameState(GameMan.State.GameOver);
                pGame.GetCurrentState().Handle();
            }
        }
示例#8
0
        public override void Update()
        {
            //first time through set a time to change states
            if (this.bStateToggle == true)
            {
                //inititally used the game to get time
                //Testing timer man
                //could use Timer Man for current time
                float curTime = TimerMan.GetCurrentTime();
                this.ChangeStateTime = curTime + 10;
                this.bStateToggle    = false;
            }


            else
            {
                SpaceInvaders pGame = GameMan.GetGame();

                //time has elapsed start over
                if (this.ChangeStateTime <= pGame.GetTime())
                {
                    this.bStateToggle = true;

                    SpriteBatch pSB_Intro = SpriteBatchMan.Find(SpriteBatch.Name.IntroScreen);
                    pSB_Intro.bToggle = true;

                    SpriteBatch pGameOverScreen = SpriteBatchMan.Find(SpriteBatch.Name.GameOver);
                    pGameOverScreen.bToggle = false;

                    //SpriteBatch pSB_Splats = SpriteBatchMan.Find(SpriteBatch.Name.Splats);
                    //pSB_Splats.bToggle = false;

                    //----------------------------------------------------------------------------------------------------
                    //Things we need to reset for the Next game?
                    //----------------------------------------------------------------------------------------------------

                    // need to remove ship from its root
                    GameObject pShipRoot = GONodeMan.Find(GameObject.Name.ShipRoot);
                    GameObject pShip     = (GameObject)pShipRoot.GetFirstChild();

                    if (pShip != null)
                    {
                        pShip.Remove();
                    }

                    ShipMan.Destroy();

                    GraveyardMan.KillAll();
                    //GraveyardMan.DumpNodes();
                    GraveyardMan.Destroy();


                    TimerMan.ClearActiveList();
                    TimerMan.DumpTimeEvents();

                    AlienGroup pAlienGroup = (AlienGroup)GONodeMan.Find(GameObject.Name.AlienGrid);
                    pAlienGroup.SetDeltaMove(15.0f);

                    SpriteBatch pSB_Projectiles = SpriteBatchMan.Find(SpriteBatch.Name.Projectiles);
                    pSB_Projectiles.bToggle = false;

                    //----------------------------------------------------------------------------------------------------

                    pGame.SetGameState(GameMan.State.Intro);
                    pGame.GetCurrentState().Update();
                }
            }
        }