コード例 #1
0
ファイル: Program.cs プロジェクト: TheRealSquidgy/Game
        //Game start menu. Player can start a new game or continue an existing one.
        static string Start(Soldier player)
        {
            string Choice = "";

            while (Choice == "")
            {
                Console.WriteLine("Welcome to Squidgy's Intergalactice Arena of Death! \n");
                Console.WriteLine("Press 1 - Start new game");
                Console.WriteLine("Press 2 - Continue");
                if (File.Exists(State.SaveLocation(player)))
                {
                    Console.WriteLine("\t Name: " + player.Name);
                    Console.WriteLine("\t Level: " + player.Level);
                    Console.WriteLine("\t Career winnings: " + player.Moonbux + " Moonbux");
                    Console.WriteLine("\t Missions survived: " + player.Survived);
                }
                else
                {
                    Console.WriteLine("\t---NO SAVE DATA---");
                }
                Console.WriteLine("Press 3 - Quit \n");
                Choice = Console.ReadLine();
                switch (Choice)
                {
                case "1":
                {
                    Console.Clear();
                    return("CreateSoldier");
                }

                case "2":
                {
                    if (File.Exists(State.SaveLocation(player)))
                    {
                        Console.Clear();
                        return("Mission");
                    }
                    else
                    {
                        Console.WriteLine("No save data! Select 1 to create a new soldier. Press enter to continue");
                        Console.ReadLine();
                        Console.Clear();
                        Choice = "";
                        break;
                    }
                }

                case "3":
                {
                    System.Environment.Exit(0);
                    break;
                }

                default:
                {
                    Console.WriteLine("Invalid input. Please enter 1 or 2.");
                    Choice = "";
                    break;
                }
                }
            }
            return("Mission");
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: TheRealSquidgy/Game
        public static string GoShop(List <ShopItem> ShopInventory, Soldier player, Inventory playerInventory)
        {
            string itemChoice = "";

            while (itemChoice == "")
            {
                Console.Clear();
                Console.WriteLine("Welcome to the item shop!\n"); //displays item list, prompts user to select item number
                for (int i = 0; i < ShopInventory.Count; i++)
                {
                    Console.WriteLine((i + 1) + ") {0} - {1} Moonbux", ShopInventory[i].WeaponData.Name, ShopInventory[i].ItemPrice);
                }
                Console.WriteLine();
                Console.WriteLine(player.Name + "'s funds: " + player.Moonbux + " Moonbux");
                Console.WriteLine("Select a number to view weapon stats. Type EXIT to leave the item shop: -");

                itemChoice = Console.ReadLine();
                bool isInt;
                int  intItemChoice;
                isInt = int.TryParse(itemChoice, out intItemChoice);

                if (isInt)
                {
                    intItemChoice -= 1;
                    if (intItemChoice <= ShopInventory.Count && intItemChoice >= 0) //checks if number is valid menu option. If yes, display item stats.
                    {
                        Console.Clear();

                        Weapon selectedWeaponData = ShopInventory[intItemChoice].WeaponData;

                        Console.WriteLine("Weapon: " + selectedWeaponData.Name);
                        Console.WriteLine("Damage: " + selectedWeaponData.DmgMin + "-" + selectedWeaponData.DmgMax);
                        Console.WriteLine("Critical Hit Damage: " + selectedWeaponData.CritDmgMin + "-" + selectedWeaponData.CritDmgMax);
                        Console.WriteLine("Critical Hit Chance: " + selectedWeaponData.CritChance + "%");
                        Console.WriteLine(selectedWeaponData.Description + "\n");

                        bool playerOwnsWeapon = CheckWeaponOwnership(playerInventory, player, selectedWeaponData);
                        if (playerOwnsWeapon == false) //if player does not own the selected weapon give them the choice to buy it, assuming they have the funds.
                        {
                            Console.WriteLine("Press 1 to buy weapon. Press 2 to return to item list.");
                            string purchaseDecision = "";
                            while (purchaseDecision == "")
                            {
                                purchaseDecision = Console.ReadLine();
                                switch (purchaseDecision)
                                {
                                case "1":
                                {
                                    bool playerCanAffordItem = CheckFunds(player, ShopInventory[intItemChoice]);
                                    if (playerCanAffordItem)
                                    {
                                        player.Moonbux -= ShopInventory[intItemChoice].ItemPrice;
                                        Console.WriteLine("Item purchased! Press 1 to equip now. Press 2 to send to inventory.");
                                        string purchasedItemDestination = "";
                                        while (purchasedItemDestination == "")
                                        {
                                            purchasedItemDestination = Console.ReadLine();
                                            switch (purchasedItemDestination)
                                            {
                                            case "1":
                                            {
                                                Console.WriteLine(selectedWeaponData.Name + " equipped. " + player.WeaponEquipped.Name + " sent to inventory.");
                                                Console.ReadLine();
                                                playerInventory.Weapons.Add(player.WeaponEquipped);
                                                player.WeaponEquipped = selectedWeaponData;
                                                itemChoice            = "";
                                                break;
                                            }

                                            case "2":
                                            {
                                                playerInventory.Weapons.Add(selectedWeaponData);
                                                Console.WriteLine(selectedWeaponData.Name + " sent to inventory. Press enter to return to item shop.");
                                                Console.ReadLine();
                                                itemChoice = "";
                                                break;
                                            }

                                            default:
                                            {
                                                Console.WriteLine("Invalid input. Press 1 to equip now. Press 2 to send to inventory.");
                                                break;
                                            }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        Console.WriteLine("Insufficient funds! Returning to item shop.");
                                        Console.ReadLine();
                                        itemChoice = "";
                                    }
                                    break;
                                }

                                case "2":
                                {
                                    itemChoice = "";
                                    break;
                                }

                                default:
                                {
                                    Console.WriteLine("Invalid input. Press 1 to buy weapon. Press 2 to return to item list.");
                                    purchaseDecision = "";
                                    break;
                                }
                                }
                            }
                        }
                        else //if player does own the weapon, check if equipped. If not, offer to equip the weapon.
                        {
                            bool selectedWeaponAlreadyEquipped;
                            selectedWeaponAlreadyEquipped = CheckIfEquipped(player, selectedWeaponData);
                            if (selectedWeaponAlreadyEquipped)
                            {
                                Console.WriteLine(selectedWeaponData.Name + " already equipped. Press enter to return to the item list.");
                                Console.ReadLine();
                                itemChoice = "";
                            }
                            else
                            {
                                Console.WriteLine(selectedWeaponData.Name + " already purchased and in storage.");
                                Console.WriteLine("You currently have the " + player.WeaponEquipped.Name + " equipped.");
                                Console.WriteLine("Press 1 to swap out weapons. Press 2 to return to item list.");
                                string equipOrReturn = "";
                                while (equipOrReturn == "")
                                {
                                    equipOrReturn = Console.ReadLine();
                                    switch (equipOrReturn)
                                    {
                                    case "1":
                                    {
                                        playerInventory.Weapons.Add(player.WeaponEquipped);
                                        player.WeaponEquipped = selectedWeaponData;
                                        RemoveWeaponFromInventory(player, playerInventory);
                                        Console.WriteLine(player.WeaponEquipped.Name + " taken from inventory and equipped.");
                                        Console.ReadLine();
                                        itemChoice = "";
                                        break;
                                    }

                                    case "2":
                                    {
                                        itemChoice = "";
                                        break;
                                    }

                                    default:
                                    {
                                        Console.WriteLine("Invalid input. Press 1 to equip this weapon now. Press 2 to return to item list.");
                                        Console.ReadLine();
                                        equipOrReturn = "";
                                        break;
                                    }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        //Console.Clear();
                        Console.WriteLine("Invalid input. Select a valid number to view weapon stats.");
                        itemChoice = "";
                        Console.ReadLine();
                    }
                }
                else if (itemChoice.ToLower() == "exit")
                {
                    Console.WriteLine("Thanks for visiting the item shop! See you next time.");
                    State.Save(playerInventory);
                    Console.WriteLine("Inventory has been saved.");
                    Console.ReadLine();
                    Console.Clear();
                    return("OptionSelect");
                }
                else
                {
                    //Console.Clear();
                    Console.WriteLine("Invalid input. Select a valid number to view weapon stats.");
                    itemChoice = "";
                    Console.ReadLine();
                }
            }
            return("OptionSelect");
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: TheRealSquidgy/Game
        //Win or lose, OptionSelect handles what happens after PostCombat. If the player won (savefile still exists), they can play again, visit the item shop or save and quit. If the player lost, they can return to title screen or quit.
        public static string OptionSelect(Soldier player)
        {
            if (File.Exists(State.SaveLocation(player)))
            {
                string Choice = "";
                while (Choice == "")
                {
                    Console.WriteLine("What would you like to do next? \n");
                    Console.WriteLine("1. Play again.");
                    Console.WriteLine("2. Visit the Item Shop.");
                    Console.WriteLine("3. Save and exit.");
                    Choice = Console.ReadLine();
                    switch (Choice)
                    {
                    case "1":
                    {
                        Console.Clear();
                        return("Mission");
                        //break;
                    }

                    case "2":
                    {
                        Console.Clear();
                        return("Shop");
                        //break;
                    }

                    case "3":
                    {
                        Console.Clear();
                        return("Exit");
                        //break;
                    }

                    default:
                    {
                        Console.WriteLine("Invalid input. Please enter 1, 2 or 3 from the above options.");
                        Choice = "";
                        break;
                    }
                    }
                }
            }
            else
            {
                string Choice = "";
                while (Choice == "")
                {
                    Console.WriteLine("What would you like to do next?\n");
                    Console.WriteLine("1. Start a new game");
                    Console.WriteLine("2. Quit");
                    Choice = Console.ReadLine();
                    switch (Choice)
                    {
                    case "1":
                    {
                        return("Start");
                        //break;
                    }

                    case "2":
                    {
                        return("Exit");
                        //break;
                    }

                    default:
                    {
                        Console.WriteLine("Invalid input. Please enter 1 or 2.");
                        Choice = "";
                        break;
                    }
                    }
                }
            }
            Console.WriteLine("Something has gon wrong in OptionSelect. You should never see this.");
            return("Exit");
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: TheRealSquidgy/Game
        static int CalculateNewLevelExpReq(Soldier player)
        {
            int LevelExpReq = 100 + (player.Level * 50);

            return(LevelExpReq);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: TheRealSquidgy/Game
        static void Main(string[] args)
        {
            Soldier   player          = new Soldier();
            Inventory playerInventory = new Inventory();
            Shop      ItemShop        = new Shop();

            if (File.Exists(State.SaveLocation(player)))
            {
                player          = (Soldier)State.Load(player);
                playerInventory = (Inventory)State.Load(playerInventory);
            }

            string nextFunction = "Start";

            while (nextFunction != "Exit")
            {
                switch (nextFunction)
                {
                case "Start":
                {
                    nextFunction = Start(player);
                    break;
                }

                case "CreateSoldier":
                {
                    nextFunction = CreateSoldier(player, playerInventory);
                    break;
                }

                case "Mission":
                {
                    Entity  winner;
                    Sectoid enemy = new Sectoid();
                    Mission.PreCombat(player, enemy);
                    winner = Mission.Combat(player, enemy);
                    Mission.PostCombat(winner, player, playerInventory);
                    nextFunction = "OptionSelect";
                    break;
                }

                case "OptionSelect":
                {
                    nextFunction = OptionSelect(player);
                    break;
                }

                case "Shop":
                {
                    nextFunction = Shop.GoShop(Shop.ShopInventory, player, playerInventory);
                    break;
                }

                case "Exit":
                {
                    break;
                }

                default:
                {
                    Console.Write("This should never run. Something has gone wrong. Press enter to end the session.");
                    Console.ReadLine();
                    System.Environment.Exit(0);
                    break;
                }
                }
            }
            System.Environment.Exit(0);
        }