예제 #1
1
        public Invader(SpaceInvaders game)
            : base(game)
        {
            _Game = game;

                        _Velocity = Vector2.Zero;
        }
예제 #2
0
 public static void Main()
 {
     using (var game = new SpaceInvaders())
     {
         game.Run();
     }
 }
예제 #3
0
        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);
                }
            }
        }
예제 #4
0
        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();
        }
예제 #5
0
        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);
                }
            }
        }
예제 #6
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (SpaceInvaders game = new SpaceInvaders())
     {
         game.Run();
     }
 }
예제 #7
0
        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();
        }
예제 #8
0
 /// <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();
        }
예제 #10
0
        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());

            //}
        }
예제 #12
0
        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;
            }
        }
예제 #13
0
 public static void Main()
 {
     using (var game = new SpaceInvaders())
     {
         game.Run();
     }
 }
예제 #14
0
        public static void SetGame(SpaceInvaders inGame)
        {
            Debug.Assert(inGame != null);

            GameStateManager pInstance = GameStateManager.PrivInstance();

            pInstance.pGame = inGame;
        }
예제 #15
0
        //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();
        }
예제 #16
0
        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();
        }
예제 #17
0
        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();
        }
예제 #18
0
        public override void Notify()
        {
            SpaceInvaders pSI = SpaceInvaders.GetInstance();

            pSI.UnLoadContent();

            pSI.SetState(SpaceInvaders.State.GamePlayingState);
            pSI.LoadContent();
        }
예제 #19
0
        static void Main(string[] args)
        {
            //Create the instance
            SpaceInvaders game = new SpaceInvaders();

            Debug.Assert(game != null);

            //Start the game
            game.Run();
        }
예제 #20
0
        public override void Transition()
        {
            SpaceInvaders.UpdateHiScore();

            SpriteBatchManager.SetActive(this.poSpriteBatchManager);
            InputManager.SetActive(this.poInputManager);
            FontManager.SetActive(this.poFontManager);

            SceneOver.SwitchTime = Simulation.GetTotalTime();
        }
예제 #21
0
        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"));
            }
        }
예제 #22
0
        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;
        }
예제 #23
0
        static void Main(string[] args)
        {
            GameMan.Create();
            // Create the instance
            SpaceInvaders game = GameMan.GetGame();

            Debug.Assert(game != null);

            // Start the game
            game.Run();
        }
예제 #24
0
        public override void Notify()
        {
            SpaceInvaders pSI = SpaceInvaders.GetInstance();

            pSI.UnLoadContent();

            pSI.SetState(SpaceInvaders.State.MenuState);
            pSI.LoadContent();

            pSI.scoreOne = 0;
        }
예제 #25
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();
            }
        }
예제 #27
0
        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();
        }
예제 #28
0
        static void Main(string[] args)
        {
            game = new SpaceInvaders();
            Thread inputThread = new Thread(InputThread);

            inputThread.Start();

            while (true)
            {
                Thread.Sleep(200);
                game.Update();
                game.Draw();
            }
        }
예제 #29
0
        //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);
                }
            }
        }
예제 #30
0
        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);
        }
예제 #31
0
        //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();
            }
        }
예제 #32
0
        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
            }
        }
예제 #33
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()));
        }