Guest User

Untitled

a guest
Jul 21st, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.70 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Microsoft.Xna.Framework;
  5. using Microsoft.Xna.Framework.Audio;
  6. using Microsoft.Xna.Framework.Content;
  7. using Microsoft.Xna.Framework.GamerServices;
  8. using Microsoft.Xna.Framework.Graphics;
  9. using Microsoft.Xna.Framework.Input;
  10. using Microsoft.Xna.Framework.Media;
  11.  
  12.  
  13. namespace SpaceInvaders
  14. {
  15.     /// <summary>
  16.     /// This is a game component that implements IUpdateable.
  17.     /// </summary>
  18.     public class MiniMap : Microsoft.Xna.Framework.DrawableGameComponent
  19.     {
  20.         private Game1 Game;
  21.  
  22.         private Texture2D original;
  23.         private Texture2D minienemy;
  24.         public List<Vector2> points;
  25.  
  26.    
  27.         public MiniMap(Game game)
  28.             : base(game)
  29.         {
  30.             // TODO: Construct any child components here
  31.             this.Game = (Game1)game;
  32.         }
  33.  
  34.         /// <summary>
  35.         /// Allows the game component to perform any initialization it needs to before starting
  36.         /// to run.  This is where it can query for any required services and load content.
  37.         /// </summary>
  38.         public override void Initialize()
  39.         {
  40.            
  41.             // TODO: Add your initialization code here
  42.             original = Game.Content.Load<Texture2D>("minimap");
  43.             minienemy = Game.Content.Load<Texture2D>("enemymini");
  44.             points = new List<Vector2>();
  45.  
  46.             foreach (Enemy en in Game.enemies.enemies)
  47.             {
  48.                 Vector2 point = new Vector2();
  49.                 point.X = (en.position.X / 4) + 300;
  50.                 point.Y = en.position.Y / 4;
  51.                 points.Add(point);
  52.  
  53.             }
  54.  
  55.             base.Initialize();
  56.         }
  57.  
  58.         /// <summary>
  59.         /// Allows the game component to update itself.
  60.         /// </summary>
  61.         /// <param name="gameTime">Provides a snapshot of timing values.</param>
  62.         public override void Update(GameTime gameTime)
  63.         {
  64.            
  65.             // TODO: Add your update code here
  66.             for (int i = 0; i < Game.enemies.enemies.Count; i++)
  67.             {
  68.                 Vector2 point = points.ElementAt(i);
  69.                 point.X = (Game.enemies.enemies.ElementAt(i).position.X / 4) + 300;
  70.                 point.Y = (Game.enemies.enemies.ElementAt(i).position.Y / 4);
  71.                 points[i] = point;
  72.             }
  73.             base.Update(gameTime);
  74.         }
  75.  
  76.  
  77.         public override void Draw(GameTime gameTime)
  78.         {
  79.            
  80.                 foreach (Vector2 point in points)
  81.                 {
  82.                     Game.spriteBatch.Draw(minienemy, point, Color.White);
  83.                 }
  84.  
  85.             base.Draw(gameTime);
  86.         }
  87.     }
  88. }
Add Comment
Please, Sign In to add comment