Esempio n. 1
0
        private void Init()
        {
            string baseDir = "./Messages/Stars";

            //get the star ansi image;
            string filename = Path.Combine(baseDir, string.Format("{0}.MII", this.StarSystem.SpectralClass));
            var    starFile = Messages.Message.ReadMII2File(filename);

            TextCanvas canvas = new TextCanvas(screenWidth, 25, TextCanvas.NumOfColorsEnum.XTERM256);

            starFile.Write(0, 0, canvas);

            canvas.FillRectangle(41, 4, 79 - 41, 10, 0);
            canvas.DrawString(41, 4, string.Format("{0} System", StarSystem.Name), (byte)ANSI.ANSIColor_16.Cyan, 0);
            canvas.DrawString(41, 5, string.Format("Stable system with {0} major bodies", StarSystem.NumberOfBodies + 1), (byte)ANSI.ANSIColor_16.Cyan, 0);
            canvas.DrawString(41, 7, string.Format("Main Star: {0}", StarSystem.Name), (byte)ANSI.ANSIColor_16.Cyan, 0);
            canvas.DrawString(41, 8, string.Format("{1} : {2}", StarSystem.Name, StarSystem.StarType, StarSystem.Desc), (byte)ANSI.ANSIColor_16.Cyan, 0);
            canvas.DrawString(41, 9, string.Format("Spectral Class: {0}", StarSystem.SpectralClass), (byte)ANSI.ANSIColor_16.Cyan, 0);
            canvas.DrawString(41, 10, string.Format("Luminosity: {0}", StarSystem.LuminosityClass), (byte)ANSI.ANSIColor_16.Cyan, 0);
            canvas.DrawString(41, 11, string.Format("Magnitude: {0}", StarSystem.Magnitude), (byte)ANSI.ANSIColor_16.Cyan, 0);
            canvas.DrawString(41, 12, string.Format("Size: ~{0:0.00}", StarSystem.Size), (byte)ANSI.ANSIColor_16.Cyan, 0);
            canvas.DrawString(41, 13, string.Format("Mass: ~{0:0.00}", StarSystem.Mass), (byte)ANSI.ANSIColor_16.Cyan, 0);
            canvas.DrawString(41, 14, string.Format("Habitable Zone ~{0:0.00}Au", StarSystem.HZone), (byte)ANSI.ANSIColor_16.Cyan, 0);

            //int boxX = 40, boxY = 0;

            //canvas.FillRectangle(boxX, boxY, 79 - boxX, 30 - boxY, 0);
            //canvas.DrawRectangle(boxX, boxY, 79 - boxX, 30 - boxY, 250);

            this.Canvas = canvas;
        }
Esempio n. 2
0
        public string GetInfo()
        {
            string        baseDir  = "./Messages/Citys/";
            string        spfile   = "p1.png.MII";
            TextCanvas    canvas   = new TextCanvas(screenWidth, 18, TextCanvas.NumOfColorsEnum.XTERM256);
            StringBuilder sBuilder = new StringBuilder();

            canvas.FillRectangle(0, 0, 44, 18, 234);

            string tileFilename = Path.Combine(baseDir, spfile);
            var    img          = Messages.Message.ReadMII2File(tileFilename);

            img.Write(2, 2, canvas);

            canvas.DrawString(45, 1, string.Format("Port: {0}", SpacePort.Name), (byte)ANSI.ANSIColor_16.Cyan, 0);
            canvas.DrawString(45, 2, string.Format("Planet: {0}", SpacePort.Body.PlanetName), (byte)ANSI.ANSIColor_16.Cyan, 0);
            canvas.DrawString(45, 3, string.Format("Planet Sector: {0}", SpacePort.PlanetSector), (byte)ANSI.ANSIColor_16.Cyan, 0);

            sBuilder.AppendLine(canvas.ToString());
            return(sBuilder.ToString());
        }
Esempio n. 3
0
        public TextCanvas Test()
        {
            byte wallColor = 239;
            byte topColor  = 241;

            List <char[]> def = new List <char[]>();

            StringReader sr = new StringReader(spec);
            string       line;

            while ((line = sr.ReadLine()) != null)
            {
                def.Add(line.ToCharArray());
            }

            Random rand    = new Random();
            string baseDir = "./Messages/Citys";


            string tileFilename = Path.Combine(baseDir, "tile3.png.MII");
            var    tile         = Messages.Message.ReadMII2File(tileFilename);

            //tile.WriteTile(mainCanvas);

            mainCanvas.FillRectangle(0, 0, mainCanvas.Width, mainCanvas.Height, 234);

            //equalise
            int maxLength = 0;

            for (int y = 0; y < def.Count; y++)
            {
                if (def[y].Length > maxLength)
                {
                    maxLength = def[y].Length;
                }
            }

            for (int y = 0; y < def.Count; y++)
            {
                if (def[y].Length < maxLength)
                {
                    char[] n = new char[maxLength];
                    for (int x = 0; x < maxLength; x++)
                    {
                        n[x] = ' ';
                    }

                    Array.Copy(def[y], n, def[y].Length);
                    def[y] = n;
                }
            }

            for (int y = 0; y < def.Count; y++)
            {
                for (int x = 0; x < def[y].Length; x++)
                {
                    char c = def[y][x];
                    if (c == 'B')
                    {
                        string filename = Path.Combine(baseDir, buildings[rand.Next(0, buildings.Length - 1)]);
                        var    buildind = Messages.Message.ReadMII2File(filename);
                        buildind.Write(x * 21, y * 8, mainCanvas);
                    }
                    else if (c == 'P')
                    {
                        //Give space for the port [2x2]
                        if (x + 1 < def[y].Length)
                        {
                            def[y][x + 1] = '+';
                        }
                        if (y + 1 < def.Count)
                        {
                            if (x < def[y + 1].Length)
                            {
                                def[y + 1][x] = '_';
                            }
                            if (x + 1 < def[y + 1].Length)
                            {
                                def[y + 1][x + 1] = '_';
                            }
                        }
                        string filename = Path.Combine(baseDir, sPorts[0]);
                        var    buildind = Messages.Message.ReadMII2File(filename);
                        buildind.Write(x * 21, y * 8, mainCanvas);
                    }
                    else if (c == 'F')
                    {
                        //Give space for the factory [2x2]
                        if (x + 1 < def[y].Length)
                        {
                            def[y][x + 1] = '+';
                        }
                        if (y + 1 < def.Count)
                        {
                            if (x < def[y + 1].Length)
                            {
                                def[y + 1][x] = '_';
                            }
                            if (x + 1 < def[y + 1].Length)
                            {
                                def[y + 1][x + 1] = '_';
                            }
                        }

                        string filename = Path.Combine(baseDir, factoriesB[rand.Next(0, factoriesB.Length - 1)]);
                        var    buildind = Messages.Message.ReadMII2File(filename);
                        buildind.Write(x * 21, y * 8, mainCanvas);
                    }
                    else if (c == 'f')
                    {
                        //Give space for the factory [1x2]
                        if (x + 1 < def[y].Length)
                        {
                            def[y][x + 1] = '+';
                        }
                        string filename = Path.Combine(baseDir, factoriesA[rand.Next(0, factoriesB.Length - 1)]);
                        var    buildind = Messages.Message.ReadMII2File(filename);
                        buildind.Write(x * 21, y * 8, mainCanvas);
                    }
                }
            }

            for (int y = 0; y < def.Count; y++)
            {
                for (int x = 0; x < def[y].Length; x++)
                {
                    char c = def[y][x];
                    if (c != ' ' && c != 'F' && c != 'P' && c != 'f' && c != '_')
                    {
                        bool makeTunnelRight = x + 1 < def[y].Length;
                        bool makeTunnelDown  = y + 1 < def.Count;
                        bool makeTunnelUp    = y > 0;

                        if (makeTunnelRight)
                        {
                            makeTunnelRight = (
                                def[y][x + 1] != ' ' && def[y][x + 1] != '_' &&
                                def[y][x + 1] != '|'
                                );
                        }

                        if (makeTunnelDown)
                        {
                            makeTunnelDown = (
                                def[y + 1][x] != ' ' && def[y + 1][x] != '_'
                                );
                        }

                        if (makeTunnelUp)
                        {
                            makeTunnelUp = (
                                def[y - 1][x] != ' ' && def[y - 1][x] != '_' && c != '|'
                                );
                        }

                        if (makeTunnelRight)
                        {
                            if (c != '|')
                            {
                                if (makeTunnelDown)
                                {
                                    mainCanvas.DrawString(x * 21 + 21 - 3, y * 8 + 4, "▀▀█▀", topColor, wallColor);
                                }
                                else
                                {
                                    mainCanvas.DrawString(x * 21 + 21 - 3, y * 8 + 4, "▀▀▀▀", topColor, wallColor);
                                }
                            }
                            else
                            {
                                if (makeTunnelDown)
                                {
                                    mainCanvas.DrawString(x * 21 + 21 - 1, y * 8 + 4, "█▀", topColor, wallColor);
                                }
                                else
                                {
                                    mainCanvas.DrawString(x * 21 + 21 - 1, y * 8 + 4, "▀▀", topColor, wallColor);
                                }
                            }
                        }
                        else if (makeTunnelUp)
                        {
                            mainCanvas.DrawString(x * 21 + 21 - 3, y * 8 + 4, "▀▀▀", topColor, wallColor);
                            //mainCanvas.DrawString(x * 21 + 21 - 3, y * 8 + 5, "███", wallColor, 0);
                        }
                        else if (makeTunnelDown)
                        {
                            if (c == '|')
                            {
                                mainCanvas.DrawString(x * 21 + 21 - 1, y * 8 + 4, "█", topColor, wallColor);
                            }
                            else
                            {
                                mainCanvas.DrawString(x * 21 + 21 - 3, y * 8 + 4, "▀▀█", topColor, wallColor);
                            }
                        }

                        if (makeTunnelDown)
                        {
                            for (int i = 0; i < 8; i++)
                            {
                                mainCanvas.DrawString(x * 21 + 22 - 2, y * 8 + 5 + i, "█", topColor, 0);
                            }
                        }

                        if (makeTunnelRight && def[y][x + 1] == '-')
                        {
                            mainCanvas.DrawString(x * 21 + 22, y * 8 + 4, "▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀", topColor, wallColor);
                        }
                    }
                }
            }

            return(mainCanvas);
        }