示例#1
0
        //-----------------------------------------------------------------------------
        // Game::Update()
        //      Called once per frame, update data, tranformations, etc
        //      Use this function to control process order
        //      Input, AI, Physics, Animation, and Graphics
        //-----------------------------------------------------------------------------

        public override void Update()
        {
            SoundManager.Update();
            // Update the scene
            Simulation.Update(this.GetTime());
            pSceneContext.GetState().Update(this.GetTime());
        }
示例#2
0
        public override void Execute()
        {
            // Let the gameObject deal with this...
            //this.pAlien.Remove();

            GameObject pA = (GameObject)this.pUFO;
            GameObject pB = (GameObject)Iterator.GetParent(pA);

            pA.Remove();

            // TODO:  update score - may need a better way (maybe an observer)
            SceneContext sc = SceneContext.GetInstance();

            sc.GetState().UpdateScore(this.pUFO.GetScore());

            // TODO: Splat Alien - needs a better way
            this.pSplat = new Splat(GameObject.Name.Splat, GameSprite.Name.SplatUFO, pUFO.x, pUFO.y);
            pSplat.ActivateCollisionSprite(this.pSB_Boxes);
            pSplat.ActivateGameSprite(this.pSB_Aliens);

            GameObject pSplatbRoot = GameObjectMan.Find(GameObject.Name.SplatRoot);

            Debug.Assert(pSplatbRoot != null);
            pSplatbRoot.Add(pSplat);

            TimerMan.Add(TimeEvent.Name.SplatRemoveUFO, new SplatRemoveEvent(this.pSplat), 0.5f);
        }
示例#3
0
        //-----------------------------------------------------------------------------
        // Game::Update()
        //      Called once per frame, update data, tranformations, etc
        //      Use this function to control process order
        //      Input, AI, Physics, Animation, and Graphics
        //-----------------------------------------------------------------------------


        public override void Update()
        {
            // Add your update below this line: ----------------------------
            //  stuff called every update no matter the scene here...
            //  example: like audio update


            GlobalTimer.Update(this.GetTime());

            // Hack to proof of concept...
            if (Azul.Input.GetKeyState(Azul.AZUL_KEY.KEY_0) == true)
            {
                pSceneContext.SetState(SceneContext.Scene.Demo);
            }

            if (Azul.Input.GetKeyState(Azul.AZUL_KEY.KEY_3) == true)
            {
                pSceneContext.SetState(SceneContext.Scene.Select);
            }

            if (Azul.Input.GetKeyState(Azul.AZUL_KEY.KEY_1) == true)
            {
                pSceneContext.SetState(SceneContext.Scene.Play);
                Score.SetCurrentPlayer(1);
            }

            if (Azul.Input.GetKeyState(Azul.AZUL_KEY.KEY_2) == true)
            {
                pSceneContext.SetState(SceneContext.Scene.Play);
                Score.SetCurrentPlayer(2);
            }

            if (Azul.Input.GetKeyState(Azul.AZUL_KEY.KEY_4) == true)
            {
                pSceneContext.SetState(SceneContext.Scene.GameOver);
            }



            // Update the scene
            (pSceneContext.GetState()).Update(this.GetTime());
        }
示例#4
0
        public override void Notify()
        {
            SceneContext pSceneContext = SceneContext.GetInstance();

            Debug.Assert(pSceneContext != null);

            SceneState sceneState = pSceneContext.GetState();

            if (pSceneContext.poScenePlayer2.numLives > 1)
            {
                pSceneContext.SetState(SceneContext.Scene.Player2);
            }
        }
示例#5
0
        public override void Notify()
        {
            SceneContext pSceneContext = SceneContext.GetInstance();

            Debug.Assert(pSceneContext != null);

            SceneState sceneState = pSceneContext.GetState();

            if (sceneState.name == SceneContext.Scene.Over)
            {
                pSceneContext.SetState(SceneContext.Scene.Select);
            }
        }
        public override void Execute()
        {
            // Let the gameObject deal with this...
            //this.pAlien.Remove();

            GameObject pA = (GameObject)this.pAlien;
            GameObject pB = (GameObject)Iterator.GetParent(pA);

            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();

                    // Recreate Grid on last alien delete
                    AlienGrid pGrid = (AlienGrid)pC;
                    pGrid.GenerateAlien(GameObjectMan.GetActive());
                    pGrid.ResetSpeed();
                    this.scenePlay.AddLife();
                }
            }

            // TODO:  update score - may need a better way (maybe an observer)
            SceneContext sc = SceneContext.GetInstance();

            sc.GetState().UpdateScore(this.pAlien.scoreValue);


            // TODO: Splat Alien - needs a better way
            this.pSplat = new Splat(GameObject.Name.Splat, GameSprite.Name.SplatAlien, pAlien.x, pAlien.y);
            pSplat.ActivateCollisionSprite(this.pSB_Boxes);
            pSplat.ActivateGameSprite(this.pSB_Aliens);

            GameObject pSplatbRoot = GameObjectMan.Find(GameObject.Name.SplatRoot);

            Debug.Assert(pSplatbRoot != null);
            pSplatbRoot.Add(pSplat);

            TimerMan.Add(TimeEvent.Name.SplatRemoveAlien, new SplatRemoveEvent(this.pSplat), 0.5f);
        }
示例#7
0
        //-----------------------------------------------------------------------------
        // Game::Update()
        //      Called once per frame, update data, tranformations, etc
        //      Use this function to control process order
        //      Input, AI, Physics, Animation, and Graphics
        //-----------------------------------------------------------------------------

        public override void Update()
        {
            // Update the scene
            pSceneContext.GetState().Update(this.GetTime());
        }
示例#8
0
 //-----------------------------------------------------------------------------
 // Game::Draw()
 //		This function is called once per frame
 //	    Use this for draw graphics to the screen.
 //      Only do rendering here
 //-----------------------------------------------------------------------------
 public override void Draw()
 {
     SceneContext.GetState().Draw();
 }
示例#9
0
        //-----------------------------------------------------------------------------
        // Game::Update()
        //      Called once per frame, update data, tranformations, etc
        //      Use this function to control process order
        //      Input, AI, Physics, Animation, and Graphics
        //-----------------------------------------------------------------------------

        public override void Update()
        {
            GlobalTimer.Update(this.GetTime());

            SceneContext.GetState().Update(this.GetTime());
        }
        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);
            }
        }