Esempio n. 1
0
        public static IBitmap City(City city, bool smallFont = false)
        {
            IBitmap      output   = new Picture(16, 16);
            TextSettings settings = new TextSettings()
            {
                FontId    = smallFont ? 1 : 0,
                Alignment = TextAlign.Center
            };

            if (city.Tile.Units.Length > 0)
            {
                output.FillRectangle(0, 0, 16, 16, 5);
            }
            output.FillRectangle(1, 1, 14, 14, 15)
            .FillRectangle(2, 1, 13, 13, Common.ColourDark[city.Owner])
            .FillRectangle(2, 2, 12, 12, Common.ColourLight[city.Owner]);

            IBitmap resource;

            if (Resources.Exists("SP257"))
            {
                resource = Resources["SP257"][192, 112, 16, 16];
            }
            else
            {
                resource = new Picture(Free.Instance.City, Common.GetPalette256);
            }
            resource
            .ColourReplace(3, 0)
            .ColourReplace(5, Common.ColourDark[city.Owner]);

            if (city.IsInDisorder)
            {
                output.AddLayer(resource, 0, 0)
                .AddLayer(Icons.Citizen(Enums.Citizen.UnhappyMale), 5, 1);
            }
            else
            {
                output.AddLayer(resource, 0, 0)
                .DrawText($"{city.Size}", (smallFont ? 1 : 0), 5, 9, 5, TextAlign.Center);
            }

            resource?.Dispose();

            if (city.HasBuilding <CityWalls>())
            {
                output.AddLayer(Generic.Fortify, 0, 0);
            }

            return(output);
        }
Esempio n. 2
0
        public Picture GetText(string text, int font, byte colourFirstLetter, byte colour)
        {
            if (text == null)
            {
                text = "[MISSING STRING]";
            }

            List <Bytemap> letters       = new List <Bytemap>();
            bool           isFirstLetter = true;

            foreach (char c in text)
            {
                letters.Add(GetLetter(isFirstLetter ? colourFirstLetter : colour, font, c));
                isFirstLetter = false;
            }

            int width = 0, height = 0;

            foreach (Bytemap letter in letters)
            {
                width += letter.Width + 1;
                if (height < letter.Height)
                {
                    height = letter.Height;
                }
            }

            Picture output = new Picture(width, height);

            int xx = 0;

            foreach (Bytemap letter in letters)
            {
                output.AddLayer(letter, xx, 0);
                xx += letter.Width + 1;
            }

            return(output);
        }
Esempio n. 3
0
        public Picture GetPalace(PalaceStyle style, PalacePart part, int level)
        {
            if (level == 0)
            {
                style = PalaceStyle.None;
            }

            int combine = (level * 100) + ((int)style * 10) + (int)part;

            if (!_palacePart.ContainsKey(combine))
            {
                Picture picture = null;

                int offsetX = 0, offsetY = 0;
                if (style == PalaceStyle.Classical)
                {
                    offsetX = 160;
                }
                if (style == PalaceStyle.Islamic)
                {
                    offsetY = 100;
                }

                switch (part)
                {
                case PalacePart.LeftTower:
                    picture = new Picture(35, 101);
                    if (style == PalaceStyle.Classical)
                    {
                        picture.AddLayer(Instance[$"CASTLE{level}"][160, 1 + offsetY, 35, 99], 0, 2);
                        break;
                    }
                    picture.AddLayer(Instance[$"CASTLE{level}"][104 + offsetX, 1 + offsetY, 27, 99], 8, 2);
                    break;

                case PalacePart.RightTower:
                    picture = new Picture(35, 101);
                    if (style == PalaceStyle.Classical)
                    {
                        picture.AddLayer(Instance[$"CASTLE{level}"][196, 1 + offsetY, 35, 99], 0, 2);
                        break;
                    }
                    picture.AddLayer(Instance[$"CASTLE{level}"][132 + offsetX, 1 + offsetY, 27, 99], 0, 2);
                    break;

                case PalacePart.Wall:
                case PalacePart.WallShadow:
                {
                    picture = new Picture(48, 101);
                    if (level == 0)
                    {
                        picture.AddLayer(Instance["CASTLE0"][53 + offsetX, 1 + offsetY, 24, 99]);
                        break;
                    }
                    for (int i = 0; i < 2; i++)
                    {
                        bool shadow = (part == PalacePart.WallShadow && i == 0);
                        picture.AddLayer(Instance[$"CASTLE{level}"][(shadow ? 53 : 78) + offsetX, 1 + offsetY, 24, 99], (24 * i));
                    }
                    break;
                }

                case PalacePart.LeftTowerWall:
                {
                    picture = new Picture(57, 101);
                    if (level == 0)
                    {
                        picture.AddLayer(Instance["CASTLE0"][78 + offsetX, 1 + offsetY, 24, 99], 33);
                        break;
                    }
                    picture.AddLayer(Instance[$"CASTLE{level}"][53 + offsetX, 1 + offsetY, 24, 99], 33);
                    if (style == PalaceStyle.Classical)
                    {
                        picture.AddLayer(Instance[$"CASTLE{level}"][160, 1 + offsetY, 35, 99], 0, 2);
                        break;
                    }
                    picture.AddLayer(Instance[$"CASTLE{level}"][104 + offsetX, 1 + offsetY, 27, 99], 8, 2);
                    break;
                }

                case PalacePart.RightTowerWall:
                case PalacePart.RightTowerWallShadow:
                {
                    picture = new Picture(57, 101);
                    if (level == 0)
                    {
                        picture.AddLayer(Instance["CASTLE0"][53 + offsetX, 1 + offsetY, 24, 99]);
                        break;
                    }

                    bool shadow = (part == PalacePart.RightTowerWallShadow);
                    picture.AddLayer(Instance[$"CASTLE{level}"][(shadow ? 53 : 78) + offsetX, 1 + offsetY, 24, 99], 0);
                    if (style == PalaceStyle.Classical)
                    {
                        picture.AddLayer(Instance[$"CASTLE{level}"][196, 1 + offsetY, 35, 99], 21, 2);
                        break;
                    }
                    picture.AddLayer(Instance[$"CASTLE{level}"][132 + offsetX, 1 + offsetY, 27, 99], 21, 2);
                    break;
                }

                case PalacePart.Center:
                {
                    picture = Instance[$"CASTLE{level}"][0 + offsetX, 1 + offsetY, 52, 99];
                    break;
                }
                }

                _palacePart[combine] = picture;
            }
            return(_palacePart[combine]);
        }