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(); } }
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, ScenePlay.ShipLives.ToString()); this.RunTime = Simulation.GetTotalTime() - ScenePlay.StartTimeDelta; //Debug.WriteLine(this.RunTime); 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(); } }
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(); } }
public override void Handle() { //set state of scene context to Scene Play ScenePlay.StartTimeDelta += (Simulation.GetTotalTime() - SceneOver.SwitchTime); ScenePlay2.StartTimeDelta += (Simulation.GetTotalTime() - SceneOver.SwitchTime); SpaceInvaders.pSceneContext.SetState(SceneContext.Scene.Play1); }
//----------------------------------------------------------------------------- // 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(); }
public override void Transition() { SpaceInvaders.UpdateHiScore(); SpriteBatchManager.SetActive(this.poSpriteBatchManager); InputManager.SetActive(this.poInputManager); FontManager.SetActive(this.poFontManager); SceneOver.SwitchTime = Simulation.GetTotalTime(); }
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(); } }
public override void Handle() { //set state of scene context to Scene Over if (ScenePlay.ShipLives == 0) { //Debug.WriteLine("P2 " + this.RunTime); SpaceInvaders.pSceneContext.SetState(SceneContext.Scene.Over); } else { //Debug.WriteLine("P2 " + this.RunTime); SpaceInvaders.pSceneContext.SetState(SceneContext.Scene.Play1); } ScenePlay.StartTimeDelta += (Simulation.GetTotalTime() - ScenePlay2.SwitchTime); }
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())); }
public override void Transition() { // update SpriteBatchMan() SpriteBatchManager.SetActive(this.poSpriteBatchManager); GameObjectManager.SetActive(this.poGameObjectManager); InputManager.SetActive(this.poInputManager); FontManager.SetActive(this.poFontManager); TimerManager.SetActive(this.poTimerManager); CollisionPairManager.SetActive(this.poCollisionPairManager); ScenePlay2.SwitchTime = Simulation.GetTotalTime(); if (ScenePlay2.ShipLives < 1 || ScenePlay2.ShipLives == 3) { AlienGrid pGrid = (AlienGrid)GameObjectManager.Find(GameObject.Name.AlienGrid); pGrid.ResetStartRate(); this.ResetAll(); } }
//call during the update loop //todo - drop the bomb depending on the number of steps taken OR number of aliens left! public static void UpdateBombDrop() { GridManager pGridMan = GridManager.privInstance(); Debug.Assert(pGridMan != null); Debug.Assert(pGridMan.pCurrentGrid != null); //get the total time float time = Simulation.GetTotalTime(); if (time > 5.0f) { if (pGridMan.randomInt / 2 == 0) { pGridMan.pCurrentGrid.DropBomb(); } //if the time is even, generate a new random number if ((int)time % 2 == 0) { pGridMan.privGenerateNewRandomNumber(); } } }
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); } }