Esempio n. 1
0
        /// <summary>
        /// Returns a copy of this map and all of its contents, with new instances of each object (Map, SuperRegions, Regions).
        /// </summary>
        /// <returns></returns>
        public Map GetMapCopy()
        {
            Map newMap = new Map();

            foreach (SuperRegion sr in SuperRegions)
            {
                SuperRegion newSuperRegion = new SuperRegion(sr.ID, sr.ArmiesReward);
                newMap.AddSuperRegion(newSuperRegion);
            }

            foreach (Region r in Regions)
            {
                Region newRegion = new Region(r.ID, newMap.GetSuperRegionByID(r.SuperRegion.ID), r.PlayerName, r.Armies);
                newMap.AddRegion(newRegion);
            }

            foreach (Region r in Regions) 
            {
                Region newRegion = newMap.GetRegionByID(r.ID);
                foreach (Region neighbor in r.Neighbors)
                {
                    newRegion.AddNeighbor(newMap.GetRegionByID(neighbor.ID));
                }
            }

            return newMap;
        }
Esempio n. 2
0
 public void AddNeighbor(Region neighbor)
 {
     if (!Neighbors.Contains(neighbor))
     {
         Neighbors.Add(neighbor);
         neighbor.AddNeighbor(this);
     }
 }