Example #1
1
 public Pathfinding(Map ma, Point m, Point t, int r)
 {
     map = ma;
     me = m;
     target = t;
     range = r;
 }
Example #2
0
 public PlayerBase(Map _map)
 {
     map = _map;
     BuildCapabilitiesBuildings = new Dictionary<string, bool>();
     BuildCapabilitiesUnits = new Dictionary<string, bool>();
     CountBuildings = new Dictionary<string, int>();
     CountUnits = new Dictionary<string, int>();
     UIBLC xml = new UIBLC();
     xml = XMLWork.XMLDeserialization();
     Buildings = new List<AbstractBuilding>();
     Units = new List<IUnit>();
     Resources = XMLWork.XMLStarting().resources;
     foreach (string item in xml.BuildingTypes)
     {
         BuildCapabilitiesBuildings.Add(item, false);
         CountBuildings.Add(item, 0);
     }
     foreach (string item in xml.UnitTypes)
     {
         BuildCapabilitiesUnits.Add(item, false);
         CountUnits.Add(item, 0);
     }
     BuildCapabilitiesBuildings["Farm"] = true;
     factory = new BuildingFactory();
     unitFactory = new UnitFactory();
     newOptions = new AddNewOptions();
 }
Example #3
0
        public Map Run(int w, int h)
        {
            Map map = new Map();
            map.Generate(w, h);
            var pf = new PathFinder();
            var fp = pf.FindPath(map, new Point(1, 1), new Point(w - 2, h - 2));
            while (fp.Count == 0)
            {
                map.Generate(w, h);
                pf = new PathFinder();
                fp = pf.FindPath(map, new Point(1, 1), new Point(w - 2, h - 2));
            }

            //CSVDoc D = new CSVDoc();
            //for (int i = 0; i < map.Data.Count; i++)
            //    for (int j = 0; j < map.Data[i].Count; j++)
            //        D.AddValueAt(i, j, map.Data[i][j].Height.ToString());
            //fp.ForEach(P => D.AddValueAt(P.y, P.x, "P"));
            //D.Save("Map.csv");
            return map;
        }
Example #4
0
 public void Move(int i, Map map)
 {
     int[] a = new int[8] { 1, 1, 1, 0, 0, -1, -1, -1 };
     int[] b = new int[8] { -1, 0, 1, -1, 1, -1, 0, 1 };
     map.Data[position.y][position.x].Use = "";
     position.x += a[i];
     position.y += b[i];
     map.Data[position.y][position.x].Use = "Peasant";
 }
Example #5
0
 public Attack(IUnit _unit, Map m, IUnit t)
 {
     Unit = _unit;
     Map = m;
     Target = t;
 }
Example #6
0
 //[XmlInclude(typeof(BuildFarmCapability)), XmlInclude(typeof(BuildBarrackCapability)), XmlInclude(typeof(BuildBowWorkshopCapability)), XmlInclude(typeof(BuildTowerCapability)), XmlInclude(typeof(BuildPeasantCapability)), XmlInclude(typeof(BuildArcherCapability))]
 public static void SerialMap(Map _map)
 {
     XmlSerializer serializer = new XmlSerializer(typeof(Map));
     // WARNING !!! You might need to change this link in order to make this project work
     using (TextWriter writer = new StreamWriter(@"C:/Users/Andrei/Source/Repos/uWarcraft/Uwarcraft/Serialization/samplemap.xml"))
     {
         serializer.Serialize(writer, _map);
     }
 }