コード例 #1
0
        public override void Update(float systemTime)
        {
            // Single Step, Free running...
            Simulation.Update(systemTime);

            // Handels Keyboard input
            InputManager.Update();

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


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


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


                // Delete any objects here...
                DelayedObjectManager.Process();

                // Check to see if all aliens are dead to move to the next level.
                Level.Update();
            }
        }
コード例 #2
0
        public override void Update(float systemTime)
        {
            InputManager.Update();

            FontManager.Update(Font.Name.Player1Score, SpaceInvaders.pPlayer1Score);
            FontManager.Update(Font.Name.Player2Score, SpaceInvaders.pPlayer2Score);
            FontManager.Update(Font.Name.HiScore, SpaceInvaders.pHiScore);
            FontManager.Update(Font.Name.Lives, ScenePlay2.ShipLives.ToString());


            this.RunTime = Simulation.GetTotalTime() - ScenePlay2.StartTimeDelta;
            //Debug.WriteLine(this.RunTime);

            if (Simulation.GetTimeStep() > 0.0f)
            {
                TimerManager.Update(this.RunTime);
                GameObjectManager.Update();
                //Collision Checks
                CollisionPairManager.Process();
                // Delete any objects here...
                DelayedObjectManager.Process();

                //check if all alien killed
                AlienGrid pGrid = (AlienGrid)GameObjectManager.Find(GameObject.Name.AlienGrid);
                if (pGrid.GetAlienCount() < 1)
                {
                    pGrid.IncreaseStartRate();
                    this.ResetAll();
                }
            }
        }
コード例 #3
0
        override public void Update(float systemTime)
        {
            // Snd update - keeps everything moving and updating smoothly
            sndEngine.Update();

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

            // Input
            InputMan.Update();

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

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

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

                // Delete any objects here...
                DelayedObjectMan.Process();
            }
        }
コード例 #4
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()
        {
            //check time;
            //Debug.WriteLine("Simulation.GetTimeStep()  = {0}", Simulation.GetTimeStep());
            //Debug.WriteLine("Simulation.GetTotalTime() = {0}", Simulation.GetTotalTime());



            //Update game simulation
            // Single Step, Free running...
            Simulation.Update(this.GetTime());

            //always update input asap
            InputManager.Update();

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

                //with simulator timer
                TimerEventManager.Update(Simulation.GetTotalTime());
                ////no simulator timer
                //TimerEventManager.Update(this.GetTime());


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

                //GameObjectManager updates ALL game objects and sprite positions
                // remember each game object has a proxy sprite attached
                GameObjectManager.Update();

                GridManager.UpdateBombDrop();
            }


            ////Original, No Simulation ---------------------------------------------------

            ////always update input asap
            //InputMan.Update();

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

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

            ////GameObjectManager updates ALL game objects and sprite positions
            //// remember each game object has a proxy sprite attached
            //// walk through all objects and push to flyweight
            //GameObjectMan.Update();

            //// Delete any objects here...
            //DelayedObjectMan.Process();
        }
コード例 #5
0
        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();
            }
        }
コード例 #6
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()));
        }
コード例 #7
0
        public override void Notify()
        {
            //Delete Alien
            //Debug.WriteLine("RemoveShieldBrickObserver: {0} {1}", this.subject.gameObject_A, this.subject.gameObject_B);

            //set this observer's alien object as the subject's pointer object that got hit
            //this.pAlienObj = (AlienType)this.pSubject.pObjB;
            this.pAlienObj = (GameObject)this.pSubject.pObjB;
            Debug.Assert(this.pAlienObj != null);

            //set the alien object as markedForDeath
            if (this.pAlienObj.markForDeath == false)
            {
                this.pAlienObj.markForDeath = true;

                ////hold the x, y coordinates of the target alien;
                //int index = pAlienObj.index;
                //float target_X = pAlienObj.pProxySprite.x;
                //float target_Y = pAlienObj.pProxySprite.y;

                ////create the alien explosion object to temporarily replace the normal alien object in the grid
                //ExplodingAlien pExplodeAlien = new ExplodingAlien(GameObject.Name.ExplodingAlien, GameSprite.Name.AlienExplosion, index, target_X, target_Y);

                ////get the right sprite batch and activate the explosion sprite
                //SpriteBatch pSB_GameSprites = SpriteBatchManager.Find(SpriteBatch.Name.GameSprites);
                //SpriteBatch pSB_Boxes = SpriteBatchManager.Find(SpriteBatch.Name.SpriteBoxes);

                ////activate the game and collision sprites
                //pExplodeAlien.ActivateGameSprite(pSB_GameSprites);
                //pExplodeAlien.ActivateCollisionSprite(pSB_Boxes);

                ////hold a pointer to old alien and its parent;
                //GameObject targetAlien = (GameObject)this.pAlienObj;
                //GameObject parentColumn = (GameObject)targetAlien.pParent;

                ////make sure the parent exists;
                //Debug.Assert(parentColumn != null);

                ////remove the alien
                //targetAlien.Remove();
                //Debug.WriteLine("removing alien {0} at x:{1}, y: {2}, sx: {3}, sy: {4}", targetAlien.pProxySprite.pSprite.GetName(),
                //    targetAlien.pProxySprite.x,
                //    targetAlien.pProxySprite.y,
                //    targetAlien.pProxySprite.sx,
                //    targetAlien.pProxySprite.sy
                //);

                ////hot swap the object pointers!
                ////set this remove alien's pAlienObj pointer to explosion alien;
                //this.pAlienObj = pExplodeAlien;

                ////insert the explosion alien as a child of column (where old alien used to be)
                //PCSTree rootGamObjTree = GameObjectManager.GetRootTree();
                //Debug.Assert(rootGamObjTree != null);

                ////update the coordinate data to render in old spot (GameObjectManager already called update)
                //this.pAlienObj.Update();

                //rootGamObjTree.Insert(this.pAlienObj, parentColumn);

                //Debug.WriteLine("added exploding alien {0} at x:{1}, y: {2}, sx: {3}, sy: {4}", pExplodeAlien.pProxySprite.pSprite.GetName(),
                //    pExplodeAlien.pProxySprite.x,
                //    pExplodeAlien.pProxySprite.y,
                //    pExplodeAlien.pProxySprite.sx,
                //    pExplodeAlien.pProxySprite.sy
                //);

                //Debug.WriteLine("added this pAlienObj {0} at x:{1}, y: {2}, sx: {3}, sy: {4}", this.pAlienObj.pProxySprite.pSprite.GetName(),
                //    this.pAlienObj.pProxySprite.x,
                //    this.pAlienObj.pProxySprite.y,
                //    this.pAlienObj.pProxySprite.sx,
                //    this.pAlienObj.pProxySprite.sy
                //);


                ////before removal, swap the sprite of JUST THIS ALIEN'S sprite image to the explosion sprite
                ////this forces ALL sprites to do the pop animation. dumb proxy sprites
                //this.pAlienObj.ChangeImage(Image.Name.AlienExplosionPop);

                //test - try and hot swap proxy sprite with this game sprite?
                //Azul.Rect pProxySpriteRect = this.pAlienObj.pProxySprite.pSprite.GetScreenRect();
                //Azul.Color white = new Azul.Color(1, 1, 1);
                //Image pImage = ImageManager.Find(Image.Name.AlienExplosionPop);

                float currentTime = Simulation.GetTimeStep();
                float totalTime   = Simulation.GetTotalTime();


                //Delay
                //todo create an ObserverManager or refactor DelayObjectManager to pool observer objects - avoid using new at all cost!
                RemoveAlienObserver observer = new RemoveAlienObserver(this);
                DelayedObjectManager.Attach(observer);
            }
            else
            {
                Debug.Assert(false);
            }
        }