Ejemplo n.º 1
0
        private void UpdateBoons()
        {
            int boonsSize = Boons.Count;

            for (int i = 0; i < boonsSize; i++)
            {
                BoonObject curBoon = Boons.Dequeue();

                // Update the position of the current Destructible
                curBoon.Update(gameSpeed, Ship.Position, Ship.Attraction);

                bool boonCollected = curBoon.isCollected(Ship.Bounds, Ship.GrabRadius);
                if (boonCollected)
                {
                    if (EnumEquals(curBoon.type, boonTypes.money))
                    {
                        Money++;
                    }
                    if (EnumEquals(curBoon.type, boonTypes.material))
                    {
                        Material++;
                    }
                    if (EnumEquals(curBoon.type, boonTypes.bonus))
                    {
                        Bonuses++;
                    }
                }

                bool onScreen = !(curBoon.Position.Y > MaxY || boonCollected);
                if (onScreen) // If the Enemy is not past the bottom of the screen
                {
                    Boons.Enqueue(curBoon);
                }
            }
        }
Ejemplo n.º 2
0
        } // NEEDS BALANCING

        private void spawnRandomBoon(Vector2 pos, bool bonusPossible)
        {
            BoonObject newBoon    = new BoonObject(pos, bonusPossible, r);
            bool       boonExists = !EnumEquals(newBoon.type, boonTypes.none);

            if (boonExists)
            {
                Boons.Enqueue(newBoon);
            }
        }
Ejemplo n.º 3
0
 private void spawnRandomBoon(Vector2 pos, bool bonusPossible)
 {
     BoonObject newBoon = new BoonObject(pos, bonusPossible, r);
     bool boonExists = !EnumEquals(newBoon.type, boonTypes.none);
     if (boonExists)
         Boons.Enqueue(newBoon);
 }
Ejemplo n.º 4
0
        protected override void Draw(GameTime gameTime)
        {
            graphics.GraphicsDevice.Clear(Color.Black);
            spriteBatch.Begin();

            //myBackground.Draw(spriteBatch);
            proceduralStarBackground.Draw(spriteBatch);
            spriteBatch.End();

            spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);

            if (!gameOver)
            {
                Ship.Draw(spriteBatch);

                // Go through bullets, drawing each one
                int size = Bullets.Count;
                for (int i = 0; i < size; i++)
                {
                    BulletObject curBullet = Bullets.Dequeue();

                    if (!TryHit(curBullet))
                    {
                        curBullet.Draw(spriteBatch);
                        Bullets.Enqueue(curBullet);
                    }
                    else
                    {
                        if (Ship.Health <= 0)
                        {
                            gameOver = true;
                        }
                    }
                }


                //destructibleObjects.DrawAll(spriteBatch);

                // Go through destructables, drawing each one
                int destSize = EnemyShips.Count;
                for (int i = 0; i < destSize; i++)
                {
                    EnemyShip curDest = EnemyShips.Dequeue();
                    curDest.Draw(spriteBatch, enemy1);
                    EnemyShips.Enqueue(curDest);
                }

                // Go through boons, drawing each one
                int boonSize = Boons.Count;
                for (int i = 0; i < boonSize; i++)
                {
                    BoonObject curBoon = Boons.Dequeue();
                    curBoon.Draw(spriteBatch, boonTextures);
                    Boons.Enqueue(curBoon);
                }

                DrawGUI();
            }
            else
            {
                DrawText(new Vector2(MaxX / 2 - 50, MaxY / 2 - 10), "GAME OVER");
                DrawText(new Vector2(MaxX / 2 - 85 - score.ToString().Length, MaxY / 2 + 10), "Final Score: " + score);
            }

            // FPS COUNTER -- DEBUG/OPTIMIZATION PURPOSES
            numOfFrames++;

            FPS = gameTime.ElapsedGameTime.Ticks;
            spriteBatch.DrawString(font, "FPS: " + FPS.ToString(), new Vector2(0, 40), Color.White);

            spriteBatch.End();

            base.Draw(gameTime);
        }