public Pole() { name = "null"; type = '!'; foo = 0; weight = 0; passable = false; Creature = new List <Agent.Creature>(); Items = new List <Agent.Item>(); mapEntities = new Agent.MapEntity(); transluscent = true; isExplored = false; colour = ConsoleColor.Black; }
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 MakeMapEntitiesList() { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load("MapEntities.xml"); XmlNodeList elemList = xmlDoc.GetElementsByTagName("entity"); Console.WriteLine("Number of entities: {0}", elemList.Count); for (int i = 0; i < elemList.Count; i++) { var entity = new Agent.MapEntity(); Console.WriteLine("Adding MapEntity no. {0}", i); entity.type = elemList[i].Attributes["type"].Value[0]; Console.WriteLine("MapEntity type: {0}", entity.type); entity.name = elemList[i].Attributes["name"].Value; entity.passable = bool.Parse(elemList[i].Attributes["passable"].Value); entity.transluscent = bool.Parse(elemList[i].Attributes["transluscent"].Value); entity.HP = byte.Parse(elemList[i].Attributes["HP"].Value); entity.family = elemList[i].Attributes["family"].Value; if (elemList[i].Attributes["resources"].Value != "none") { string resources; resources = elemList[i].Attributes["resources"].Value; char[] separator1 = new char[] { ',' }; char[] separator2 = { ':' }; string[] splitString; splitString = resources.Split(separator1); string[] splitSplitString; List <String> res = new List <string>(); List <int> amount = new List <int>(); for (int k = 0; k < splitString.GetLength(0); k++) { splitSplitString = splitString[k].Split(separator2); for (int e = 0; e < splitString.GetLength(0); e += 2) { res.Add(splitSplitString[e]); Console.WriteLine(splitSplitString[e]); } for (int o = 1; o <= splitString.GetLength(0); o += 2) { amount.Add(Convert.ToInt16(splitSplitString[o])); Console.WriteLine(splitSplitString[o]); } } } entitiesList.Add(entity); } }
public Pole[,] PopulateWithMapEntities(Pole[,] tab, List <Agent.MapEntity> mapEntitiesList) { Random r = new Random(Guid.NewGuid().GetHashCode()); for (int j = 0; j < tab.GetLength(1); j++) { for (int i = 0; i < tab.GetLength(0); i++) { var entity = new Agent.MapEntity(); entity.name = mapEntitiesList[0].name; entity.currentpossition = new Point(i, j); entity.HP = mapEntitiesList[0].HP; entity.passable = mapEntitiesList[0].passable; entity.transluscent = mapEntitiesList[0].passable; entity.type = mapEntitiesList[0].type; entity.family = mapEntitiesList[0].family; var k = r.Next(1, 100); if (k > 80) { tab[i, j].mapEntities = entity; if (!(mapEntitiesList[0].passable)) { tab[i, j].passable = false; } if (!(mapEntitiesList[0].transluscent)) { tab[i, j].transluscent = false; } } } } return(tab); }