示例#1
0
        public Pages Buy()
        {
            Console.Clear();
            TitleBox titleBox = new TitleBox("Buy");

            titleBox.Print();

            BoundaryBox box = new BoundaryBox(25, edge, new XYPair(66, 20), Alignment.LeftAligned);

            box.Print();

            objH.PrintImage(new XYPair(edge + 68, 15), "ShopKeeper");

            Menu buyShop = new Menu(27, edge + 3, maxShown: 9, menuStyle: BoxStyle.Limited, width: 60);

            foreach (ShopItem item in objH.player.currentPlanet.supplyShop)
            {
                buyShop.AddItem(new MenuItem(Calc.GetShopDisplay(item)));
            }

            buyShop.SetEntryPoint(0);
            int selection = buyShop.EnterMenuLoop();

            FreeString wouldLiketoBuy = new FreeString(new XYPair(edge + 3, 38), "How many would you like to buy?");
            int        maxAmount      = objH.player.money / objH.player.currentPlanet.supplyShop[selection].GetPrice();
            Numbers    amount         = new Numbers(3, new XYPair(edge + 4, 40), maxAmount);

            wouldLiketoBuy.Print();
            int amountBought = amount.EnterMainLoop();

            objH.player.Buy(objH.player.currentPlanet.supplyShop[selection], amountBought);
            return(Pages.Shop);
        }
示例#2
0
        public Pages Inventory()
        {
            Console.Clear();
            TitleBox titleBox = new TitleBox("Inventory");

            titleBox.Print();

            BoundaryBox box = new BoundaryBox(10, edge, new XYPair(66, 35), Alignment.LeftAligned);

            box.Print();

            objH.PrintImage(new XYPair(edge + 68, 15), "Pikachu");

            Menu inventoryMenu = new Menu(27, edge + 3, maxShown: 20, menuStyle: BoxStyle.Limited, width: 60);

            foreach (InventoryItem item in objH.player.inventory)
            {
                inventoryMenu.AddItem(new MenuItem(Calc.GetInventoryDisplay(item)));
            }

            inventoryMenu.SetEntryPoint(0);
            int selection = inventoryMenu.EnterMenuLoop();

            return(Pages.Ship);
        }
示例#3
0
        public Pages Sale()
        {
            Console.Clear();
            TitleBox titleBox = new TitleBox("Sale");

            titleBox.Print();

            BoundaryBox box = new BoundaryBox(25, edge, new XYPair(66, 20), Alignment.LeftAligned);

            box.Print();

            objH.PrintImage(new XYPair(edge + 68, 15), "ShopKeeper");

            Menu            saleShop = new Menu(27, edge + 3, maxShown: 9, menuStyle: BoxStyle.Limited, width: 60);
            List <ShopItem> canSale  = new List <ShopItem>();

            foreach (ShopItem item in objH.player.currentPlanet.demandShop)
            {
                if (objH.player.inventory.Any(i => i.index == item.GetIndex()))
                {
                    canSale.Add(item);
                    saleShop.AddItem(new MenuItem(Calc.GetShopDisplay(item)));
                }
            }

            if (canSale.Count > 0)
            {
                saleShop.SetEntryPoint(0);
                int selection = saleShop.EnterMenuLoop();

                FreeString wouldLiketoSale = new FreeString(new XYPair(edge + 3, 38), "How many would you like to Sale?");
                int        maxAmount       = objH.player.inventory.FirstOrDefault(i => i.index == canSale[selection].GetIndex()).amount;
                Numbers    amount          = new Numbers(3, new XYPair(edge + 4, 40), maxAmount);
                wouldLiketoSale.Print();
                int amountSold = amount.EnterMainLoop();
                objH.player.Sale(canSale[selection], amountSold);
            }
            else
            {
                FreeString nothingToSale = new FreeString(new XYPair(edge + 10, 30), "You don't have anything to sale to this planet");
                nothingToSale.Print();
                Console.Read();
            }
            return(Pages.Shop);
        }
示例#4
0
        public Pages Shop()
        {
            Console.Clear();
            TitleBox titleBox = new TitleBox("SHOP");

            titleBox.Print();


            BoundaryBox welcomeBox = new BoundaryBox(25, new XYPair(50, 10), Alignment.Centered);

            FreeStringBundle welcomeMessage = new FreeStringBundle(26, edge + 40, 200);

            welcomeMessage.AddFreeString("Welcome, Dear Customer!", alignment: Alignment.LeftAligned);
            welcomeMessage.AddFreeString("What would you like to do today!", alignment: Alignment.LeftAligned);

            Menu buyOrSale = new Menu(29, menuStyle: BoxStyle.Limited, _alignment: Alignment.Centered, width: 5);

            buyOrSale.AddItem(new MenuItem("Buy", Alignment.Centered));
            buyOrSale.AddItem(new MenuItem("Sale", Alignment.Centered));
            buyOrSale.AddItem(new MenuItem("Exit", Alignment.Centered));

            welcomeBox.Print();
            welcomeMessage.Print();
            buyOrSale.SetEntryPoint(0);
            int choice = buyOrSale.EnterMenuLoop();

            switch (choice)
            {
            case 0:
                return(Pages.Buy);

            case 1:
                return(Pages.Sale);

            case 2:
                return(Pages.Ship);

            default:
                break;
            }

            return(Pages.Ship);
        }
示例#5
0
        public Pages Travel()
        {
            Console.Clear();
            TitleBox titleBox = new TitleBox("Travel");

            titleBox.Print();

            List <BoundaryBox> boxs = new List <BoundaryBox>();

            boxs.Add(new BoundaryBox(25, edge, new XYPair(69, 20), Alignment.RightAligned));
            boxs.Add(new BoundaryBox(25, edge, new XYPair(50, 20), Alignment.LeftAligned));
            boxs.Add(new BoundaryBox(5, edge, new XYPair(60, 20), Alignment.RightAligned));
            titleBox.Print();

            List <FreeStringBundle> fSBs = new List <FreeStringBundle>();

            fSBs.Add(new FreeStringBundle(9, edge + 63, 200));
            string supplies = objH.player.currentPlanet.supplies;

            fSBs.Add(new FreeStringBundle(27, edge + 55, 200));
            fSBs[1].AddFreeString($"WrapFactor: {objH.player.wrapFactor}", alignment: Alignment.LeftAligned);
            fSBs[1].AddFreeString($"Speed: {objH.player.GetSpeed()}", alignment: Alignment.LeftAligned);
            fSBs[1].AddFreeString($"Current Fuel LeveL: {objH.player.GetFuelLevel()}", alignment: Alignment.LeftAligned);
            fSBs[1].AddFreeString($"Age: {objH.player.GetAge()}", alignment: Alignment.LeftAligned);


            fSBs.Add(new FreeStringBundle(27, edge + 95, 200));
            fSBs[2].AddFreeString($"Money: {objH.player.money}", alignment: Alignment.LeftAligned);


            foreach (BoundaryBox box in boxs)
            {
                box.Print();
            }

            foreach (FreeStringBundle fSB in fSBs)
            {
                fSB.Print();
            }

            List <Planet> planetsInReach = objH.player.GetPlanetWithinReach();

            Menu travelTo = new Menu(27, edge + 3, maxShown: 9, menuStyle: BoxStyle.Limited, width: 30);

            foreach (Planet p in planetsInReach)
            {
                travelTo.AddItem(new MenuItem(p.name));
            }
            travelTo.SetEntryPoint(0);
            objH.PrintImage(new XYPair(edge + 5, 5), "Planet");

            int  selection = 0;
            bool done      = false;

            while (!done)
            {
                double distance = planetsInReach[travelTo.ReturnIndex()].location - objH.player.currentPlanet.location;
                string demands  = objH.player.currentPlanet.demands;
                fSBs[0].ClearContent();
                boxs[2].Print();
                fSBs[0].AddFreeString($"Current Selected Planet Location: {planetsInReach[travelTo.ReturnIndex()].location}", alignment: Alignment.LeftAligned);
                fSBs[0].AddFreeString($"Supply(s):{planetsInReach[travelTo.ReturnIndex()].supplies}", alignment: Alignment.LeftAligned);
                fSBs[0].AddFreeString($"Demand(s):{planetsInReach[travelTo.ReturnIndex()].demands}", alignment: Alignment.LeftAligned);
                fSBs[0].AddFreeString($"Fuel Price: {planetsInReach[travelTo.ReturnIndex()].fuelPrice}", alignment: Alignment.LeftAligned);
                fSBs[0].AddFreeString($"Distance From Current Planet: {distance}", alignment: Alignment.LeftAligned);
                fSBs[0].Print();

                travelTo.Print();

                var input = Console.ReadKey().Key;
                switch (input)
                {
                case ConsoleKey.UpArrow:
                    travelTo.ItemUp();
                    break;

                case ConsoleKey.DownArrow:
                    travelTo.ItemDown();
                    break;

                case ConsoleKey.Enter:
                    selection = travelTo.ReturnIndex();
                    done      = true;
                    break;

                default:
                    break;
                }
            }

            foreach (Planet p in planetsInReach)
            {
                p.RefreshMarket(ref objH.r, objH.categoryDatas);
            }

            objH.player.Travel(planetsInReach[selection]);

            return(Pages.Ship);
        }
示例#6
0
        public Pages Ship()
        {
            Console.Clear();
            TitleBox           titleBox = new TitleBox("SHIP");
            List <BoundaryBox> boxs     = new List <BoundaryBox>();


            boxs.Add(new BoundaryBox(25, edge, new XYPair(69, 20), Alignment.RightAligned));
            boxs.Add(new BoundaryBox(25, edge, new XYPair(50, 20), Alignment.LeftAligned));
            boxs.Add(new BoundaryBox(5, edge, new XYPair(60, 20), Alignment.RightAligned));
            titleBox.Print();


            List <FreeStringBundle> fSBs = new List <FreeStringBundle>();

            fSBs.Add(new FreeStringBundle(9, edge + 70, 200));
            string supplies = objH.player.currentPlanet.supplies;

            string demands = objH.player.currentPlanet.demands;

            fSBs[0].AddFreeString($"Current Planet: {objH.player.currentPlanet.name}", alignment: Alignment.LeftAligned);
            fSBs[0].AddFreeString($"Supply(s):{supplies}", alignment: Alignment.LeftAligned);
            fSBs[0].AddFreeString($"Demand(s):{demands}", alignment: Alignment.LeftAligned);
            fSBs[0].AddFreeString($"Fuel Price: {objH.player.currentPlanet.fuelPrice}", alignment: Alignment.LeftAligned);


            fSBs.Add(new FreeStringBundle(27, edge + 55, 200));
            fSBs[1].AddFreeString($"WrapFactor: {objH.player.wrapFactor}", alignment: Alignment.LeftAligned);
            fSBs[1].AddFreeString($"Speed: {objH.player.GetSpeed()}", alignment: Alignment.LeftAligned);
            fSBs[1].AddFreeString($"Current Fuel LeveL: {objH.player.GetFuelLevel()}", alignment: Alignment.LeftAligned);
            fSBs[1].AddFreeString($"Age: {objH.player.GetAge()}", alignment: Alignment.LeftAligned);


            fSBs.Add(new FreeStringBundle(27, edge + 95, 200));
            fSBs[2].AddFreeString($"Money: {objH.player.money}", alignment: Alignment.LeftAligned);


            foreach (BoundaryBox box in boxs)
            {
                box.Print();
            }

            foreach (FreeStringBundle fSB in fSBs)
            {
                fSB.Print();
            }


            Menu main = new Menu(27, edge + 3, menuStyle: BoxStyle.Limited, width: 15);

            main.AddItem(new MenuItem("Travel", Alignment.Centered, MenuPart.MenuItemSelected));
            main.AddItem(new MenuItem("Refuel", Alignment.Centered, MenuPart.MenuItem));
            main.AddItem(new MenuItem("Shop", Alignment.Centered, MenuPart.MenuItem));
            main.AddItem(new MenuItem("Inventory", Alignment.Centered, MenuPart.MenuItem));
            //main.AddItem(new MenuItem("Upgrade", Alignment.Centered, MenuPart.MenuItem));

            objH.PrintImage(new XYPair(edge + 5, 5), "Planet");

            int selection = main.EnterMenuLoop();

            switch (selection)
            {
            case 0:
                return(Pages.Travel);

            case 1:
                objH.player.refuel();
                return(Pages.Ship);

            case 2:
                return(Pages.Shop);

            case 3:
                return(Pages.Inventory);

            case 4:
                return(Pages.Upgrade);
            }


            return(Pages.Ship);
        }