Ejemplo n.º 1
0
 public static void Update()
 {
     MovementManager();
     Landing();
     UpdateEnemies();
     Shoot();
     UpdateBullets();
     Mothership.Update();
 }
Ejemplo n.º 2
0
 private void UpdateBullets()
 {
     for (int i = 0; i < bullets.Length; i++)
     {
         if (!bullets[i].IsFired)
         {
             continue;
         }
         bullets[i].Update();
         if (EnemiesManager.IsCollideWithBullet(bullets[i]) ||
             Mothership.IsCollideWithBullet(bullets[i]))
         {
             bullets[i].IsFired = false;
         }
     }
 }
Ejemplo n.º 3
0
        /**
         * Constructor for the engine.
         * _g: The context to render to.
         */
        public Engine(Graphics _g)
        {
            instance = this;

            g                  = _g;
            backBuffer         = new Bitmap(Width, Height);
            backBufferGraphics = Graphics.FromImage(backBuffer);
            gameObjects        = new List <GameObject>();
            soundEffects       = new SoundPlayer[3];

            //Initialize the pool of missiles
            missiles = new Missile[15];
            for (int i = 0; i < 15; i++)
            {
                missiles[i] = new Missile(0, 0, Width / 100, Width / 50);
                gameObjects.Add(missiles[i]);
            }

            bombs = new List <Bomb>();

            //Test fleet
            fleet = new Fleet(Width / 2, 0, 5, 5);
            gameObjects.Add(fleet);
            gameObjects.AddRange(fleet.GetShips());


            //Create the player character
            mship = new Mothership(Width / 2 - Width / 100, Height - Width / 25, Width / 25, Width / 50);
            gameObjects.Add(mship);

            currentState = eState.MainMenu;

            main = new Menu();
            main.Add(new GUILabel("Start", Width / 2, Height / 2, Width / 10, Height / 50), new Menu.Action(e => e.SetState(eState.Playing)));
            main.Add(new GUILabel("Quit", Width / 2, Height / 2 + Height / 25, Width / 10, Height / 50), new Menu.Action(e => e.Quit()));

            bonusShip = new BonusShip(-100, 0, 100, 100);
            gameObjects.Add(bonusShip);

            LoadSounds();
        }
Ejemplo n.º 4
0
        private void loadDrawables()
        {
            m_Player1Spaceship       = new Player1Spaceship(Game);
            m_Player1Spaceship.Died += onSpaceshipKilled;
            this.Add(m_Player1Spaceship);

            m_Player2Spaceship       = new Player2Spaceship(Game);
            m_Player2Spaceship.Died += onSpaceshipKilled;
            this.Add(m_Player2Spaceship);

            m_Player1Lives = new LivesRow(Game, m_Player1Spaceship.Lives, m_Player1Spaceship.AssetName);
            m_Player1Spaceship.LivesCountChanged += m_Player1Lives.UpdateLivesCount;
            this.Add(m_Player1Lives);

            m_Player2Lives = new LivesRow(Game, m_Player2Spaceship.Lives, m_Player2Spaceship.AssetName);
            m_Player2Spaceship.LivesCountChanged += m_Player2Lives.UpdateLivesCount;
            this.Add(m_Player2Lives);

            m_Player1ScoreText = new ScoreText(m_GameState.Player1Name, Color.Blue, Game, k_ScoreFontAsset);
            m_GameState.Player1ScoreChanged += m_Player1ScoreText.UpdateNewScore;
            this.Add(m_Player1ScoreText);

            m_Player2ScoreText = new ScoreText(m_GameState.Player2Name, Color.Green, Game, k_ScoreFontAsset);
            m_GameState.Player2ScoreChanged += m_Player2ScoreText.UpdateNewScore;
            this.Add(m_Player2ScoreText);

            m_Mothership = new Mothership(Game);
            this.Add(m_Mothership);

            m_InvadersMatrix = new InvadersMatrix(Game);
            m_InvadersMatrix.invadersMatrixReachedBottomScreen += () => m_GameOver = true;
            m_InvadersMatrix.AllInvadersWereDefeated           += () => m_LevelCleared = true;

            this.Add(m_InvadersMatrix);

            m_DancingBarriersRow = new DancingBarriersRow(Game);
            this.Add(m_DancingBarriersRow);
        }
Ejemplo n.º 5
0
 public static void Draw()
 {
     DrawEnemies();
     DrawBullets();
     Mothership.Draw();
 }