예제 #1
0
        public void CreateGrid()
        {
            float x = (screenWidth - country.Width * COLS) / 2;
            float y = (screenHeight - country.Height * ROWS) / 2;
            offset = new Vector2(x, y);
            territories = new Dictionary<string, Country>();

            for (int r = 0; r < ROWS; ++r)
            {
                for (int c = 0; c < COLS; ++c)
                {
                    x = country.Width / 2 + country.Width * c;
                    y = country.Height / 2 + country.Height * r;
                    Vector2 loc = new Vector2(x, y);
                    Country ctry = new Country(loc, country, noone, 4);
                    territories.Add(rcIdx(r, c), ctry);
                }
            }

            for (int r = 0; r < ROWS; ++r)
            {
                for (int c = 0; c < COLS; ++c)
                {
                    Country ctry, nbr;
                    territories.TryGetValue(rcIdx(r, c), out ctry);
                    if (c - 1 >= 0)
                    {
                        territories.TryGetValue(rcIdx(r, c - 1), out nbr);
                        ctry.addNeighbor(nbr);
                    }
                    if (c + 1 < COLS)
                    {
                        territories.TryGetValue(rcIdx(r, c + 1), out nbr);
                        ctry.addNeighbor(nbr);
                    }
                    if (r - 1 >= 0)
                    {
                        territories.TryGetValue(rcIdx(r - 1, c), out nbr);
                        ctry.addNeighbor(nbr);
                    }
                    if (r + 1 < ROWS)
                    {
                        territories.TryGetValue(rcIdx(r + 1, c), out nbr);
                        ctry.addNeighbor(nbr);
                    }
                }
            }
        }
예제 #2
0
        private void CreateWorld()
        {
            offset = new Vector2(0, 0);
            scale = 1.0f;
            territories = new Dictionary<string, Country>();
            doodads = new List<Doodad>();

            // import graphics
            Country c;
            //c = new Country(new Vector2(609.9492f, 358.1009f), new Vector2(0f, 0f), content.Load<Texture2D>("worldmap"), noone, 4);
            //territories.Add("worldmap", c);

            #region LoadDoodads
            doodads.Add(new Doodad(new Vector2(-14.69687f, 191.6566f), content.Load<Texture2D>("doodads/alaskaToKamchatka1"), "alaskaToKamchatka1", Color.White));
            doodads.Add(new Doodad(new Vector2(1266.268f, 191.0086f), content.Load<Texture2D>("doodads/alaskaToKamchatka2"), "alaskaToKamchatka2", Color.White));
            doodads.Add(new Doodad(new Vector2(516.4464f, 394.6735f), content.Load<Texture2D>("doodads/brazilToWestAfrica"), "brazilToWestAfrica", Color.White));
            doodads.Add(new Doodad(new Vector2(687.2501f, 292.322f), content.Load<Texture2D>("doodads/centralEuropeToEgypt"), "centralEuropeToEgypt", Color.White));
            doodads.Add(new Doodad(new Vector2(632.7992f, 273.3663f), content.Load<Texture2D>("doodads/centralEuropeToNorthAfrica"), "centralEuropeToNorthAfrica", Color.White));
            doodads.Add(new Doodad(new Vector2(980.6555f, 389.7321f), content.Load<Texture2D>("doodads/chinaToIndonesia"), "chinaToIndonesia", Color.White));
            doodads.Add(new Doodad(new Vector2(550.7408f, 193.8686f), content.Load<Texture2D>("doodads/greenlandToCentralEurope"), "greenlandToCentralEurope", Color.White));
            doodads.Add(new Doodad(new Vector2(1044.322f, 439.598f), content.Load<Texture2D>("doodads/indonesiaToEasternAustralia"), "indonesiaToEasternAustralia", Color.White));
            doodads.Add(new Doodad(new Vector2(1019.372f, 443.377f), content.Load<Texture2D>("doodads/indonesiaToWesternAustralia"), "indonesiaToWesternAustralia", Color.White));
            doodads.Add(new Doodad(new Vector2(424.5769f, 209.475f), content.Load<Texture2D>("doodads/montrealToGreenland"), "montrealToGreenland", Color.White));
            doodads.Add(new Doodad(new Vector2(635.3635f, 221.1855f), content.Load<Texture2D>("doodads/scandenaviaToCentralEurope"), "scandenaviaToCentralEurope", Color.White));
            doodads.Add(new Doodad(new Vector2(674.8361f, 216.3632f), content.Load<Texture2D>("doodads/scandenaviaToUkraine"), "scandenaviaToUkraine", Color.White));
            doodads.Add(new Doodad(new Vector2(614.2961f, 280.9735f), content.Load<Texture2D>("doodads/spainToNorthAfrica"), "spainToNorthAfrica", Color.White));
            doodads.Add(new Doodad(new Vector2(568.4507f, 516.1575f), content.Load<Texture2D>("doodads/compass"), "compass", Color.Lerp(OCEAN, Color.White, 0.3f)));
            doodads.Add(new Doodad(new Vector2(167.4364f, 497.0134f), content.Load<Texture2D>("doodads/briskBox"), "briskBox", Color.Lerp(OCEAN, Color.White, 0.3f)));
            //Color.Lerp(OCEAN, Color.White, 0.3f)
            //c = new Country(new Vector2(0f, 0f), content.Load<Texture2D>("doodads/briskBox"), noone, 4);
            //territories.Add("briskBox", c);

            #endregion

            #region InitializeCountries
            c = new Country(new Vector2(107.8508f, 200.828f), new Vector2(7.7f, -10.85f), content.Load<Texture2D>("territories/alaska"), noone, 4);
            territories.Add("alaska", c);
            c = new Country(new Vector2(222.2292f, 197.246f), new Vector2(-3.85f, 8.75f), content.Load<Texture2D>("territories/northwest"), noone, 4);
            territories.Add("northwest", c);
            c = new Country(new Vector2(343.4084f, 205.0364f), new Vector2(25.67739f, 27.60754f), content.Load<Texture2D>("territories/montreal"), noone, 4);
            territories.Add("montreal", c);
            c = new Country(new Vector2(457.0038f, 155.9649f), new Vector2(8.75f, -2.1f), content.Load<Texture2D>("territories/greenland"), noone, 4);
            territories.Add("greenland", c);
            c = new Country(new Vector2(237.4706f, 273.7477f), new Vector2(-1.75f, -2.45f), content.Load<Texture2D>("territories/westernUS"), noone, 4);
            territories.Add("westernUS", c);
            c = new Country(new Vector2(316.1926f, 296.1198f), new Vector2(-6.444972f, -11.69498f), content.Load<Texture2D>("territories/easternUS"), noone, 4);
            territories.Add("easternUS", c);
            c = new Country(new Vector2(280.1385f, 342.6657f), new Vector2(-12.95f, -7f), content.Load<Texture2D>("territories/mexico"), noone, 4);
            territories.Add("mexico", c);
            c = new Country(new Vector2(622.2657f, 313.593f), new Vector2(-2.594975f, 0.9050255f), content.Load<Texture2D>("territories/algeria"), noone, 4);
            territories.Add("algeria", c);
            c = new Country(new Vector2(389.8989f, 534.776f), new Vector2(6.897489f, -21.24749f), content.Load<Texture2D>("territories/argentina"), noone, 4);
            territories.Add("argentina", c);
            c = new Country(new Vector2(432.2558f, 456.1035f), new Vector2(9.432415f, -8.382415f), content.Load<Texture2D>("territories/brazil"), noone, 4);
            territories.Add("brazil", c);
            c = new Country(new Vector2(650.299f, 390.926f), new Vector2(8.569845f, -12.41985f), content.Load<Texture2D>("territories/congo"), noone, 4);
            territories.Add("congo", c);
            c = new Country(new Vector2(737.0989f, 384.7761f), new Vector2(-6.589952f, -6.589952f), content.Load<Texture2D>("territories/eastAfrica"), noone, 4);
            territories.Add("eastAfrica", c);
            c = new Country(new Vector2(688.9121f, 321.4395f), new Vector2(0f, 0f), content.Load<Texture2D>("territories/egypt"), noone, 4);
            territories.Add("egypt", c);
            c = new Country(new Vector2(587.9989f, 351.676f), new Vector2(-10.85f, 0.7f), content.Load<Texture2D>("territories/northAfrica"), noone, 4);
            territories.Add("northAfrica", c);
            c = new Country(new Vector2(717.1432f, 467.7557f), new Vector2(-16.1f, -1.75f), content.Load<Texture2D>("territories/southAfrica"), noone, 4);
            territories.Add("southAfrica", c);
            c = new Country(new Vector2(681.8353f, 246.2907f), new Vector2(-0.9801524f, -3.830152f), content.Load<Texture2D>("territories/centralEurope"), noone, 4);
            territories.Add("centralEurope", c);
            c = new Country(new Vector2(382.8569f, 419.208f), new Vector2(-17.58493f, -15.48492f), content.Load<Texture2D>("territories/venezuela"), noone, 4);
            territories.Add("venezuela", c);
            c = new Country(new Vector2(614.4059f, 246.7881f), new Vector2(3.955023f, 6.594975f), content.Load<Texture2D>("territories/westernEurope"), noone, 4);
            territories.Add("westernEurope", c);
            c = new Country(new Vector2(816.2734f, 277.6501f), new Vector2(5.587434f, -9.837434f), content.Load<Texture2D>("territories/afghanistan"), noone, 4);
            territories.Add("afghanistan", c);
            c = new Country(new Vector2(951.755f, 322.0817f), new Vector2(7.399749f, -7.919597f), content.Load<Texture2D>("territories/china"), noone, 4);
            territories.Add("china", c);
            c = new Country(new Vector2(1133.865f, 489.2401f), new Vector2(-41.7774f, 9.577386f), content.Load<Texture2D>("territories/easternAustralia"), noone, 4);
            territories.Add("easternAustralia", c);
            c = new Country(new Vector2(878.7529f, 328.2307f), new Vector2(-1.852512f, 0.9474875f), content.Load<Texture2D>("territories/india"), noone, 4);
            territories.Add("india", c);
            c = new Country(new Vector2(982.8348f, 403.5369f), new Vector2(14.39246f, 5.992463f), content.Load<Texture2D>("territories/indonesia"), noone, 4);
            territories.Add("indonesia", c);
            c = new Country(new Vector2(1135.609f, 193.1856f), new Vector2(-5.6f, -5.95f), content.Load<Texture2D>("territories/kamchatka"), noone, 4);
            territories.Add("kamchatka", c);
            c = new Country(new Vector2(765.4097f, 317.237f), new Vector2(-4.5897f, -8.039698f), content.Load<Texture2D>("territories/middleEast"), noone, 4);
            territories.Add("middleEast", c);
            c = new Country(new Vector2(1028.929f, 224.3549f), new Vector2(-5.684923f, -1.484924f), content.Load<Texture2D>("territories/moreSiberia"), noone, 4);
            territories.Add("moreSiberia", c);
            c = new Country(new Vector2(671.1532f, 194.2956f), new Vector2(-12.95f, 4.9f), content.Load<Texture2D>("territories/scandinavia"), noone, 4);
            territories.Add("scandinavia", c);
            c = new Country(new Vector2(907.4369f, 210.014f), new Vector2(28.39246f, 5.292463f), content.Load<Texture2D>("territories/siberia"), noone, 4);
            territories.Add("siberia", c);
            c = new Country(new Vector2(803.3606f, 208.4472f), new Vector2(-7.127388f, -3.977386f), content.Load<Texture2D>("territories/westRussia"), noone, 4);
            territories.Add("westRussia", c);
            c = new Country(new Vector2(1035.703f, 493.5189f), new Vector2(-6.939949f, 5.189949f), content.Load<Texture2D>("territories/westernAustralia"), noone, 4);
            territories.Add("westernAustralia", c);
            #endregion

            #region CreateContinents
            continents = new List<Continent>();
            Continent cont = new Continent("North America", 2);
            territories.TryGetValue("alaska", out c);
            cont.Add(c);
            territories.TryGetValue("northwest", out c);
            cont.Add(c);
            territories.TryGetValue("montreal", out c);
            cont.Add(c);
            territories.TryGetValue("greenland", out c);
            cont.Add(c);
            territories.TryGetValue("westernUS", out c);
            cont.Add(c);
            territories.TryGetValue("easternUS", out c);
            cont.Add(c);
            territories.TryGetValue("mexico", out c);
            cont.Add(c);
            continents.Add(cont);

            cont = new Continent("South America", 1);
            territories.TryGetValue("venezuela", out c);
            cont.Add(c);
            territories.TryGetValue("argentina", out c);
            cont.Add(c);
            territories.TryGetValue("brazil", out c);
            cont.Add(c);
            continents.Add(cont);

            cont = new Continent("Africa", 2);
            territories.TryGetValue("northAfrica", out c);
            cont.Add(c);
            territories.TryGetValue("congo", out c);
            cont.Add(c);
            territories.TryGetValue("southAfrica", out c);
            cont.Add(c);
            territories.TryGetValue("eastAfrica", out c);
            cont.Add(c);
            territories.TryGetValue("egypt", out c);
            cont.Add(c);
            territories.TryGetValue("algeria", out c);
            cont.Add(c);
            continents.Add(cont);

            cont = new Continent("Europe", 2);
            territories.TryGetValue("westernEurope", out c);
            cont.Add(c);
            territories.TryGetValue("centralEurope", out c);
            cont.Add(c);
            territories.TryGetValue("scandinavia", out c);
            cont.Add(c);
            continents.Add(cont);

            cont = new Continent("Asia", 3);
            territories.TryGetValue("westRussia", out c);
            cont.Add(c);
            territories.TryGetValue("middleEast", out c);
            cont.Add(c);
            territories.TryGetValue("afghanistan", out c);
            cont.Add(c);
            territories.TryGetValue("siberia", out c);
            cont.Add(c);
            territories.TryGetValue("moreSiberia", out c);
            cont.Add(c);
            territories.TryGetValue("kamchatka", out c);
            cont.Add(c);
            territories.TryGetValue("india", out c);
            cont.Add(c);
            territories.TryGetValue("china", out c);
            cont.Add(c);
            continents.Add(cont);

            cont = new Continent("Australia", 1);
            territories.TryGetValue("indonesia", out c);
            cont.Add(c);
            territories.TryGetValue("easternAustralia", out c);
            cont.Add(c);
            territories.TryGetValue("westernAustralia", out c);
            cont.Add(c);
            continents.Add(cont);
            #endregion

            // Adjacency lists
            Country n;

            #region NorthAmericaNeighbors
            territories.TryGetValue("alaska", out c);
            territories.TryGetValue("northwest", out n);
            c.addNeighbor(n);
            territories.TryGetValue("kamchatka", out n);
            c.addNeighbor(n);

            territories.TryGetValue("northwest", out c);
            territories.TryGetValue("alaska", out n);
            c.addNeighbor(n);
            territories.TryGetValue("montreal", out n);
            c.addNeighbor(n);
            territories.TryGetValue("westernUS", out n);
            c.addNeighbor(n);

            territories.TryGetValue("montreal", out c);
            territories.TryGetValue("northwest", out n);
            c.addNeighbor(n);
            territories.TryGetValue("greenland", out n);
            c.addNeighbor(n);
            territories.TryGetValue("westernUS", out n);
            c.addNeighbor(n);
            territories.TryGetValue("easternUS", out n);
            c.addNeighbor(n);

            territories.TryGetValue("greenland", out c);
            territories.TryGetValue("montreal", out n);
            c.addNeighbor(n);
            territories.TryGetValue("westernEurope", out n);
            c.addNeighbor(n);

            territories.TryGetValue("westernUS", out c);
            territories.TryGetValue("northwest", out n);
            c.addNeighbor(n);
            territories.TryGetValue("montreal", out n);
            c.addNeighbor(n);
            territories.TryGetValue("easternUS", out n);
            c.addNeighbor(n);
            territories.TryGetValue("mexico", out n);
            c.addNeighbor(n);

            territories.TryGetValue("easternUS", out c);
            territories.TryGetValue("montreal", out n);
            c.addNeighbor(n);
            territories.TryGetValue("westernUS", out n);
            c.addNeighbor(n);
            territories.TryGetValue("mexico", out n);
            c.addNeighbor(n);

            territories.TryGetValue("mexico", out c);
            territories.TryGetValue("easternUS", out n);
            c.addNeighbor(n);
            territories.TryGetValue("westernUS", out n);
            c.addNeighbor(n);
            territories.TryGetValue("venezuela", out n);
            c.addNeighbor(n);
            #endregion

            #region SouthAmericaNeighbors
            territories.TryGetValue("venezuela", out c);
            territories.TryGetValue("mexico", out n);
            c.addNeighbor(n);
            territories.TryGetValue("brazil", out n);
            c.addNeighbor(n);
            territories.TryGetValue("argentina", out n);
            c.addNeighbor(n);

            territories.TryGetValue("argentina", out c);
            territories.TryGetValue("venezuela", out n);
            c.addNeighbor(n);
            territories.TryGetValue("brazil", out n);
            c.addNeighbor(n);

            territories.TryGetValue("brazil", out c);
            territories.TryGetValue("venezuela", out n);
            c.addNeighbor(n);
            territories.TryGetValue("argentina", out n);
            c.addNeighbor(n);
            territories.TryGetValue("northAfrica", out n);
            c.addNeighbor(n);
            #endregion

            #region AfricaNeighbors
            territories.TryGetValue("northAfrica", out c);
            territories.TryGetValue("brazil", out n);
            c.addNeighbor(n);
            territories.TryGetValue("algeria", out n);
            c.addNeighbor(n);
            territories.TryGetValue("congo", out n);
            c.addNeighbor(n);

            territories.TryGetValue("congo", out c);
            territories.TryGetValue("northAfrica", out n);
            c.addNeighbor(n);
            territories.TryGetValue("algeria", out n);
            c.addNeighbor(n);
            territories.TryGetValue("egypt", out n);
            c.addNeighbor(n);
            territories.TryGetValue("eastAfrica", out n);
            c.addNeighbor(n);
            territories.TryGetValue("southAfrica", out n);
            c.addNeighbor(n);

            territories.TryGetValue("southAfrica", out c);
            territories.TryGetValue("eastAfrica", out n);
            c.addNeighbor(n);
            territories.TryGetValue("congo", out n);
            c.addNeighbor(n);

            territories.TryGetValue("eastAfrica", out c);
            territories.TryGetValue("southAfrica", out n);
            c.addNeighbor(n);
            territories.TryGetValue("congo", out n);
            c.addNeighbor(n);
            territories.TryGetValue("egypt", out n);
            c.addNeighbor(n);
            territories.TryGetValue("middleEast", out n);
            c.addNeighbor(n);

            territories.TryGetValue("egypt", out c);
            territories.TryGetValue("algeria", out n);
            c.addNeighbor(n);
            territories.TryGetValue("congo", out n);
            c.addNeighbor(n);
            territories.TryGetValue("eastAfrica", out n);
            c.addNeighbor(n);
            territories.TryGetValue("middleEast", out n);
            c.addNeighbor(n);
            territories.TryGetValue("centralEurope", out n);
            c.addNeighbor(n);

            territories.TryGetValue("algeria", out c);
            territories.TryGetValue("egypt", out n);
            c.addNeighbor(n);
            territories.TryGetValue("congo", out n);
            c.addNeighbor(n);
            territories.TryGetValue("northAfrica", out n);
            c.addNeighbor(n);
            territories.TryGetValue("westernEurope", out n);
            c.addNeighbor(n);
            territories.TryGetValue("centralEurope", out n);
            c.addNeighbor(n);
            #endregion

            #region EuropeNeighbors
            territories.TryGetValue("westernEurope", out c);
            territories.TryGetValue("algeria", out n);
            c.addNeighbor(n);
            territories.TryGetValue("centralEurope", out n);
            c.addNeighbor(n);
            territories.TryGetValue("scandinavia", out n);
            c.addNeighbor(n);

            territories.TryGetValue("centralEurope", out c);
            territories.TryGetValue("algeria", out n);
            c.addNeighbor(n);
            territories.TryGetValue("egypt", out n);
            c.addNeighbor(n);
            territories.TryGetValue("westernEurope", out n);
            c.addNeighbor(n);
            territories.TryGetValue("middleEast", out n);
            c.addNeighbor(n);
            territories.TryGetValue("scandinavia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("westRussia", out n);
            c.addNeighbor(n);

            territories.TryGetValue("scandinavia", out c);
            territories.TryGetValue("centralEurope", out n);
            c.addNeighbor(n);
            territories.TryGetValue("westernEurope", out n);
            c.addNeighbor(n);
            territories.TryGetValue("westRussia", out n);
            c.addNeighbor(n);
            #endregion

            #region AsiaNeighbors
            territories.TryGetValue("westRussia", out c);
            territories.TryGetValue("scandinavia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("centralEurope", out n);
            c.addNeighbor(n);
            territories.TryGetValue("afghanistan", out n);
            c.addNeighbor(n);
            territories.TryGetValue("siberia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("middleEast", out n);
            c.addNeighbor(n);

            territories.TryGetValue("middleEast", out c);
            territories.TryGetValue("centralEurope", out n);
            c.addNeighbor(n);
            territories.TryGetValue("egypt", out n);
            c.addNeighbor(n);
            territories.TryGetValue("eastAfrica", out n);
            c.addNeighbor(n);
            territories.TryGetValue("afghanistan", out n);
            c.addNeighbor(n);
            territories.TryGetValue("westRussia", out n);
            c.addNeighbor(n);

            territories.TryGetValue("afghanistan", out c);
            territories.TryGetValue("westRussia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("middleEast", out n);
            c.addNeighbor(n);
            territories.TryGetValue("siberia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("india", out n);
            c.addNeighbor(n);

            territories.TryGetValue("siberia", out c);
            territories.TryGetValue("westRussia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("afghanistan", out n);
            c.addNeighbor(n);
            territories.TryGetValue("india", out n);
            c.addNeighbor(n);
            territories.TryGetValue("china", out n);
            c.addNeighbor(n);
            territories.TryGetValue("moreSiberia", out n);
            c.addNeighbor(n);

            territories.TryGetValue("moreSiberia", out c);
            territories.TryGetValue("siberia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("china", out n);
            c.addNeighbor(n);
            territories.TryGetValue("kamchatka", out n);
            c.addNeighbor(n);

            territories.TryGetValue("kamchatka", out c);
            territories.TryGetValue("moreSiberia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("alaska", out n);
            c.addNeighbor(n);

            territories.TryGetValue("india", out c);
            territories.TryGetValue("afghanistan", out n);
            c.addNeighbor(n);
            territories.TryGetValue("siberia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("china", out n);
            c.addNeighbor(n);

            territories.TryGetValue("china", out c);
            territories.TryGetValue("india", out n);
            c.addNeighbor(n);
            territories.TryGetValue("siberia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("moreSiberia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("indonesia", out n);
            c.addNeighbor(n);
            #endregion

            #region AustraliaNeighbors
            territories.TryGetValue("indonesia", out c);
            territories.TryGetValue("china", out n);
            c.addNeighbor(n);
            territories.TryGetValue("easternAustralia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("westernAustralia", out n);
            c.addNeighbor(n);

            territories.TryGetValue("easternAustralia", out c);
            territories.TryGetValue("indonesia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("westernAustralia", out n);
            c.addNeighbor(n);

            territories.TryGetValue("westernAustralia", out c);
            territories.TryGetValue("indonesia", out n);
            c.addNeighbor(n);
            territories.TryGetValue("easternAustralia", out n);
            c.addNeighbor(n);
            #endregion
        }