Ejemplo n.º 1
0
 public BoundaryBox(int row, XYPair size, Alignment boxAlignment = Alignment.Centered)
 {
     alignment = boxAlignment;
     y         = row;
     width     = size.x;
     height    = size.y;
 }
Ejemplo n.º 2
0
 public RandomPlanetGenerationScope(XYPair s, int sF, int r, int maxPerArea)
 {
     size             = s;
     splitFactor      = sF;
     radius           = r;
     maxAmountPerArea = maxPerArea;
 }
Ejemplo n.º 3
0
 public Border(XYPair size, XYPair position)
 {
     sizeX     = size.x;
     sizeY     = size.y;
     positionX = position.x;
     positionY = position.y;
 }
Ejemplo n.º 4
0
 public BoundaryBox(int row, int spacing, XYPair size, Alignment boxAlignment = Alignment.RightAligned)
 {
     alignment    = boxAlignment;
     y            = row;
     width        = size.x;
     height       = size.y;
     this.spacing = spacing;
 }
Ejemplo n.º 5
0
 public BoundaryBox(XYPair position, XYPair size)
 {
     alignment = Alignment.Free;
     x         = position.x;
     y         = position.y;
     width     = size.x;
     height    = size.y;
 }
Ejemplo n.º 6
0
        public Pages CreateNewData()
        {
            Console.Clear();
            FreeStringBundle fSB = new FreeStringBundle(21);

            fSB.AddFreeString("Hello Advanturer");
            fSB.AddFreeString("What is your name?");
            BoundaryBox box = new BoundaryBox(20, new XYPair(24, 7));

            box.Print();
            fSB.Print();
            Console.SetCursorPosition(Console.WindowWidth / 2 - 5, Console.CursorTop + 2);
            string playerName = Console.ReadLine();


            Console.Clear();
            fSB.ClearContent();

            fSB.AddFreeString($"Ok, {playerName}");
            fSB.AddFreeString("What is your gender?");
            XYPair bgSize = new XYPair(24, 7);
            Menu   menu   = new Menu(24);

            menu.AddItem(new MenuItem("Male", Alignment.Centered));
            menu.AddItem(new MenuItem("Female", Alignment.Centered));
            menu.SetEntryPoint(0);
            box.Print();
            fSB.Print();
            Gender playerGender = menu.EnterMenuLoop() == 0 ? Gender.Male : Gender.Female;

            box.Print();
            fSB.Print();
            Console.SetCursorPosition(Console.WindowWidth / 2 - 5, Console.CursorTop + 1);
            string gender = playerGender.ToString();

            objH.player       = new Player(playerName, playerGender, ref objH);
            objH.player.money = 50000;



            Console.Clear();
            bgSize = new XYPair(35, 5);
            box.SetSize(bgSize);
            fSB.ClearContent();
            fSB.AddFreeString($"Your Name is {playerName}");
            fSB.AddFreeString($"Your Gender is {gender}");
            fSB.AddFreeString($"Press Enter to find your home");
            box.Print();
            fSB.Print();
            Console.ReadLine();

            objH.GenerateNewData();



            return(Pages.Ship);
        }
Ejemplo n.º 7
0
        public void SetBG(int lineSize)
        {
            hasBG       = true;
            columnWidth = lineSize;
            XYPair size           = new XYPair(lineSize, menuItems.Count);
            int    startingColumn = style == BoxStyle.FullSize ? (Console.WindowWidth - columnWidth) / 2 : columnStart + columnWidth / 2;
            XYPair position       = new XYPair(startingColumn, firstRow);

            bg = new Border(size, position);
        }
Ejemplo n.º 8
0
 public FreeString(XYPair position, string t,
                   TextColor tColor    = TextColor.White, TextColor bColor = TextColor.Black,
                   Alignment alignment = Alignment.Free)
 {
     SetTextColor(tColor);
     SetBackgroundColor(bColor);
     textAlignment = alignment;
     text          = t;
     x             = position.x;
     y             = position.y;
 }
Ejemplo n.º 9
0
 public FreeString(XYPair position, string t,
                   Color tColor, Color bColor,
                   Alignment alignment = Alignment.Free)
 {
     textColor       = tColor;
     backgroundColor = bColor;
     textAlignment   = alignment;
     text            = t;
     x = position.x;
     y = position.y;
 }
Ejemplo n.º 10
0
 public void PrintFreeStrings()
 {
     foreach (FreeString s in freeStringBitmap)
     {
         XYPair sP = s.GetStartingPoint();
         Console.SetCursorPosition(sP.x, sP.y);
         Console.ForegroundColor = s.textColor;
         Console.BackgroundColor = s.backgroundColor;
         Console.Write(s.text);
     }
     Console.ResetColor();
 }
Ejemplo n.º 11
0
 public Numbers(int _digits, XYPair position, int max)
 {
     positionX = position.x;
     positionY = position.y;
     digits    = _digits;
     if (digits < 1)
     {
         digits = 1;
     }
     for (int i = 0; i < digits; i++)
     {
         numbers.Add(new Number());
     }
     this.max = max;
 }
Ejemplo n.º 12
0
        public void Print(XYPair position, string imageName)
        {
            int index = images.FindIndex(f => f.name == imageName);

            if (index >= 0)
            {
                Image imageSelected = images[index];
                GraphicRenderer.PrintImage(position, imageSelected);
            }
            else
            {
                StringRenderer.PrintFreeString(new FreeString(new XYPair(position.x, position.y),
                                                              $"Image: {imageName} not find", TextColor.Red, alignment: Alignment.LeftAligned));
            }
        }
Ejemplo n.º 13
0
        public int TestMenu()
        {
            XYPair bgSize   = new XYPair(10, 4);
            Menu   testMenu = new Menu(30);

            testMenu.AddItem(new MenuItem("Item 1", Alignment.Centered));
            testMenu.AddItem(new MenuItem("Item 2", Alignment.Centered));
            testMenu.AddItem(new MenuItem("Item 3", Alignment.Centered));
            testMenu.AddItem(new MenuItem("Item 4", Alignment.Centered));
            testMenu.AddItem(new MenuItem("Item 5", Alignment.Centered));
            testMenu.AddItem(new MenuItem("Item 6", Alignment.Centered));
            testMenu.AddItem(new MenuItem("Item 7", Alignment.Centered));
            testMenu.AddItem(new MenuItem("Item 8", Alignment.Centered));
            return(testMenu.EnterMenuLoop());
        }
Ejemplo n.º 14
0
 public Numbers(int _digits, XYPair position)
 {
     positionX = position.x;
     positionY = position.y;
     digits    = _digits;
     if (digits < 1)
     {
         digits = 1;
     }
     for (int i = 0; i < digits; i++)
     {
         numbers.Add(new Number());
         max += (int)(Math.Pow(10, i)) * 9;
     }
 }
Ejemplo n.º 15
0
        private void disableRadiusLocations(XYPair planet, List <XYPair> potentialLocations, int radius)
        {
            int cornerX = planet.getX() - radius;
            int cornerY = planet.getY() - radius;

            for (int x = 0; x < radius * 2; x++)
            {
                for (int y = 0; y < radius * 2; y++)
                {
                    XYPair c1 = new XYPair(x, y);
                    XYPair c2 = new XYPair(radius, radius);
                    if (Calc.WithinDistance(c1, c2, radius))
                    {
                        potentialLocations.Remove(new XYPair(cornerX + x, cornerY + y));
                    }
                }
            }
        }
Ejemplo n.º 16
0
        public List <Planet> GenerateHomeTown(XYPair homeTown)
        {
            int           x = homeTown.x;
            int           y = homeTown.y;
            List <Planet> homeTownPlanets = new List <Planet>();

            homeTownPlanets.Add(new Planet(new XYPair(5 + x, 5 + y), "Earth"));
            homeTownPlanets.Add(new Planet(new XYPair(4 + x, 3 + y), "Mars"));
            homeTownPlanets.Add(new Planet(new XYPair(5 + x, 4 + y), "XCentrolStation"));
            homeTownPlanets.Add(new Planet(new XYPair(4 + x, 5 + y), "YoRHa"));
            homeTownPlanets.Add(new Planet(new XYPair(7 + x, 8 + y), "Ernasis"));
            homeTownPlanets.Add(new Planet(new XYPair(9 + x, 9 + y), "Alpha Centauri 3"));
            homeTownPlanets.Add(new Planet(new XYPair(1 + x, 2 + y), "Lisnar"));
            homeTownPlanets.Add(new Planet(new XYPair(1 + x, 8 + y), "Amenias"));
            homeTownPlanets.Add(new Planet(new XYPair(9 + x, 2 + y), "Agnesia"));

            return(homeTownPlanets);
        }
Ejemplo n.º 17
0
        public static void PrintMenuItem(MenuItem item, int currentRow, int middleColumn, int startColumn)
        {
            XYPair position;

            switch (item.alignment)
            {
            case Alignment.LeftAligned:
                position = new XYPair(startColumn, currentRow);
                break;

            case Alignment.Centered:
                position = new XYPair(middleColumn - item.itemName.Length / 2 - 1, currentRow);
                break;

            default:
                position = new XYPair(middleColumn * 2 - item.itemName.Length, currentRow);
                break;
            }
            StringRenderer.PrintFreeString(new FreeString(position, item.itemName));
        }
Ejemplo n.º 18
0
        public static void PrintImage(XYPair position, Image image)
        {
            int row = position.y;

            foreach (string line in image.bitmap)
            {
                Console.SetCursorPosition(position.x, row);
                char[] nextLine = line.ToCharArray();
                for (int i = 0; i < nextLine.Length; i += 2)
                {
                    string nextPixel      = nextLine[i] + "";
                    int    nextColorIndex = Convert.ToInt32(nextPixel, 16);
                    setForeground(nextColorIndex, image.colors);
                    nextPixel      = nextLine[i + 1] + "";
                    nextColorIndex = Convert.ToInt32(nextPixel, 16);
                    setBackground(nextColorIndex, image.colors);
                    Console.Write("▀");
                }
                row++;
            }
        }
Ejemplo n.º 19
0
        public Pages MainMenu()
        {
            Console.Clear();
            Menu menu = new Menu(36);

            menu.AddItem(new MenuItem("New Game", Alignment.Centered));
            menu.AddItem(new MenuItem("Load Data", Alignment.Centered));
            menu.AddItem(new MenuItem("Credit", Alignment.Centered));
            menu.AddItem(new MenuItem("Exit", Alignment.Centered));
            menu.SetEntryPoint(1);
            XYPair      bgSize = new XYPair(20, 6);
            BoundaryBox box    = new BoundaryBox(35, bgSize);

            box.Print();
            objH.PrintImage(new XYPair(35, 5), "Logo");

            int i = menu.EnterMenuLoop();

            switch (i)
            {
            case 0:
                return(Pages.NewCharacter);

            case 1:
                break;

            case 2:
                break;

            case 3:
                return(Pages.Exit);

            default:
                break;
            }

            return(Pages.MainMenu);
        }
Ejemplo n.º 20
0
 public void SetBG(XYPair size, XYPair position)
 {
     hasBG = true;
     bg    = new Border(size, position);
 }
Ejemplo n.º 21
0
 public void SetBorder(XYPair size, XYPair position)
 {
     hasBorder = true;
     border    = new Border(size, position);
 }
Ejemplo n.º 22
0
 public void AddFreeString(XYPair position, string t,
                           TextColor tColor = TextColor.White, TextColor bColor = TextColor.Black)
 {
     freeStringBitmap.Add(new FreeString(position, t, tColor, bColor));
 }
Ejemplo n.º 23
0
 public static bool WithinDistance(XYPair c1, XYPair c2, int r)
 {
     return(c1 - c2 < r);
 }
Ejemplo n.º 24
0
 public void SetSize(XYPair size)
 {
     width  = size.x;
     height = size.y;
 }
Ejemplo n.º 25
0
 public void PrintImage(XYPair position, string imageName)
 {
     images.Print(position, imageName);
 }
Ejemplo n.º 26
0
        public void GenerateNewGalaxy()
        {
            AssetGenerator assetG             = new AssetGenerator();
            int            radius             = 7;
            int            sectionSizeX       = 70;
            int            sectionSizeY       = 50;
            int            splitFactor        = 4;//280 by 200
            RandomPlanetGenerationScope scope = new RandomPlanetGenerationScope(new XYPair(sectionSizeX, sectionSizeY),
                                                                                splitFactor, radius, 40);

            PrintGenerationInfo("Locating Planets...");
            List <XYPair> potentialPlanetLocations = assetG.GeneratePlanetLocations(scope);

            System.Threading.Thread.Sleep(1000);

            PrintGenerationInfo("Locating Home Planet System...");
            XYPair homeTownPosition = new XYPair(r.Next(50, 230), r.Next(50, 140));

            potentialPlanetLocations = assetG.EmptySpaceForHomeTown(potentialPlanetLocations, homeTownPosition);
            System.Threading.Thread.Sleep(1000);

            PrintGenerationInfo("Acquiring HomeTown Planet Names...");
            planets.AddRange(assetG.GenerateHomeTown(homeTownPosition));
            System.Threading.Thread.Sleep(1000);

            PrintGenerationInfo("Acquiring Planet Names...");
            planets.AddRange(assetG.PopulateLocation(potentialPlanetLocations));
            System.Threading.Thread.Sleep(1000);

            PrintGenerationInfo("Analyzing Market Data...");
            foreach (Planet p in planets)
            {
                p.GenerateMarket(ref r, categoryDatas);
                p.RefreshFuelPrice(ref r);
            }
            System.Threading.Thread.Sleep(1000);

            PrintGenerationInfo($"Locating {player.GetName()}...");
            player.setPlanet(planets.Find(p => p.GetName() == "Earth"));
            System.Threading.Thread.Sleep(1000);



            // BitMap for debug
            //PrintGenerationInfo($"Generating Galaxy Map...");
            //Bitmap bmp = new Bitmap((sectionSizeX + radius) * splitFactor * 10, (sectionSizeY + radius) * splitFactor * 10);
            //Graphics g = Graphics.FromImage(bmp);
            //foreach (XYPair l in potentialPlanetLocations)
            //{
            //    g.DrawEllipse(new Pen(Color.FromArgb(12,12,12), 3f),
            //        new Rectangle(new Point((l.x - radius) * 10, (l.y - radius) * 10), new Size(radius * 10, radius * 10)));
            //}
            //List<String> homePlanets = new List<string> { "Earth", "Mars", "XCentrolStation", "YoRHa", "Ernasis", "Alpha Centauri 3",
            // "Lisnar", "Amenias", "Agnesia"};
            //foreach (Planet p in planets)
            //{
            //    if (homePlanets.Contains(p.name))
            //    {
            //        g.FillEllipse(new SolidBrush(ColorTranslator.FromHtml("#ff00ffff")), new Rectangle(new Point((p.GetLocation().x - radius) * 10, (p.GetLocation().y - radius) * 10),
            //        new Size(radius * 2, radius * 2))
            //        );
            //    }

            //}

            //g.Dispose();
            //bmp.Save(@"C:\MSSA\Galaxy Map.PNG", System.Drawing.Imaging.ImageFormat.Png);
            //bmp.Dispose();
            PrintGenerationInfo($"Process Complete!");
            System.Threading.Thread.Sleep(3000);
            PrintGenerationInfo($"Welcome, {player.name}!");
            System.Threading.Thread.Sleep(2000);
        }
Ejemplo n.º 27
0
 //        bool generated;
 public Planet(XYPair location, string name)
 {
     this.name     = name;
     this.location = location;
 }
Ejemplo n.º 28
0
 public List <XYPair> EmptySpaceForHomeTown(List <XYPair> potentialPlanetLocations, XYPair homeTown)
 {
     potentialPlanetLocations.RemoveAll(l => (l.getX() > homeTown.x && l.getX() < homeTown.x + 12) &&
                                        (l.getY() > homeTown.y && l.getY() < homeTown.y + 12));
     return(potentialPlanetLocations);
 }