Exemple #1
0
 public Game()
 {
     if (readMapFormFile)
     {
         Texture2D mapImage = Resources.Load("provinces", typeof(Texture2D)) as Texture2D; ///texture;
         map = new MyTexture(mapImage);
     }
     else
     {
         generateMapImage();
     }
     mapBorders = new Rect(0f, 0f, map.getWidth() * Options.cellMultiplier, map.getHeight() * Options.cellMultiplier);
 }
Exemple #2
0
        public Game(Texture2D mapImage)
        {
            DrawFogOfWar = true;
            if (mapImage == null)
            {
                generateMapImage();
            }
            else
            {
                //Texture2D mapImage = Resources.Load("provinces", typeof(Texture2D)) as Texture2D; ///texture;
                mapTexture = new MyTexture(mapImage);
            }

            mapBorders = new Rect(0f, 0f, mapTexture.getWidth() * Options.cellMultiplier, mapTexture.getHeight() * Options.cellMultiplier);
        }
Exemple #3
0
        public static void preReadProvinces(MyTexture image)
        {
            ProvinceNameGenerator nameGenerator = new ProvinceNameGenerator();
            Color currentProvinceColor          = image.GetPixel(0, 0);
            int   provinceCounter = 0;

            for (int j = 0; j < image.getHeight(); j++) // circle by province
            {
                for (int i = 0; i < image.getWidth(); i++)
                {
                    if (currentProvinceColor != image.GetPixel(i, j)
                        //&& !blockedProvinces.Contains(currentProvinceColor)
                        && !isProvinceCreated(currentProvinceColor))
                    {
                        allProvinces.Add(new Province(nameGenerator.generateProvinceName(), provinceCounter, currentProvinceColor, Product.getRandomResource(false)));
                        provinceCounter++;
                    }
                    currentProvinceColor = image.GetPixel(i, j);
                    //game.updateStatus("Reading provinces.. x = " + i + " y = " + j);
                }
            }
        }
Exemple #4
0
        public static List <Province> getSeaProvinces(MyTexture mapTexture, bool useProvinceColors)
        {
            List <Province> res = new List <Province>();

            if (!useProvinceColors)
            {
                Province seaProvince;
                for (int x = 0; x < mapTexture.getWidth(); x++)
                {
                    seaProvince = FindProvince(mapTexture.GetPixel(x, 0));
                    if (!res.Contains(seaProvince))
                    {
                        res.Add(seaProvince);
                    }
                    seaProvince = FindProvince(mapTexture.GetPixel(x, mapTexture.getHeight() - 1));
                    if (!res.Contains(seaProvince))
                    {
                        res.Add(seaProvince);
                    }
                }
                for (int y = 0; y < mapTexture.getHeight(); y++)
                {
                    seaProvince = FindProvince(mapTexture.GetPixel(0, y));
                    if (!res.Contains(seaProvince))
                    {
                        res.Add(seaProvince);
                    }
                    seaProvince = FindProvince(mapTexture.GetPixel(mapTexture.getWidth() - 1, y));
                    if (!res.Contains(seaProvince))
                    {
                        res.Add(seaProvince);
                    }
                }

                seaProvince = FindProvince(mapTexture.getRandomPixel());
                if (!res.Contains(seaProvince))
                {
                    res.Add(seaProvince);
                }

                if (Rand.Get.Next(3) == 1)
                {
                    seaProvince = FindProvince(mapTexture.getRandomPixel());
                    if (!res.Contains(seaProvince))
                    {
                        res.Add(seaProvince);
                    }
                    if (Rand.Get.Next(20) == 1)
                    {
                        seaProvince = FindProvince(mapTexture.getRandomPixel());
                        if (!res.Contains(seaProvince))
                        {
                            res.Add(seaProvince);
                        }
                    }
                }
            }
            else
            { // Victoria 2 format
                foreach (var item in GetAllProvinces())
                {
                    var color = item.getColorID();
                    if (color.g + color.b >= 200f / 255f + 200f / 255f && color.r < 96f / 255f)
                    {
                        //if (color.g + color.b + color.r > 492f / 255f)
                        res.Add(item);
                    }
                }
            }
            return(res);
        }