Inheritance: NamedObject, OwnableObject
Exemplo n.º 1
0
		/// <summary>Reads all objects. </summary>
		private void LoadAllObjects(MapFile mf) {

			// import tiles
			foreach (var iso in mf.Tiles)
				_tiles[iso.Dx, iso.Dy / 2] = new MapTile(iso.Dx, iso.Dy, iso.Rx, iso.Ry, iso.Z, iso.TileNum, iso.SubTile, _tiles);

			// import terrain
			foreach (var terr in mf.Terrains) {
				var t = new TerrainObject(terr.Name);
				_terrainObjects.Add(t);
				_tiles.GetTile(terr.Tile).AddObject(t);
			}

			// import smudges
			foreach (var sm in mf.Smudges) {
				var s = new SmudgeObject(sm.Name);
				_tiles.GetTile(sm.Tile).AddObject(s);
				_smudgeObjects.Add(s);
			}

			// import overlays
			foreach (var o in mf.Overlays) {
				var ovl = new OverlayObject(o.OverlayID, o.OverlayValue);
				_tiles.GetTile(o.Tile).AddObject(ovl);
				_overlayObjects.Add(ovl);
			}

			// import infantry
			foreach (var i in mf.Infantries) {
				var inf = new InfantryObject(i.Owner, i.Name, i.Health, i.Direction, i.OnBridge);
				_tiles.GetTile(i.Tile).AddObject(inf);
				_infantryObjects.Add(inf);
			}

			foreach (var u in mf.Units) {
				var un = new UnitObject(u.Owner, u.Name, u.Health, u.Direction, u.OnBridge);
				_tiles.GetTile(u.Tile).AddObject(un);
				_unitObjects.Add(un);
			}

			foreach (var a in mf.Aircrafts) {
				var ac = new AircraftObject(a.Owner, a.Name, a.Health, a.Direction, a.OnBridge);
				_tiles.GetTile(a.Tile).AddObject(ac);
				_aircraftObjects.Add(ac);
			}

			foreach (var s in mf.Structures) {
				var str = new StructureObject(s.Owner, s.Name, s.Health, s.Direction);
				str.Upgrade1 = s.Upgrade1;
				str.Upgrade2 = s.Upgrade2;
				str.Upgrade3 = s.Upgrade3;
				_tiles.GetTile(s.Tile).AddObject(str);
				_structureObjects.Add(str);
			}
		}