예제 #1
0
 /// <summary>
 /// Creates the effect for when the player fires a bullet.
 /// </summary>
 /// <param name="position">Where on the screen to create the effect.</param>        
 public void CreatePlayerFireSmoke(Player player)
 {
     for (int i = 0; i < 8; ++i)
     {
         Particle p = CreateParticle();
         p.TextureName = "smoke";
         p.Texture = textureDictionary[p.TextureName];
         p.Color = Color.White;
         p.Position.X = player.Position.X + player.Width / 2;
         p.Position.Y = player.Position.Y;
         p.Alpha = 1.0f;
         p.AlphaRate = -1.0f;
         p.Life = 1.0f;
         p.Rotation = 0.0f;
         p.RotationRate = -2.0f + 4.0f * (float)random.NextDouble();
         p.Scale = 0.25f;
         p.ScaleRate = 0.25f;
         p.Velocity.X = -4 + 8.0f * (float)random.NextDouble();
         p.Velocity.Y = -16.0f + -32.0f * (float)random.NextDouble();
     }
 }
예제 #2
0
 /// <summary>
 /// Creates the mud/dust effect when the player moves.
 /// </summary>
 /// <param name="position">Where on the screen to create the effect.</param>        
 public void CreatePlayerDust(Player player)
 {
     for (int i = 0; i < 2; ++i)
     {
         Particle p = CreateParticle();
         p.TextureName = "smoke";
         p.Texture = textureDictionary[p.TextureName];
         p.Color = new Color(125, 108, 43);
         p.Position.X = player.Position.X + player.Width * (float)random.NextDouble();
         p.Position.Y = player.Position.Y + player.Height - 3.0f * (float)random.NextDouble();
         p.Alpha = 1.0f;
         p.AlphaRate = -2.0f;
         p.Life = 0.5f;
         p.Rotation = 0.0f;
         p.RotationRate = -2.0f + 4.0f * (float)random.NextDouble();
         p.Scale = 0.25f;
         p.ScaleRate = 0.5f;
         p.Velocity.X = -4 + 8.0f * (float)random.NextDouble();
         p.Velocity.Y = -8 + 4.0f * (float)random.NextDouble();
     }
 }
예제 #3
0
        public void ReadXml(XmlReader reader)
        {
            // Read the wrapper element
            reader.Read();

            // deserialize basic gameplay elements
            DeserializeGameplayMembers(reader);

            XmlSerializer bonusSerializer = new XmlSerializer(typeof(Bonus));
            bonus = bonusSerializer.Deserialize(reader) as Bonus;

            // Deserialize the player
            XmlSerializer playerSerializer = new XmlSerializer(typeof(Player));
            player = playerSerializer.Deserialize(reader) as Player;

            // Deserialize the aliens
            XmlSerializer enemySerializer = new XmlSerializer(typeof(Enemy));

            int enemyCount = int.Parse(reader.GetAttribute("Count"));

            // Read past the opening element for the alien list
            reader.Read();

            for (int i = 0; i < enemyCount; i++)
            {
                enemies.Add(enemySerializer.Deserialize(reader) as Enemy);
            }

            // Advance past the closing element if it exists
            if (enemyCount > 0)
            {
                reader.Read();
            }

            reader.Read();
        }
예제 #4
0
        public GameplayHelper(ContentManager contentManager, SpriteBatch spriteBatch,
            GraphicsDevice graphicsDevice)
        {
            random = new Random();

            worldBounds = new Rectangle(0, 0, (int)screenWidth, (int)screenHeight);

            gameOver = true;

            player = new Player();

            enemies = new List<Enemy>();

            bonus = new Bonus();

            InitializeAssets(contentManager, spriteBatch, graphicsDevice);
        }
예제 #5
0
        public GameplayHelper()
        {
            random = new Random();

            worldBounds = new Rectangle(0, 0, (int)screenWidth, (int)screenHeight);

            gameOver = true;

            player = new Player();

            enemies = new List<Enemy>();

            bonus = new Bonus();
        }