public Invader(SpaceInvaders game) : base(game) { _Game = game; _Velocity = Vector2.Zero; }
public static void Main() { using (var game = new SpaceInvaders()) { game.Run(); } }
public override void Handle(SpaceInvaders pGame) { bool isTwoPlayer = GameStateManager.GetGame().IsTwoPlayerMode(); Player pPlayer1 = GameStateManager.GetGame().GetPlayer(Player.Name.Player1); if (isTwoPlayer) { // Two-Player Mode if (pPlayer1.GetNumLives() < 1) { // Update HiScore this.UpdateHiScore(pGame, pPlayer1.GetPoints()); } // Switch to player 2 this.SwitchState(pGame, GameStateManager.GameState.Player2); } else { // One-Player Mode if (pPlayer1.GetNumLives() < 1) { // Update HiScore this.UpdateHiScore(pGame, pPlayer1.GetPoints()); // Go to End state this.SwitchState(pGame, GameStateManager.GameState.End); } } }
static void Main(string[] args) { game = new SpaceInvaders(); // create update thread Thread inputthread = new Thread(InputThread); inputthread.Start(); // alien update thread // Thread alienthread = new Thread(AlienThread); // alienthread.Start(); // game loop while (true) { Thread.Sleep(200); // update the game game.Update(); // draw the game game.Draw(); } // when the game is done. // inputthread.Abort(); }
public override void Execute() { GameObject pAlienObject = (GameObject)this.pAlien; GameObject pColumn = (GameObject)Iterator.GetParent(pAlienObject); SpaceInvaders pGame = GameMan.GetGame(); //always remove the alien pAlienObject.Remove(); //check if Column has aliens left //true means we have no more children, and safe to remove column if (PrivCheckParent(pColumn) == true) { GameObject pGroup = (GameObject)Iterator.GetParent(pColumn); pColumn.Remove(); //check if Grid/Group had any columns left //true means we have no more children, and safe to change states if (PrivCheckParent(pGroup) == true) { //We just beat a wave, so call the the states handle // to either go to next wave or to see if its the end of the game TimerMan.Add(TimeEvent.Name.GameStateChange, new GameStateChange(true), 5.0f); } } }
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { using (SpaceInvaders game = new SpaceInvaders()) { game.Run(); } }
public void SwitchState(SpaceInvaders pGame, GameStateManager.GameState nextState) { // Detach current state input observers pGame.DetachStateInputObservers(); // Queue any Time Events for later TimeEvent pTimeEvent = TimerManager.Pop(); while (pTimeEvent != null) { this.GetQueuedTimeEventManager().Enqueue(pTimeEvent.GetName(), pTimeEvent.GetCommand(), pTimeEvent.GetDeltaTime()); pTimeEvent = TimerManager.Pop(); } // Change game state pGame.SetGameState(nextState); // Load up TimerManager with next state's Time Events QueuedTimeEvent qte = pGame.GetStateQueuedTimeEventManager().Dequeue(); while (qte != null) { TimerManager.Add(qte.GetTimeEventName(), qte.GetCommand(), qte.GetTimeEventDelta()); // Get next queued event qte = pGame.GetStateQueuedTimeEventManager().Dequeue(); } // Attach next state input observers pGame.AttachStateInputObservers(); }
/// <summary> /// Le point d'entrée de l'application /// </summary> static void Main(string[] args) { using (SpaceInvaders game = new SpaceInvaders()) { game.Run(); } }
static void Main(string[] args) { Game SpaceInvaders = new SpaceInvaders(); SpaceInvaders.Setup(); SpaceInvaders.Start(); }
public override void Handle() { //handle is called before entering gamestate loops //fight the wave if (bWaveFinished == false) { Debug.WriteLine("Wave 1"); Debug.WriteLine("-----------------------------------------------------------------"); // De-activate sprite batch SpriteBatch pIntroScreen = SpriteBatchMan.Find(SpriteBatch.Name.IntroScreen); pIntroScreen.bToggle = false; this.bWaveFinished = true; LoadContent(); //Update(); } // wave is finished go to the next one else { Debug.WriteLine("Wave 2"); Debug.WriteLine("-----------------------------------------------------------------"); this.bWaveFinished = false; SpaceInvaders pGame = GameMan.GetGame(); pGame.SetGameState(GameMan.State.LVL2); pGame.GetCurrentState().Handle(); } }
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() { SpaceInvaders pSI = SpaceInvaders.GetInstance(); GameObject pObject = this.pSubject.pObjB; GameObject.Name name = pObject.name; switch (name) { case GameObject.Name.Squid: pSI.scoreOne += 60; break; case GameObject.Name.Octopus: pSI.scoreOne += 20; break; case GameObject.Name.Crab: pSI.scoreOne += 40; break; case GameObject.Name.UFO: pSI.scoreOne += 100; break; default: Debug.Assert(false); break; } }
public static void SetGame(SpaceInvaders inGame) { Debug.Assert(inGame != null); GameStateManager pInstance = GameStateManager.PrivInstance(); pInstance.pGame = inGame; }
//test for two player private GameMan() { this.poSpaceInvaders = null; this.pIntro = new IntroState(); this.pInGame = new InGameState(); this.pLVL2 = new InGameStateLV2(); this.pEnd = new EndGameState(); }
public override void Notify() { //Debug.WriteLine("1 key pressed"); //this is for the Intro //might be a bug here, if people press it again SpaceInvaders pGame = GameMan.GetGame(); pGame.GetCurrentState().Handle(); }
public override void Handle() { //when the person makes the choice we change states // then call the handle() SpaceInvaders pGame = GameMan.GetGame(); pGame.SetGameState(GameMan.State.InGame); pGame.GetCurrentState().Handle(); }
public override void Notify() { SpaceInvaders pSI = SpaceInvaders.GetInstance(); pSI.UnLoadContent(); pSI.SetState(SpaceInvaders.State.GamePlayingState); pSI.LoadContent(); }
static void Main(string[] args) { //Create the instance SpaceInvaders game = new SpaceInvaders(); Debug.Assert(game != null); //Start the game game.Run(); }
public override void Transition() { SpaceInvaders.UpdateHiScore(); SpriteBatchManager.SetActive(this.poSpriteBatchManager); InputManager.SetActive(this.poInputManager); FontManager.SetActive(this.poFontManager); SceneOver.SwitchTime = Simulation.GetTotalTime(); }
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")); } }
private GameStateManager() { // Store the states this.pAttractState = new GameAttractState(GameStateManager.GameState.Attract); this.pPlayer1State = new GamePlayer1State(GameStateManager.GameState.Player1); this.pPlayer2State = new GamePlayer2State(GameStateManager.GameState.Player2); this.pEndState = new GameEndState(GameStateManager.GameState.End); // set active this.pGame = null; }
static void Main(string[] args) { GameMan.Create(); // Create the instance SpaceInvaders game = GameMan.GetGame(); Debug.Assert(game != null); // Start the game game.Run(); }
public override void Notify() { SpaceInvaders pSI = SpaceInvaders.GetInstance(); pSI.UnLoadContent(); pSI.SetState(SpaceInvaders.State.MenuState); pSI.LoadContent(); pSI.scoreOne = 0; }
//this is hopefully going to sound of every 1 second not sure if thats what its supposed to do public override void Execute(float deltaTime) { SpaceInvaders pGame = GameMan.GetGame(); IrrKlang.ISoundEngine pSndEngine = pGame.GetSndEngine(); pSndEngine.SoundVolume = 0.1f; pSndEngine.Play2D("ufo_lowpitch.wav"); TimerMan.Add(TimeEvent.Name.PlaySound, this, deltaTime); }
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(); } }
static void Main(string[] args) { GameStateManager.Create(); // Create the instance SpaceInvaders game = new SpaceInvaders(); Debug.Assert(game != null); GameStateManager.SetGame(game); // Start the game game.Run(); }
static void Main(string[] args) { game = new SpaceInvaders(); Thread inputThread = new Thread(InputThread); inputThread.Start(); while (true) { Thread.Sleep(200); game.Update(); game.Draw(); } }
//Grid Observer only worryies about moving the grid back and forth and down public override void Notify() { float movement; //Debug.WriteLine("Grid_Observer: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB); AlienGroup pGrid = (AlienGroup)this.pSubject.pObjA; WallCategory pWall = (WallCategory)this.pSubject.pObjB; if (pWall.GetCategoryType() == WallCategory.Type.Right) { //BAD HACK FIX LATER movement = pGrid.GetDeltaMove() * -1.0f; pGrid.SetDeltaMove(movement); pGrid.MoveAcross(); pGrid.MoveDown(); } else if (pWall.GetCategoryType() == WallCategory.Type.Left) { movement = pGrid.GetDeltaMove() * -1.0f; pGrid.SetDeltaMove(movement); pGrid.MoveAcross(); pGrid.MoveDown(); } else { //Bottom Wall hit, move aliens up and reset Waves before Game Over SpaceInvaders pGame = GameMan.GetGame(); GameState pState = pGame.GetCurrentState(); if (pState.GetStateName() == GameMan.State.InGame) { InGameState pLvl1 = (InGameState)pState; pLvl1.SetStateToggle(false); TimerMan.Add(TimeEvent.Name.GameStateChange, new GameStateChange(false), 2.0f); } else if (pState.GetStateName() == GameMan.State.LVL2) { InGameStateLV2 pLvl2 = (InGameStateLV2)pState; pLvl2.SetStateToggle(false); TimerMan.Add(TimeEvent.Name.GameStateChange, new GameStateChange(false), 2.0f); } } }
public static SpaceInvaders Create() { // make sure its the first time Debug.Assert(pInstance == null); // Do the initialization if (pInstance == null) { pInstance = new SpaceInvaders(); } Debug.Assert(pInstance != null); pInstance.SetState(SpaceInvaders.State.MenuState); return(pInstance); }
//this will be called if a wave is completed for better or worse public override void Execute(float deltaTime) { SpaceInvaders pGame = GameMan.GetGame(); if (wonOrLost == true) { pGame.GetCurrentState().Handle(); } else { pGame.SetGameState(GameMan.State.GameOver); pGame.GetCurrentState().Handle(); } }
public override void Notify() { // we need to revert lvl1 or lvl2 to original forms // because we lost and will need to re-load content //ship was hit take a life and subtract from score PlayerMan.P1TakeLife(); PlayerMan.SetP1Score(-250); float P1lives = PlayerMan.GetP1Lives(); SpaceInvaders pGame = GameMan.GetGame(); //check if they have more lives if (P1lives == 0) { // last life i was stil able to shoot Ship pShip = ShipMan.GetShip(); pShip.SetShootState(ShipMan.ShootState.End); pShip.SetMoveState(ShipMan.MoveState.NoMove); GameState pState = pGame.GetCurrentState(); if (pState.GetStateName() == GameMan.State.InGame) { InGameState pLvl1 = (InGameState)pState; pLvl1.SetStateToggle(false); TimerMan.Add(TimeEvent.Name.GameStateChange, new GameStateChange(false), 5.0f); } else if (pState.GetStateName() == GameMan.State.LVL2) { InGameStateLV2 pLvl2 = (InGameStateLV2)pState; pLvl2.SetStateToggle(false); TimerMan.Add(TimeEvent.Name.GameStateChange, new GameStateChange(false), 5.0f); } } else { //do nothing } }
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())); }