Esempio n. 1
0
        static public void UpdateAllScore()
        {
            ScoreManager pMan = ScoreManager.PrivGetInstance();

            Debug.Assert(pMan != null);

            Font pTestMessage = FontManager.Find(Font.Name.Player1_Score);

            Debug.Assert(pTestMessage != null);
            pTestMessage.UpdateMessage(pMan.Player1_Score);

            pTestMessage = FontManager.Find(Font.Name.Player2_Score);
            Debug.Assert(pTestMessage != null);
            pTestMessage.UpdateMessage(pMan.Player2_Score);

            pTestMessage = FontManager.Find(Font.Name.High_Score);
            Debug.Assert(pTestMessage != null);
            pTestMessage.UpdateMessage(pMan.High_Score);

            pTestMessage = FontManager.Find(Font.Name.Player1_Lives);
            Debug.Assert(pTestMessage != null);
            pTestMessage.UpdateMessage("Lives " + GameScene.Get1PlayerLive());

            pTestMessage = FontManager.Find(Font.Name.Player2_Lives);
            Debug.Assert(pTestMessage != null);
            pTestMessage.UpdateMessage("Lives " + GameScene.Get2PlayerLives());
        }
Esempio n. 2
0
 public static void reduceLife()
 {
     if (isPlayer1Playing)
     {
         P1_Life.UpdateMessage("P1 HP = " + Player1.life.ToString());
     }
     else
     {
         P2_Life.UpdateMessage("P2 HP = " + Player2.life.ToString());
     }
 }
        public override void EndPlayerTurn(GameManager pGameManager)
        {
            //Debug.WriteLine("RESETTING SHIP!");
            ShipManager.ResetShip();

            SoundManager.StopAllSounds();

            Font pScoreHeader1 = FontManager.Find(Font.Name.ScoreHeader1);
            Font pScoreHeader2 = FontManager.Find(Font.Name.ScoreHeader2);

            pGameManager.pActivePlayer.lives--;
            //Debug.WriteLine("Number of lives remaining is {0}", pGameManager.pActivePlayer.lives);

            if (pGameManager.pActivePlayer.name == PlayerArtifact.Name.PlayerOne && pGameManager.poPlayer2.lives > 0)
            {
                pScoreHeader1.UpdateMessage(" SCORE<1> ");
                pScoreHeader2.UpdateMessage("*SCORE<2>*");
                LivesManager.DisplayLives(pGameManager.poPlayer2.lives);

                //Debug.WriteLine("SWAPPING TO PLAYER 2!");

                //Debug.WriteLine("Storing P1 Managers to Manager Mementos");
                pGameManager.poPlayer1.ArchiveManagerStates(pGameManager.pGame.GetTime());

                //Debug.WriteLine("Restoring P2 Managers from Manager Mementos");
                pGameManager.poPlayer2.RestoreManagerStates(pGameManager.pGame.GetTime());

                pGameManager.SetActivePlayer(PlayerArtifact.Name.PlayerTwo);
            }
            else if (pGameManager.pActivePlayer.name == PlayerArtifact.Name.PlayerTwo && pGameManager.poPlayer1.lives > 0)
            {
                pScoreHeader1.UpdateMessage("*SCORE<1>*");
                pScoreHeader2.UpdateMessage(" SCORE<2> ");
                LivesManager.DisplayLives(pGameManager.poPlayer1.lives);

                //Debug.WriteLine("SWAPPING TO PLAYER 1!");

                //Debug.WriteLine("Storing P2 Managers to Manager Mementos");
                pGameManager.poPlayer2.ArchiveManagerStates(pGameManager.pGame.GetTime());

                //Debug.WriteLine("Restoring P1 Managers from Manager Mementos");
                pGameManager.poPlayer1.RestoreManagerStates(pGameManager.pGame.GetTime());

                pGameManager.SetActivePlayer(PlayerArtifact.Name.PlayerOne);
            }
            else
            {
                LivesManager.DisplayLives(pGameManager.poPlayer1.lives);
                Debug.WriteLine("GAME OVER. YOU LOSE!");
                GameManager.CleanUp();
            }
        }
Esempio n. 4
0
        private void CleanPlayerState(Player.Name playerToClean)
        {
            // Clean player
            Player cleanPlayer = new Player(playerToClean);

            GameStateManager.GetGame().SetPlayer(playerToClean, cleanPlayer);

            //Find Player Points Font
            Font.Name pointsFont = Font.Name.Uninitialized;
            Font.Name livesFont  = Font.Name.Uninitialized;
            switch (playerToClean)
            {
            case Player.Name.Player1:
                pointsFont = Font.Name.Player1Score;
                livesFont  = Font.Name.Player1Lives;
                break;

            case Player.Name.Player2:
                pointsFont = Font.Name.Player2Score;
                livesFont  = Font.Name.Player2Lives;
                break;
            }

            // Update Points display
            Font pPlayerScoreFont = FontManager.Find(pointsFont);

            Debug.Assert(pPlayerScoreFont != null);
            pPlayerScoreFont.UpdateMessage(cleanPlayer.GetPoints().ToString("D4"));

            // Update Lives display
            Font pPlayerLivesFont = FontManager.Find(livesFont);

            Debug.Assert(pPlayerLivesFont != null);
            pPlayerLivesFont.UpdateMessage("LIVES " + cleanPlayer.GetNumLives().ToString());
        }
Esempio n. 5
0
        // Should be called at some point after enter a new state
        public override void Initialize(GameManager pGameManager)
        {
            //Debug.WriteLine("Initializing the GamePlay State in {0}", pGameManager.gameMode);

            Font pCredits      = FontManager.Find(Font.Name.Credits);
            Font pScoreHeader1 = FontManager.Find(Font.Name.ScoreHeader1);
            Font pScoreHeader2 = FontManager.Find(Font.Name.ScoreHeader2);

            pScoreHeader1.UpdateMessage("*SCORE<1>*");
            pScoreHeader2.UpdateMessage(" SCORE<2> ");
            LivesManager.DisplayLives(3);

            //---------------------------------------------------------------------------------------------------------
            // Create the player ship and missile
            //---------------------------------------------------------------------------------------------------------
            ShipManager.Create();

            pGameManager.SetActivePlayer(PlayerArtifact.Name.PlayerOne);
            pGameManager.pActiveGameModeStrategy.InitializeLevel(pGameManager);
            pGameManager.poPlayer1.RestoreManagerStates(pGameManager.pGame.GetTime());

            //---------------------------------------------------------------------------------------------------------
            // Add Keyboard Input Observers
            //---------------------------------------------------------------------------------------------------------
            InputSubject pInputSubject = InputManager.GetArrowLeftSubject();

            pInputSubject.Attach(new MoveLeftObserver());

            pInputSubject = InputManager.GetArrowRightSubject();
            pInputSubject.Attach(new MoveRightObserver());

            pInputSubject = InputManager.GetSpaceSubject();
            pInputSubject.Attach(new ShootObserver());
        }
Esempio n. 6
0
        public static void DisplayLives(int numLives)
        {
            ClearLives();

            Debug.Assert(numLives >= 0 && numLives <= 3);
            SpriteBatch pSpriteBatch = SpriteBatchManager.Find(SpriteBatch.Name.Texts);

            Debug.Assert(pSpriteBatch != null);

            LivesManager pMan = PrivGetInstance();

            if (numLives > 0)
            {
                pSpriteBatch.Attach(pMan.pShip1);
            }
            if (numLives > 1)
            {
                pSpriteBatch.Attach(pMan.pShip2);
            }
            if (numLives > 2)
            {
                pSpriteBatch.Attach(pMan.pShip3);
            }

            pMan.numLives = numLives;

            Font pLives = FontManager.Find(Font.Name.Lives);

            pLives.UpdateMessage(numLives.ToString());
        }
        public override void Update(float time)
        {
            InputMan.Update();

            SpaceInvaders pSI       = SpaceInvaders.GetInstance();
            Font          pScoreOne = FontMan.Find(Font.Name.ScoreOne);

            Debug.Assert(pScoreOne != null);
            pScoreOne.UpdateMessage("" + pSI.scoreOne);

            Font pScoreTwo = FontMan.Find(Font.Name.ScoreTwo);

            Debug.Assert(pScoreTwo != null);
            pScoreTwo.UpdateMessage("" + pSI.scoreTwo);


            Font pScoreMax = FontMan.Find(Font.Name.HighestScore);

            Debug.Assert(pScoreMax != null);
            pScoreMax.UpdateMessage("" + pSI.scoreHigh);

            //Simulation.Update(time);
            //if (Simulation.GetTimeStep() > 0.0f)
            //{
            //    // Fire off the timer events
            //    TimerMan.Update(Simulation.GetTotalTime());

            //}
        }
        public override void Notify()
        {
            Debug.WriteLine("PlayerDeathObserver: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB);

            Player pPlayer = GameStateManager.GetGame().GetPlayer(playerName);

            // Decrement life count
            pPlayer.LoseLife();

            // Update Life count display
            Font pPlayerLives = FontManager.Find(livesFont);

            Debug.Assert(pPlayerLives != null);
            pPlayerLives.UpdateMessage("LIVES " + pPlayer.GetNumLives().ToString());

            // Remove CoreCannon
            GameObject pCoreCannon = GameStateManager.GetGame().GetStateGameObjectManager().Find(GameObject.Name.CoreCannon);

            if (!pCoreCannon.IsMarkedForDeath())
            {
                pCoreCannon.MarkForDeath();

                // Delay - remove object later
                PlayerDeathObserver pObserver = new PlayerDeathObserver(this);
                GameStateManager.GetGame().GetStateDelayedObjectManager().Attach(pObserver);
            }

            // Set State Change Flag
            GameStateManager.GetGame().SetStateChangeFlag(true);
        }
Esempio n. 9
0
        public override void InitializeLevel(GameManager pGameManager)
        {
            Font pCredits = FontManager.Find(Font.Name.Credits);

            pCredits.UpdateMessage("CREDITS  01");

            PlayerOneInit(pGameManager);
        }
Esempio n. 10
0
        public override void Execute()
        {
            Font pTestMessage = FontMan.Find(Font.Name.Life);

            Debug.Assert(pTestMessage != null);
            String life = SceneStateGame.GetPlayerLife(SceneStateGame.GetCurrPlayer()).ToString();

            pTestMessage.UpdateMessage(life);
        }
Esempio n. 11
0
        public static void Update(Font.Name name, String pNewMessage)
        {
            Font pFont = FontManager.Find(name);

            Debug.Assert(pFont != null);

            Debug.Assert(pNewMessage != null);
            pFont.UpdateMessage(pNewMessage);
        }
Esempio n. 12
0
        public static void SaveHighScore(Font pHighScore)
        {
            int score = -1;

            if (Score.CurrentPlayer == 1)
            {
                score = Score.Player1Score;
            }
            if (Score.CurrentPlayer == 2)
            {
                score = Score.Player2Score;
            }
            Debug.Assert(score != -1);

            if (score > HighScore)
            {
                HighScore = score;
            }


            if (HighScore == 0)
            {
                pHighScore.UpdateMessage("000" + HighScore.ToString());
            }
            else if (HighScore < 100)
            {
                pHighScore.UpdateMessage("00" + HighScore.ToString());
            }
            else if (HighScore < 1000)
            {
                pHighScore.UpdateMessage("0" + HighScore.ToString());
            }
            else if (HighScore < 10000)
            {
                pHighScore.UpdateMessage("" + HighScore.ToString());
            }
            else
            {
                HighScore = HighScore - 10000;
                // try again
                Score.SaveHighScore(pHighScore);
            }
        }
Esempio n. 13
0
        public static void PushHighScoreToFont()
        {
            Font pHighScore = FontManager.Find(Font.Name.HighScore);

            GameManager pMan = GameManager.PrivInstance();

            Debug.Assert(pMan != null);

            pHighScore.UpdateMessage(pMan.highScore.ToString("D4"));
        }
Esempio n. 14
0
        public void UpdateHiScore(SpaceInvaders pGame, int inScore)
        {
            if (pGame.GetHiScore() < inScore)
            {
                pGame.SetHiScore(inScore);

                Font pHiScoreFont = FontManager.Find(Font.Name.HighScore);
                Debug.Assert(pHiScoreFont != null);
                pHiScoreFont.UpdateMessage(inScore.ToString("D4"));
            }
        }
        public void SetHighhScore(int newHighScore)
        {
            if (newHighScore > highScore)
            {
                highScore = newHighScore;
            }

            Font pFont = FontMan.Find(Font.Name.HighScore);

            pFont.UpdateMessage(highScore.ToString("D4"));
        }
Esempio n. 16
0
 private static void RefreshPlayer2(Font pScore)
 {
     if (Player2Score < 100)
     {
         pScore.UpdateMessage("00" + Player2Score.ToString());
     }
     else if (Player2Score < 1000)
     {
         pScore.UpdateMessage("0" + Player2Score.ToString());
     }
     else if (Player2Score < 10000)
     {
         pScore.UpdateMessage("" + Player2Score.ToString());
     }
     else
     {
         Player2Score = Player2Score - 10000;
         // try again
         Score.RefreshPlayer2(pScore);
     }
 }
Esempio n. 17
0
        public static void PushPlayerScoresToFonts()
        {
            Font pScore1 = FontManager.Find(Font.Name.Score1);
            Font pScore2 = FontManager.Find(Font.Name.Score2);

            GameManager pMan = GameManager.PrivInstance();

            Debug.Assert(pMan != null);

            pScore1.UpdateMessage(pMan.poPlayer1.score.ToString("D4"));
            pScore2.UpdateMessage(pMan.poPlayer2.score.ToString("D4"));
        }
Esempio n. 18
0
        public static void Refresh()
        {
            // For updating the correct number of lives
            Font pLives = FontManager.Find(Font.Name.LifeCount);

            pLives.UpdateMessage(Lives.count.ToString());

            // For a new game
            if (Lives.count == 0 && Lives.credit > 0)
            {
                Lives.count = Lives.newGameLifeCount;
                SubtractCredit();
            }
        }
        public override void Update(float time)
        {
            // Add your update below this line: ----------------------------
            //in order to render the ship on screen
            pShip.Update();

            //Update the player 1 score
            Font pScoreOne = FontMan.Find(Font.Name.ScoreOne);

            Debug.Assert(pScoreOne != null);
            SpaceInvaders pSI = SpaceInvaders.GetInstance();

            pScoreOne.UpdateMessage("" + pSI.scoreOne);

            //update the player lives
            Font pLives = FontMan.Find(Font.Name.PlayerLives);

            Debug.Assert(pLives != null);
            pLives.UpdateMessage("X" + playLives);

            // Snd update - keeps everything moving and updating smoothly
            SpaceInvaders.GetInstance().sndEngine.Update();

            // Single Step, Free running...
            Simulation.Update(time);

            // Input
            InputMan.Update();

            if (Iterator.GetChild(pUFOGroup) != null)
            {
                SpaceInvaders.GetInstance().sndEngine.Play2D("ufo_highpitch.wav");
            }

            // Run based on simulation stepping
            if (Simulation.GetTimeStep() > 0.0f)
            {
                // Fire off the timer events
                TimerMan.Update(Simulation.GetTotalTime());

                // Do the collision checks
                ColPairMan.Process();

                // walk through all objects and push to flyweight
                GameObjectMan.Update();

                // Delete any objects here...
                DelayedObjectMan.Process();
            }
        }
Esempio n. 20
0
        public override void Notify()
        {
            this.pAlien = (Alien)this.pSubject.pObjA;

            Player pPlayer = GameStateManager.GetGame().GetPlayer(playerName);

            // Add points
            pPlayer.AddPoints(pAlien.GetPoints());

            // Update Points display
            Font pPlayer1ScoreFont = FontManager.Find(pointsFont);

            Debug.Assert(pPlayer1ScoreFont != null);
            pPlayer1ScoreFont.UpdateMessage(pPlayer.GetPoints().ToString("D4"));
        }
Esempio n. 21
0
        public static void incrementScore(int s)
        {
            if (isPlayer1Playing)
            {
                Player1.IncrementScore(s);

                P1_Score.UpdateMessage(getFormattedScore(Player1.score));
            }
            else
            {
                Player2.IncrementScore(s);

                P2_Score.UpdateMessage(getFormattedScore(Player2.score));
            }

            if (Player1.score >= Player2.score)
            {
                HighestScore.UpdateMessage(getFormattedScore(Player1.score));
            }
            else
            {
                HighestScore.UpdateMessage(getFormattedScore(Player2.score));
            }
        }
Esempio n. 22
0
        public override void Update()
        {
            SpaceInvaders pGame = GameMan.GetGame();

            pGame.sndEngine.Update();

            InputManager.Update();

            Simulation.Update(pGame.GetTime());

            if (Simulation.GetTimeStep() > 0.0f)
            {
                //start timer
                TimerMan.Update(Simulation.GetTotalTime());

                //Update all the game objects(nodes)
                GONodeMan.Update();

                //check for collisions
                ColPairMan.Process();

                //process observers
                DelayedObjectMan.Process();
            }


            //---------------------------------------------------------------------------------------------------------
            // Font Practice
            //---------------------------------------------------------------------------------------------------------

            Font pScoreMessage = FontMan.Find(Font.Name.P1Points);

            Debug.Assert(pScoreMessage != null);
            pScoreMessage.UpdateMessage("" + (PlayerMan.GetP1Score()));

            Font pHiScore = FontMan.Find(Font.Name.HiPoints);

            Debug.Assert(pHiScore != null);
            pHiScore.UpdateMessage("" + PlayerMan.GetHiScore());

            Font pP1LivesLeft = FontMan.Find(Font.Name.LivesP1);

            Debug.Assert(pP1LivesLeft != null);
            pP1LivesLeft.UpdateMessage("P1 Lives: " + (PlayerMan.GetP1Lives()));
        }
Esempio n. 23
0
        public override void Update(float time)
        {
            InputMan.Update();

            SpaceInvaders pSI       = SpaceInvaders.GetInstance();
            Font          pScoreOne = FontMan.Find(Font.Name.ScoreOne);

            Debug.Assert(pScoreOne != null);
            pScoreOne.UpdateMessage("" + pSI.scoreOne);

            Font pScoreTwo = FontMan.Find(Font.Name.ScoreTwo);

            Debug.Assert(pScoreTwo != null);
            pScoreTwo.UpdateMessage("" + pSI.scoreTwo);

            Font pScoreMax = FontMan.Find(Font.Name.HighestScore);

            Debug.Assert(pScoreMax != null);
            pScoreMax.UpdateMessage("" + pSI.scoreHigh);
        }
Esempio n. 24
0
        // Should be called at some point after enter a new state
        public override void Initialize(GameManager pGameManager)
        {
            FontManager.Add(Font.Name.GameOver, SpriteBatch.Name.Texts, "GAME  OVER", Glyph.Name.Consolas36pt, 350, 800);
            FontManager.Add(Font.Name.PressSpace, SpriteBatch.Name.Texts, "<PRESS SPACE TO CONTINUE>", Glyph.Name.Consolas36pt, 200, 200);

            Font pCredits = FontManager.Find(Font.Name.Credits);

            pCredits.UpdateMessage("CREDITS  00");

            Font pScoreHeader1 = FontManager.Find(Font.Name.ScoreHeader1);
            Font pScoreHeader2 = FontManager.Find(Font.Name.ScoreHeader2);

            pScoreHeader1.UpdateMessage(" SCORE<1> ");
            pScoreHeader2.UpdateMessage(" SCORE<2> ");


            InputSubject pInputSubject = InputManager.GetSpaceSubject();

            pInputSubject.Attach(new AdvanceGameStateObserver());
        }
Esempio n. 25
0
        public static void Update(Font.Name name, int pNewMessage)
        {
            Font pFont = FontManager.Find(name);

            Debug.Assert(pFont != null);


            String temp = pNewMessage.ToString();

            if (pNewMessage < 10)
            {
                temp = "000" + temp;
            }
            else if (pNewMessage < 100)
            {
                temp = "00" + temp;
            }
            else if (pNewMessage < 1000)
            {
                temp = "0" + temp;
            }

            pFont.UpdateMessage(temp);
        }
Esempio n. 26
0
        public override void Notify()
        {
            //Debug.WriteLine(" Snd_Observer: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB);
            GameObject.Name name = this.pSubject.pObjB.GetName();
            switch (name)
            {
            case GameObject.Name.Octopus:
                this.pScore = 10;
                break;

            case GameObject.Name.Crab:
                this.pScore = 20;
                break;

            case GameObject.Name.Squid:
                this.pScore = 30;
                break;

            case GameObject.Name.UFO:
                this.pScore = 200;
                break;

            default:
                Debug.Assert(false);
                break;
            }

            if (SceneStateGame.GetCurrPlayer() == 1)
            {
                Font pTestMessage = FontMan.Find(Font.Name.Score1);
                Debug.Assert(pTestMessage != null);
                int    newScore       = Int32.Parse(pTestMessage.GetMessage()) + this.pScore;
                String newScoreString = newScore.ToString().PadLeft(4, '0');
                pTestMessage.UpdateMessage(newScoreString);

                pTestMessage = FontMan.Find(Font.Name.ScoreHigh);
                Debug.Assert(pTestMessage != null);
                if (newScore > Int32.Parse(pTestMessage.GetMessage()))
                {
                    pTestMessage.UpdateMessage(newScoreString);
                }
            }
            else if (SceneStateGame.GetCurrPlayer() == 2)
            {
                Font pTestMessage = FontMan.Find(Font.Name.Score2);
                Debug.Assert(pTestMessage != null);
                int    newScore       = Int32.Parse(pTestMessage.GetMessage()) + this.pScore;
                String newScoreString = newScore.ToString().PadLeft(4, '0');
                pTestMessage.UpdateMessage(newScoreString);

                pTestMessage = FontMan.Find(Font.Name.ScoreHigh);
                Debug.Assert(pTestMessage != null);
                if (newScore > Int32.Parse(pTestMessage.GetMessage()))
                {
                    pTestMessage.UpdateMessage(newScoreString);
                }
            }
            else
            {
                Debug.Assert(false);
            }
        }
Esempio n. 27
0
        public override void Update()
        {
            // Add your update below this line: ----------------------------

            //-----------------------------------------------------------
            // Sound Update - place here:
            //-----------------------------------------------------------

            //---------------------------------------------------------------------------------------------------------
            // Font Experiment
            //---------------------------------------------------------------------------------------------------------
            Font pTestMessage = FontMan.Find(Font.Name.TestMessage);

            Debug.Assert(pTestMessage != null);
            pTestMessage.UpdateMessage("dog " + count++);

            // walk through all objects and push to proxy
            GameObjectMan.Update();

            // Do the collision checks
            ColPairMan.Process();

            //-----------------------------------------------------------
            // Sound Experiments
            //-----------------------------------------------------------

            // Adjust music theme volume
            Sound tmpSnd = SoundMan.Find(Sound.Name.Snd_Theme);
            float vol    = tmpSnd.GetVolume();

            if (vol > 0.30f)
            {
                vol_delta = -0.002f;
            }
            else if (vol < 0.00f)
            {
                vol_delta = 0.002f;
            }
            tmpSnd.SetVolume(vol + vol_delta);

            InputMan.Update();
            // Load by file
            missileCount++;
            if (missileCount == 200)
            {
                missileCount = 0;
                // play one by file, not by load
                SoundMan.Play(Sound.Name.Snd_Shoot);
            }

            //// Trigger already loaded sounds
            //if (pMissile.y > 500.0f || pMissile.y < 100.0f)
            //{
            //    pMissile.speed *= -1.0f;

            //    switch (count%4)
            //    {
            //        case 0:
            //            SoundMan.Play(Sound.Name.Snd_HitWall);
            //            break;
            //        case 1:
            //            SoundMan.Play(Sound.Name.Snd_Explosion);
            //            break;
            //        case 2:
            //            SoundMan.Play(Sound.Name.Snd_UFO1);
            //            break;
            //        case 3:
            //            SoundMan.Play(Sound.Name.Snd_UFO2);
            //            break;
            //        default:
            //            Debug.Assert(false);
            //            break;
            //    }

            //}
            // Fire off the timer events
            TimerMan.Update(this.GetTime());

            GameObjectMan.Update();

            //Debug.WriteLine("\n------------------------------------");
            ColPairMan.Process();
        }