using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; namespace CarFire { public class Display { List mProjectiles = new List(); List mCharacters = new List(); Map mMap; public Display() { /* mMap = aMap; mCharacters = characters; */ } /// /// LoadContent will be called once per game and is the place to load /// all of your content. /// public void LoadContent(ContentManager contentManager) { Texture2D everything = contentManager.Load("cs"); mMap = contentManager.Load("Maps/stable"); Map.DefaultTile = contentManager.Load("default"); mMap.CenterCell = new Vector2(5,5); //List entities = mMap.GetAllEntities(); mProjectiles.Add(new Projectile(mMap, everything, new Vector2(5,5), 10, 10, 300, 300)); // TODO: use this.Content to load your game content here } /// /// UnloadContent will be called once per game and is the place to unload /// all content. /// public void UnloadContent() { // TODO: Unload any non ContentManager content here } /// /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// /// Provides a snapshot of timing values. public void Update(TimeSpan timespan) { foreach (Projectile projectile in mProjectiles) { projectile.Update(timespan); } //Check for collisons foreach (Character character in mCharacters) { foreach (Projectile projectile in mProjectiles) { if (projectile.GridX == character.GridX && projectile.GridY == character.GridY) { //Debug - not sure if you can remove while doing for each //Alternative - while loop, and decrement projectile counter if projectile is removed. mProjectiles.Remove(projectile); character.Health -= projectile.Damage; } } } } /// /// This is called when the game should draw itself. /// /// Provides a snapshot of timing values. public void Draw(SpriteBatch spriteBatch) { mMap.Draw(spriteBatch); foreach(Projectile projectile in mProjectiles) { projectile.Draw(spriteBatch); } foreach(Character character in mCharacters) { character.Draw(spriteBatch); } } } }