Exemple #1
0
 /// <summary>
 /// Draw the mover's area.
 /// </summary>
 /// <param name="spriteBatchManager">SpriteBatchManager used to draw sprites.</param>
 /// <param name="areaManager">AreaManager used to draw areas.</param>
 /// <param name="gameTime">Provides a snapshot of timing values.</param>
 public void Draw(SpriteManager spriteBatchManager, AreaManager areaManager, GameTime gameTime)
 {
     // If the mover is enabled.
     if (this.Enabled)
     {
         // Draw the area.
         areaManager.Draw(this.Area);
     }
 }
Exemple #2
0
        /// <summary>
        /// Draw the aim.
        /// </summary>
        /// <param name="spriteBatchManager">SpriteBatchManager used to draw sprites.</param>
        /// <param name="areaManager">AreaManager used to draw areas.</param>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public void Draw(SpriteManager spriteBatchManager, AreaManager areaManager, GameTime gameTime)
        {
            // If the aim is enabled.
            if (this.Enabled)
            {
                // Updates the aim ten times per second.
                if (true || gameTime.TotalGameTime.Milliseconds % 100 == 0)
                {
                    // Get all the units of the game.
                    List <Unit> units = new List <Unit>();
                    units.AddRange(this.Unit.Player.Units);
                    units.AddRange(this.Unit.Player.Enemy.Units);

                    bool isOverSomething = false;

                    // Check if the aim is over some unit.
                    for (int index = 0; index < units.Count; index++)
                    {
                        // Get the center position of the unit.
                        Vector2 unitPosition = new Vector2(units[index].Position.X + units[index].Texture.Width / 2, units[index].Position.Y + units[index].Texture.Height / 8);

                        // Calculates the distance between the unit and the aim.
                        if (Vector2.Distance(this.Position, unitPosition) < 40)
                        {
                            isOverSomething = true;

                            // Determine if the player owner of the unit is the enemy;
                            if (units[index].Player != this.Unit.Player)
                            {
                                this.TextureToDraw = this.AimEnemy;
                            }
                            else
                            {
                                this.TextureToDraw = this.AimAlly;
                            }

                            this.Target = units[index];
                        }
                    }

                    if (!isOverSomething)
                    {
                        this.TextureToDraw = this.AimNothing;
                        this.Target        = null;
                    }
                }

                // Draw the aim.
                Vector2 position = new Vector2(this.Position.X - this.AimAlly.Width / 2, this.Position.Y - this.AimAlly.Height / 2);
                spriteBatchManager.Draw(this.TextureToDraw, position, Color.White, 60);

                // Draw the area.
                areaManager.Draw(this.Area);
            }
        }