public Map(String title, String objective, Texture2D background, SoundEffect BGM, float scrollSpeed, Dictionary<string, EnemyPlaneObj> enemyPlaneObjs, Dictionary<string, Obj> objs, HeroPlaneObj hero, List<Event> events) { this.title = title; this.objective = objective; this.background = background; this.BGM = BGM; this.scrollSpeed = scrollSpeed; this.enemyPlaneObjs = enemyPlaneObjs; this.objs = objs; this.hero = hero; this.events = events; }
// Not used private void convertHeroPlaneObj(XmlTag element) { string key = ""; PlaneObj baseObj = null; int x, y; x = y = 0; foreach (KeyValuePair<string, string> attrib in element.Attributes) { if (attrib.Key == "id") key = attrib.Value; else if (attrib.Key == "planeobj") baseObj = planeObjs[attrib.Value]; else if (attrib.Key == "x") x = Int32.Parse(attrib.Value); else if (attrib.Key == "y") y = Int32.Parse(attrib.Value); } hero = new HeroPlaneObj(baseObj.sprite, x, y, (int)baseObj.velocity.X, (int)baseObj.velocity.Y, baseObj.srcRect.Width, baseObj.srcRect.Height, baseObj.MoveRate, baseObj.hp); }
private void convertHeroPlaneObject(XmlTag element) { Texture2D img = null; int x, y, vx, vy, moverate, hp, width, height; x = y = vx = vy = moverate = hp = width = height = 0; foreach (KeyValuePair<string, string> attrib in element.Attributes) { if (attrib.Key == "src") img = (Texture2D)Texture.FromFile(_GLOBAL.Graphics.GraphicsDevice, attrib.Value); // dynamic loading else if (attrib.Key == "x") x = Int32.Parse(attrib.Value); else if (attrib.Key == "y") y = Int32.Parse(attrib.Value); else if (attrib.Key == "vx") vx = Int32.Parse(attrib.Value); else if (attrib.Key == "vy") vy = Int32.Parse(attrib.Value); else if (attrib.Key == "width") width = (attrib.Value == "default") ? img.Width : Int32.Parse(attrib.Value); // default value else if (attrib.Key == "height") height = (attrib.Value == "default") ? img.Height : Int32.Parse(attrib.Value); // default value else if (attrib.Key == "moverate") moverate = Int32.Parse(attrib.Value); else if (attrib.Key == "hp") hp = Int32.Parse(attrib.Value); } hero = new HeroPlaneObj(img, x, y, vx, vy, width, height, moverate, hp); }
public void reset() { stack = new Stack<XmlTag>(); hero = null; BGM = null; background = null; objs = new Dictionary<string, Obj>(); objects = new Dictionary<string, Obj>(); moveableSpriteObjs = new Dictionary<string, MoveableSpriteObj>(); planeObjs = new Dictionary<string, PlaneObj>(); bulletObjs = new Dictionary<string, BulletObj>(); enemyPlaneObjs = new Dictionary<string, EnemyPlaneObj>(); events = new List<Event>(); paths = new Dictionary<string,Path>(); title = null; objective = null; scrollSpeed = 0.0f; }