public Pole(OperacjeMapy.Pole pole) { name = pole.name; type = pole.type; foo = pole.foo; weight = pole.weight; passable = pole.passable; Creature = new List <Agent.Creature>(); Items = new List <Agent.Item>(); mapEntities = new Agent.MapEntity(); transluscent = pole.transluscent; isExplored = false; colour = pole.colour; }
public void MakeFieldsForMap() { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load("MapFields.xml"); XmlNodeList elemList = xmlDoc.GetElementsByTagName("field"); Console.WriteLine("Number of fields: {0}", elemList.Count); for (int i = 0; i < elemList.Count; i++) { var mapField = new OperacjeMapy.Pole(); Console.WriteLine("Adding field no. {0}", i); mapField.type = elemList[i].Attributes["type"].Value[0]; Console.WriteLine("Field type: {0}", mapField.type); mapField.name = elemList[i].Attributes["name"].Value; mapField.weight = byte.Parse(elemList[i].Attributes["weight"].Value); mapField.foo = byte.Parse(elemList[i].Attributes["foo"].Value); Console.WriteLine("Field foo: {0}", mapField.foo); mapField.passable = bool.Parse(elemList[i].Attributes["passable"].Value); mapField.transluscent = bool.Parse(elemList[i].Attributes["transluscent"].Value); ConsoleColor[] colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); String colour = elemList[i].Attributes["colour"].Value; foreach (var color in colors) { if (colour.Equals(Convert.ToString(color), StringComparison.OrdinalIgnoreCase)) { mapField.colour = color; } } mapField.Creature = new List <Agent.Creature>(); mapField.isExplored = false; mapField.Items = new List <Agent.Item>(); mapFieldsList.Add(mapField); } }