コード例 #1
0
        public void unequip(string slot, string itemkey) //Handles unequipping all equipment
        {
            equipUnequipSB.equipunequipsb.Clear();       //Clears the equip and unequip string builder
            switch (slot.ToUpper())                      //Checks if the input is the correct slot for equipment
            {
            case "HELMET":
            case "CHEST":
            case "HAND":
            case "WAIST":
            case "LEG":
            case "BOOT":
            case "NECK":
            case "WRIST":
            case "RING1":
            case "RING2":
                foreach (GenericEquipment item in PlayerCharacter.theCharacter.playerEquipment.Values)                                                //Iterates through the player equipment
                {
                    if (PlayerCharacter.theCharacter.playerEquipmentSlots[slot].name == item.name)                                                    //If the current equipment name is equal to the equipped equipments name
                    {
                        PlayerCharacter.theCharacter.playerEquipment[itemkey].current++;                                                              //Adds a quantity of 1 to the players equipment inventory for the desired equipment item
                        PlayerCharacter.theCharacter.playerEquipmentSlots[slot].removeAttributes();                                                   //Removes the attributes applied by the equipment item
                        PlayerCharacter.theCharacter.playerEquipmentSlots[slot] = Equipment.iEquipmentMasterList["Empty"];                            //Assigns the players equipment slot to be empty
                        equipUnequipSB.equipunequipsb.Append("You unequip the " + PlayerCharacter.theCharacter.playerEquipment[itemkey].name + "\n"); //Writes the unequip message to the console window
                        break;
                    }
                }
                break;

            default:    //If no matches are found nothing happens
                break;
            }
            ConsoleSpecificTextDisplay.writeEquipUnequip();
        }
コード例 #2
0
        public void equip(string slot, string itemKey) //Handles equipping all equipment
        {
            equipUnequipSB.equipunequipsb.Clear();     //Clears the equip and unequip string builder
            switch (slot)                              //Checks if the input is the correct slot for equipment
            {
            case "HELMET":
            case "CHEST":
            case "HAND":
            case "WAIST":
            case "LEG":
            case "BOOT":
            case "NECK":
            case "WRIST":
            case "RING1":
            case "RING2":
                PlayerCharacter.theCharacter.playerEquipmentSlots[slot] = PlayerCharacter.theCharacter.playerEquipment[itemKey];            //Assigns the equipment item to the correct equipment slot
                equipUnequipSB.equipunequipsb.Append("You equip the " + PlayerCharacter.theCharacter.playerEquipment[itemKey].name + "\n"); //Displays text for equipping the equipment
                PlayerCharacter.theCharacter.playerEquipment[itemKey].current -= 1;                                                         //Removes a quantity of 1 from the equipment inventory
                PlayerCharacter.theCharacter.playerEquipment[itemKey].applyAttributes();                                                    //Adds the attribute bonuses from the equipment to the player
                break;

            default:    //If no correct slot is chosen nothing happens
                break;
            }
            ConsoleSpecificTextDisplay.writeEquipUnequip();
        }
コード例 #3
0
 public static void textCommand(string userInput) //Checks the users input text and then checks the starting letters
 {
     if (userInput.StartsWith("E:"))              //Equips items if it starts with E:
     {
         equipCommand(userInput);
     }
     if (userInput.StartsWith("U:"))//Unequips items if it starts with U:
     {
         unequipCommand(userInput);
     }
     if (userInput.StartsWith("I:"))//Displays the characters inventory if it starts with I:
     {
         ConsoleSpecificTextDisplay.writeInventory();
     }
     if (userInput.StartsWith("EQ:"))//Displays the characters equipment if it starts with EQ:
     {
         ConsoleSpecificTextDisplay.writeEquipmentInventory();
     }
     if (userInput.StartsWith("EI:"))//Displays the characters equipment if it starts with EQ:
     {
         ConsoleSpecificTextDisplay.writeEquipedEquipment();
     }
     if (userInput.StartsWith("P:"))//Displays the characters attributes if it starts with P:
     {
         ConsoleSpecificTextDisplay.displayCharacterStats();
     }
     if (userInput.StartsWith("A:"))//Displays the characters abilities if it starts with A:
     {
         ConsoleSpecificTextDisplay.displayCharacterAbilities();
     }
 }
コード例 #4
0
        public static void obtainEquipment(string equipmentKey, int quantity) //see obtainItem method, they are really the same just for a different type
        {
            GenericEquipment obtainedEquipment;                               //A generic declared equipment object

            bool alreadyObtained = false;                                     //Makes sure already obtained for the equipment is false
            bool itemMismatch    = false;                                     //and tells the game that their is no mismatch for the equipment

            obtainSB.Clear();                                                 //Clears the string builder for this class
            foreach (string item in PlayerCharacter.theCharacter.playerEquipment.Keys)
            {
                if (item == equipmentKey)//If the equipment matches the equipment key in the inventory then already obtained is set to true
                {
                    alreadyObtained = true;
                    break;
                }
                else//otherwise already obtained is set to false
                {
                    alreadyObtained = false;
                }
            }
            if (alreadyObtained == true)//If the player already has obtained the equipment
            {
                //Checks if adding the player has less than the max amount of that equipment and then adds one if not
                if (PlayerCharacter.theCharacter.playerEquipment[equipmentKey].current + quantity < PlayerCharacter.theCharacter.playerEquipment[equipmentKey].max)
                {
                    PlayerCharacter.theCharacter.playerEquipment[equipmentKey].current++;
                }
                obtainSB.Append("You obtain " + quantity + " " + equipmentKey + "\n");//Writes text to the string builder stating you obtained the equipment
            }
            else//If the player does not already have the equipment
            {
                foreach (string equipment in Equipment.iEquipmentMasterList.Keys)                          //Goes through the list of all equipment
                {
                    if (equipment == equipmentKey)                                                         //if the equipment being obtained matches an equipment in the list
                    {
                        obtainedEquipment = Equipment.iEquipmentMasterList[equipmentKey].cloneEquipment(); //The generic declared equipment object is set to be the found item by calling the clone method
                        obtainSB.Append("You obtain " + quantity + " " + equipmentKey + "\n");             //writes to the string builder the item was obtained
                        PlayerCharacter.theCharacter.playerEquipment.Add(equipmentKey, obtainedEquipment); //Adds the equipment to the player inventory
                        PlayerCharacter.theCharacter.playerEquipment[equipmentKey].current++;              //adds a quantity of 1 to the players newly obtained equipment
                        itemMismatch = false;
                        break;
                    }
                    else//if no match is found, there is an item mismatch
                    {
                        itemMismatch = true;
                    }
                }
                if (itemMismatch == true)//if an equipment mismatch has occured the proper text will be displayed
                {
                    obtainSB.Append("That item does not exist" + "\n");
                }
            }
            ConsoleSpecificTextDisplay.displayObtainedItemText();
        }
コード例 #5
0
        public static StringBuilder obtainSB = new StringBuilder();                    //The string builder for the entire class

        public static void obtainItem(string itemKey, int quantity)                    //The main method for obtaining items in game
        {
            iItem obtainedItem;                                                        //A generic declared item object

            bool alreadyObtained = false;                                              //Makes sure already obtained for the item is false
            bool itemMismatch    = false;                                              //and tells the game that their is no mismatch for the item

            obtainSB.Clear();                                                          //Clears the string builder for this class
            foreach (string item in PlayerCharacter.theCharacter.playerInventory.Keys) //Looks through all the items in a players inventory
            {
                if (item == itemKey)                                                   //If the item matches the item key in the inventory then already obtained is set to true
                {
                    alreadyObtained = true;
                    break;
                }
                else//otherwise already obtained is set to false
                {
                    alreadyObtained = false;
                }
            }
            if (alreadyObtained == true)//If the player already has obtained the item
            {
                //Checks if adding the player has less than the max amount of that item and then adds one if not
                if (PlayerCharacter.theCharacter.playerInventory[itemKey].current + quantity < PlayerCharacter.theCharacter.playerInventory[itemKey].max)
                {
                    PlayerCharacter.theCharacter.playerInventory[itemKey].current++;
                }
                obtainSB.Append("You obtain " + quantity + " " + itemKey + "\n");//Writes text to the string builder stating you obtained the item
            }
            else//If the player does not already have the item
            {
                foreach (string item in Items.iItemMasterList.Keys)                              //Goes through the list of all items
                {
                    if (item == itemKey)                                                         //if the item being obtained matches an item in the list
                    {
                        obtainedItem = Items.iItemMasterList[itemKey].cloneItem();               //The generic declared item object is set to be the found item by calling the clone method
                        obtainSB.Append("You obtain " + quantity + " " + itemKey + "\n");        //writes to the string builder the item was obtained
                        PlayerCharacter.theCharacter.playerInventory.Add(itemKey, obtainedItem); //Adds the item to the player inventory by calling the clone method for the item
                        PlayerCharacter.theCharacter.playerInventory[item].current++;            //adds a quantity of 1 to the players newly obtained item
                        itemMismatch = false;
                        break;
                    }
                    else//if no match is found, there is an item mismatch
                    {
                        itemMismatch = true;
                    }
                }
                if (itemMismatch == true)//if an item mismatch has occured the proper text will be displayed
                {
                    obtainSB.Append("That item does not exist" + "\n");
                }
            }
            ConsoleSpecificTextDisplay.displayObtainedItemText();
        }
コード例 #6
0
ファイル: LevelUp.cs プロジェクト: Stardragora/RPGComponents
        public static void levelup(PlayerCharacter player) //main method for performing the level up function
        {
            Job GenericJob = player.characterJob;          //Generic job is declared

            if (player == PlayerCharacter.theCharacter)    //Checks if the player is the player character
            {
                //Adds the next levels values to the current attributes for the player character
                player.hp   += GenericJob.hpArray[player.level];
                player.chp   = player.hp;
                player.mhp   = player.hp;
                player.mp   += GenericJob.mpArray[player.level];
                player.cmp   = player.mp;
                player.mmp   = player.mp;
                player.atk  += GenericJob.atkArray[player.level];
                player.mag  += GenericJob.magArray[player.level];
                player.str  += GenericJob.strArray[player.level];
                player.inte += GenericJob.inteArray[player.level];
                player.def  += GenericJob.defArray[player.level];
                player.mdef += GenericJob.mdefArray[player.level];
                player.agi  += GenericJob.agiArray[player.level];
                player.luck += GenericJob.luckArray[player.level];
            }
            else
            {
            }



            player.playerAbilities.Clear();//Clears and removes all of the players abilities and then readds all abilities the player should have unlocked at their current level
            foreach (iAbility ability in player.characterJob.jobsAbilities.Values)
            {
                if (player.level >= ability.level)
                {
                    player.playerAbilities.Add(ability.name, ability);
                }
            }
            ConsoleSpecificTextDisplay.displayLevelUpText();
        }
コード例 #7
0
        }                                //Turns to true once the job is set


        public void characterCreation()// Main method for creating the character
        {
            //Initializes the bool values signaling a new character
            charCreated   = false;
            jobUnassigned = true;
            nameSet       = false;
            jobSet        = false;

            writeCharCreationSB("Welcome to a new game. Please type in your name\n" +
                                "-Your name may only contain up to 12 characters\n\n"); //Writes the text for setting a character name
            while (nameSet == false)                                                    //If the character has not set a valid name the game will keep replaying this part of the code
            {
                player.name = Console.ReadLine();                                       //Allows the player to enter a name
                if (player.name.Length < 13)                                            // then checks the length on the name and if it is under 13 characters
                {
                    nameSet = true;                                                     // set the name to the character
                }
            }
            writeCharCreationSB("Welcome " + player.name + " you have a great journey ahead of you.\n"
                                + "But first, what is your profesion?\n");//Asks the player to choose a job
            writeCharCreationSB("CHOICES: Warrior\n"
                                + "         Cleric\n"
                                + "         Wizard"); //Shows the player the jobs they can pick
            while (jobSet == false)                   //Sets teh players job and keeps trying while the player is not assigned a job
            {
                player.job = Console.ReadLine();      //Gets the player input for which job they would like to use for their main character
                switch (player.job.ToUpper())
                {
                case "WARRIOR":                          //If player input is warrior
                    player.characterJob = new Warrior(); //Sets the player job to warrior
                    jobSet = true;                       //and sets the jobset trigger to true
                    break;

                case "CLERIC":                          //If player input is cleric
                    player.characterJob = new Cleric(); //sets the player job to cleric
                    jobSet = true;                      //and sets the jobset trigger to true
                    break;

                case "WIZARD":                          //If player input is wizard
                    player.characterJob = new Wizard(); //sets the player job to wizard
                    jobSet = true;                      //and sets the jobset trigger to true
                    break;

                default:            //If the player input doesnt match any option this is the default
                    jobSet = false; //Sets tje jobset trigger to false
                    break;
                }
            }
            createCharacter();//Calls the character creations method

            writeCharCreationSB("\n\nWelcome to the game " + PlayerCharacter.theCharacter.name
                                + "\nYour Stats are as follows:\n"); //Writes the welcome message to the player
            ConsoleSpecificTextDisplay.displayCharacterStats();      //Writes the character stats to the screen
            writeCharCreationSB("\nYour abilities are:\n");
            foreach (iAbility ability in PlayerCharacter.theCharacter.playerAbilities.Values)
            {
                writeCharCreationSB(ability.name + "\n");//Writes all the characters abilities to the screen
            }
            //Writes the obtained items and equipment to the game screen
            writeCharCreationSB("Here is your item and equipment starter pack:\n" +
                                "ITEMS:\n");
            ObtainItemorEquipment.obtainItem("Potion", 5);
            ObtainItemorEquipment.obtainItem("Antidote", 5);
            ObtainItemorEquipment.obtainItem("Ether", 5);
            writeCharCreationSB("EQUIPMENT:");
            ObtainItemorEquipment.obtainEquipment("Iron Ring", 1);
            ObtainItemorEquipment.obtainEquipment("Iron Helmet", 1);
            ObtainItemorEquipment.obtainEquipment("Iron Breastplate", 1);
        }