Esempio n. 1
0
        public static void ChangeSceneInternal(GameObject pGameObject)
        {
            ForwardIterator pFor = new ForwardIterator(pGameObject);

            Component pNode = pFor.First();

            pFor.Next();
            if (pFor.IsDone())
            {
                GameObject pUFORoot = GameObjectMan.Find(GameObject.Name.UFORoot);
                UFO        pUFO     = (UFO)Iterator.GetChild(pUFORoot);
                pUFO.StopSound();

                int mode      = SceneStateGame.GetPlayMode();
                int currLevel = SceneStateGame.GetCurrLevel();

                String pScore1 = Int32.Parse(FontMan.Find(Font.Name.Score1).GetMessage()).ToString().PadLeft(4, '0');
                SceneStateGame.SetScore1(pScore1);

                String pScore2 = Int32.Parse(FontMan.Find(Font.Name.Score2).GetMessage()).ToString().PadLeft(4, '0');
                SceneStateGame.SetScore2(pScore2);

                String pScoreHigh = Int32.Parse(FontMan.Find(Font.Name.ScoreHigh).GetMessage()).ToString().PadLeft(4, '0');
                SceneStateGame.SetScoreHigh(pScoreHigh);

                SceneStateGame.SetStay(true);

                int currPlayer = SceneStateGame.GetCurrPlayer();

                if (currLevel == 1)
                {
                    SceneStateGame.SetPlayerLevel(currPlayer, 2);
                    SceneStateGame.SetBaseY(450.0f);
                    SceneStateGame.SetMoveRate(1.0f);
                }
                else
                {
                    SceneStateGame.SetPlayerLevel(currPlayer, 1);
                    SceneStateGame.SetBaseY(600.0f);
                    SceneStateGame.SetMoveRate(1.5f);
                    //no need to change to the next player, when finish level 2, same player, back to level 1
                    //SceneStateGame.SetCurrPlayer(currPlayer == mode ? 1 : 2);
                }

                //currLevel = SceneStateGame.GetCurrLevel();
                //if (currLevel == 1)
                //{
                //    SceneStateGame.SetBaseY(600.0f);
                //    SceneStateGame.SetMoveRate(1.5f);
                //}
                //else
                //{
                //    SceneStateGame.SetBaseY(450.0f);
                //    SceneStateGame.SetMoveRate(1.0f);
                //}

                Scene pScene = SceneMan.GetScene();
                pScene.Unload();
            }
        }
        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());

            //}
        }
Esempio n. 3
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);
        }
        public override void Notify()
        {
            String pScoreHigh = Int32.Parse(FontMan.Find(Font.Name.ScoreHigh).GetMessage()).ToString();

            SceneStateTract.SetScoreHigh(pScoreHigh);

            Scene pScene = SceneMan.GetScene();

            pScene.Unload();
        }
        public void SetHighhScore(int newHighScore)
        {
            if (newHighScore > highScore)
            {
                highScore = newHighScore;
            }

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

            pFont.UpdateMessage(highScore.ToString("D4"));
        }
        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. 7
0
        public override void Execute()
        {
            GameObject pA = (GameObject)this.pUFO;
            GameObject pB = (GameObject)Iterator.GetParent(pA);

            float x = this.pUFO.x;
            float y = this.pUFO.y;

            pA.Remove();

            // Hacks
            if (this.pGameObj is MissileGroup)
            {
                Missile pMissile = (Missile)Iterator.GetChild(this.pGameObj);

                // bug but don't crash please
                if (pMissile == null)
                {
                    return;
                }

                Player pPlayer = pMissile.pPlayer;
                pPlayer.nPoints += this.pUFO.GetPoints();
                Font.Name pFontName = Font.Name.Uninitialized;
                if (pPlayer.n == 1)
                {
                    pFontName = Font.Name.Score1Value;
                }
                if (pPlayer.n == 2)
                {
                    pFontName = Font.Name.Score2Value;
                }
                Font pScore = FontMan.Find(pFontName);
                pScore.Set(pFontName,
                           pPlayer.nPoints.ToString(),
                           Glyph.Name.Consolas20pt,
                           pScore.pFontSprite.x,
                           pScore.pFontSprite.y);
            }

            SoundMan.PlaySound(Sound.Name.InvaderKilled);

            Explosion   explosion = new Explosion(GameObject.Name.Explosion, GameSprite.Name.Explosion, x, y);
            SpriteBatch pSB_UFOs  = SpriteBatchMan.Find(SpriteBatch.Name.Aliens);

            explosion.ActivateGameSprite(pSB_UFOs);
            GameObjectMan.Attach(explosion);
            TimerMan.Add(TimeEvent.Name.RemoveExplosion, new RemoveExplosionCommand(explosion), 0.25f);
        }
Esempio n. 8
0
        public override void execute()
        {
            //GameObject pA = (GameObject)this.pAlien;

            //GameObject pB = (GameObject)Iterator.GetParent(pA);
            //pA.remove();

            //if (checkParent(pB) == true)
            //{
            //    GameObject pC = (GameObject)Iterator.GetParent(pB);
            //    pB.remove();
            //}

            //pA.getProxySprite().setGameSprite(GameSpriteMan.Find(GameSprite.Name.Alien_Explosion));
            //GameObjectMan.Find(GameObject.Name.ExplosionGroup).add(pA);
            //SpriteBatchMan.Find(SpriteBatch.Name.Explosions).attach(pA.getProxySprite());
            //pA.activateCollisionSprite(SpriteBatchMan.Find(SpriteBatch.Name.Boxes));

            GameSprite pGameSprite = this.pAlien.getProxySprite().getGameSprite();
            Scene      pScene      = SceneMan.GetScene();

            if (pGameSprite.getName() == GameSprite.Name.Squid)
            {
                pScene.addScoreOne(30);
            }
            else if (pGameSprite.getName() == GameSprite.Name.Crab)
            {
                pScene.addScoreOne(20);
            }
            else if (pGameSprite.getName() == GameSprite.Name.Octopus)
            {
                pScene.addScoreOne(10);
            }

            FontMan.Find(Font.Name.ScoreOne).updateMessage(pScene.getScoreOne().ToString("D4"));

            if (pScene.getScoreOne() > pScene.getHighestScore())
            {
                pScene.setHighstScore(pScene.getScoreOne());
                FontMan.Find(Font.Name.HighestScore).updateMessage(pScene.getHighestScore().ToString("D4"));
            }

            this.pAlien.getProxySprite().setGameSprite(GameSpriteMan.Find(GameSprite.Name.Alien_Explosion));
            ExplosionEvent pExplosionEvent = new ExplosionEvent(this.pAlien);

            TimerMan.Add(TimeEvent.Name.ExplosionEvent, pExplosionEvent, 0.1f);
        }
Esempio n. 9
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. 10
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. 11
0
        public override void Execute()
        {
            GameObject pUFORoot = GameObjectMan.Find(GameObject.Name.UFORoot);
            UFO        pUFO     = (UFO)Iterator.GetChild(pUFORoot);

            pUFO.StopSound();

            String pScore1    = Int32.Parse(FontMan.Find(Font.Name.Score1).GetMessage()).ToString().PadLeft(4, '0');
            String pScore2    = Int32.Parse(FontMan.Find(Font.Name.Score2).GetMessage()).ToString().PadLeft(4, '0');
            String pScoreHigh = Int32.Parse(FontMan.Find(Font.Name.ScoreHigh).GetMessage()).ToString().PadLeft(4, '0');

            if (this.state == false)
            {
                SceneStateGameover.SetScore1(pScore1);
                SceneStateGameover.SetScore2(pScore2);
                SceneStateGameover.SetScoreHigh(pScoreHigh);
            }

            SceneStateGame.SetScore1(pScore1);
            SceneStateGame.SetScore2(pScore2);
            SceneStateGame.SetScoreHigh(pScoreHigh);

            GameObjectNode pGhostGameObj = GhostGameObjectMan.Find(GameObject.Name.AlienGroup);

            if (pGhostGameObj != null)
            {
                SceneStateGame.SetLoadGhost(true);
            }

            GameObject pGameObj = GameObjectMan.Find(GameObject.Name.AlienGroup);

            GhostGameObjectMan.Attach(pGameObj);

            SceneStateGame.SetStay(this.state);
            Scene pScene = SceneMan.GetScene();

            pScene.Unload();
        }
        public override void execute()
        {
            Scene pScene = SceneMan.GetScene();

            pScene.addScoreOne(200);

            FontMan.Find(Font.Name.ScoreOne).updateMessage(pScene.getScoreOne().ToString("D4"));

            if (pScene.getScoreOne() > pScene.getHighestScore())
            {
                pScene.setHighstScore(pScene.getScoreOne());
                FontMan.Find(Font.Name.HighestScore).updateMessage(pScene.getHighestScore().ToString("D4"));
            }

            this.pUFO.getProxySprite().setGameSprite(GameSpriteMan.Find(GameSprite.Name.UFO_Explosion));
            ExplosionEvent pExplosionEvent = new ExplosionEvent(this.pUFO);

            TimerMan.Add(TimeEvent.Name.ExplosionEvent, pExplosionEvent, 0.1f);

            UFOEvent pUFOEvent = new UFOEvent();

            TimerMan.Add(TimeEvent.Name.MovementAnimation, pUFOEvent, UFOMan.getDeltaTime());
        }
Esempio n. 13
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);
            }
        }
        public override void Execute()
        {
            GameObject pA = (GameObject)this.pAlien;
            GameObject pB = (GameObject)Iterator.GetParent(pA);

            float x = this.pAlien.x;
            float y = this.pAlien.y;

            AlienGrid pGrid = (AlienGrid)this.pAlien.pParent.pParent;

            pGrid.nNumActive--;

            pA.Remove();

            // TODO: Need a better way...
            if (privCheckParent(pB) == true)
            {
                GameObject pC = (GameObject)Iterator.GetParent(pB);
                pB.Remove();

                if (privCheckParent(pC) == true)
                {
                    pC.Remove();
                }
            }

            Missile pMissile = (Missile)this.pGameObj;
            Player  pPlayer  = pMissile.pPlayer;

            //
            Font.Name pFontName = Font.Name.Uninitialized;
            if (this.pGameObj is MissileCategory)
            {
                pPlayer.nPoints += this.pAlien.GetPoints();
                Font pScore = null;
                if (pPlayer.n == 1)
                {
                    pScore    = FontMan.Find(Font.Name.Score1Value);
                    pFontName = Font.Name.Score1Value;
                }
                if (pPlayer.n == 2)
                {
                    pScore    = FontMan.Find(Font.Name.Score2Value);
                    pFontName = Font.Name.Score2Value;
                }
                pScore.Set(pFontName,
                           pPlayer.nPoints.ToString(),
                           Glyph.Name.Consolas20pt,
                           pScore.pFontSprite.x,
                           pScore.pFontSprite.y);
            }

            //---------------------------------------------------------------------------------------------------------
            // Sound
            //---------------------------------------------------------------------------------------------------------
            SoundMan.PlaySound(Sound.Name.InvaderKilled);
            TimeEvent pTimeEvent = TimerMan.Find(TimeEvent.Name.ScenePlaySound);

            pTimeEvent.deltaTime -= 0.01f;

            //---------------------------------------------------------------------------------------------------------
            // Explosion
            //---------------------------------------------------------------------------------------------------------
            Explosion   explosion  = new Explosion(GameObject.Name.Explosion, GameSprite.Name.Explosion, x, y);
            SpriteBatch pSB_Aliens = SpriteBatchMan.Find(SpriteBatch.Name.Aliens);

            explosion.ActivateGameSprite(pSB_Aliens);
            GameObjectMan.Attach(explosion);
            TimerMan.Add(TimeEvent.Name.RemoveExplosion, new RemoveExplosionCommand(explosion), 0.25f);

            //---------------------------------------------------------------------------------------------------------
            // Scene Transition
            //---------------------------------------------------------------------------------------------------------
            if (pGrid.nNumActive == 0 && pPlayer.nCurrLevel == 1)
            {
                PlayerMan.WriteHighScores();
                pPlayer.nCurrLevel++;
                SceneContext.GetState().Initialize();
                if (SceneContext.bMultiplayer)
                {
                    SceneContext.SetState(SceneContext.Scene.MultiPlay);
                }
                else
                {
                    SceneContext.SetState(SceneContext.Scene.SinglePlay);
                }
            }
            else if (pGrid.nNumActive == 0 && pPlayer.nCurrLevel == 2)
            {
                PlayerMan.WriteHighScores();
                SceneContext.SetState(SceneContext.Scene.Credits);
            }
        }
Esempio n. 15
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();
        }