2 using System.Collections.Generic;
5 using Microsoft.Xna.Framework;
6 using Microsoft.Xna.Framework.Content;
7 using Microsoft.Xna.Framework.Graphics;
8 using Microsoft.Xna.Framework.Input;
14 List<Projectile> mProjectiles = new List<Projectile>();
15 List<Character> mCharacters = new List<Character>();
21 mCharacters = characters;
26 /// LoadContent will be called once per game and is the place to load
27 /// all of your content.
29 public void LoadContent(ContentManager contentManager)
31 Texture2D everything = contentManager.Load<Texture2D>("cs");
32 mMap = contentManager.Load<Map>("Maps/stable");
33 Map.DefaultTile = contentManager.Load<Texture2D>("default");
34 mMap.CenterCell = new Vector2(5,5);
35 //List<object> entities = mMap.GetAllEntities();
36 mProjectiles.Add(new Projectile(mMap, everything, new Vector2(5,5), 10, 10, 300, 300));
37 // TODO: use this.Content to load your game content here
41 /// UnloadContent will be called once per game and is the place to unload
44 public void UnloadContent()
46 // TODO: Unload any non ContentManager content here
50 /// Allows the game to run logic such as updating the world,
51 /// checking for collisions, gathering input, and playing audio.
53 /// <param name="gameTime">Provides a snapshot of timing values.</param>
54 public void Update(TimeSpan timespan)
57 foreach (Projectile projectile in mProjectiles)
59 projectile.Update(timespan);
62 foreach (Character character in mCharacters)
64 foreach (Projectile projectile in mProjectiles)
66 if (projectile.GridX == character.GridX && projectile.GridY == character.GridY)
68 //Debug - not sure if you can remove while doing for each
69 //Alternative - while loop, and decrement projectile counter if projectile is removed.
70 mProjectiles.Remove(projectile);
71 character.Health -= projectile.Damage;
78 /// This is called when the game should draw itself.
80 /// <param name="gameTime">Provides a snapshot of timing values.</param>
81 public void Draw(SpriteBatch spriteBatch)
83 mMap.Draw(spriteBatch);
84 foreach(Projectile projectile in mProjectiles)
86 projectile.Draw(spriteBatch);
89 foreach(Character character in mCharacters)
91 character.Draw(spriteBatch);