Beispiel #1
0
        public static void purchasedPotion(item1 _val)//adds a purchased potion to the players potions
        {
            int tmp = 0;

            for (int i = 0; i < 10; i++)
            {
                if (playerInvent2[i].name != null)
                {
                    tmp++;
                    //ticks up a tmp array until a blank item is found in the potions array
                }
            }
            playerInvent2[tmp] = _val;
            //sets that item to the one that wasw bought
            int count = 0;

            using (StreamWriter sw = new StreamWriter("plPotions.csv"))
            {
                while (playerInvent2[count].type == "Potion")
                {
                    sw.WriteLine($"{count + 1},{playerInvent2[count].name},{playerInvent2[count].type},{playerInvent2[count].attack}, {playerInvent2[count].cost}");

                    //adds the updated array to the player potions file
                    count++;
                }
                sw.Close();//closes the text file
            }
        }
Beispiel #2
0
        public static void purchasedWeapon(item1 _val)//method to add the bought weapon to player inventory(weapon)
        {
            int tmp = 0;

            for (int i = 0; i < 10; i++)
            {
                if (playerInvent1[i].name != null)
                {
                    tmp++;
                    //ticks up a tmp int until an empty item in the weapons array is found
                }
            }
            //sets that item to the one bought
            playerInvent1[tmp] = _val;

            int count = 0;

            using (StreamWriter sw = new StreamWriter("plWeapons.csv"))
            {
                while (playerInvent1[count].type == "Weapon")
                {
                    sw.WriteLine($"{count + 1},{playerInvent1[count].name},{playerInvent1[count].type},{playerInvent1[count].attack}, {playerInvent1[count].cost}");
                    //writes the updated players weapons to the wepaon file

                    count++;
                }
                sw.Close();//closes the text file
            }
        }