Exemplo n.º 1
0
        // Name, [Attack]/[Defense] Value, Price, Description
        public Shopkeeper()                                                                                                  // Will be used to call for items
        {
            // Populate the weapon list and puts in a temp variable and puts it in an array
            temp = new AttackItem("Great Sword", 50, 800, "This is a Great Sword...");
            shopInv.Add(temp);
            temp = new AttackItem("Sword", 25, 300, "This is a Sword...");
            shopInv.Add(temp);
            temp = new AttackItem("Dagger", 20, 250, "This is a Dagger...");
            shopInv.Add(temp);
            temp = new AttackItem("Spear", 30, 350, "This is a Spear...");
            shopInv.Add(temp);
            temp = new AttackItem("Bow", 25, 300, "This is a Bow...");
            shopInv.Add(temp);
            temp = new AttackItem("Whip", 15, 200, "This is a Whip...");
            shopInv.Add(temp);

            // Populate the armor list and puts in a temp variable and puts it in an array
            temp = new DefenseItem("Leather Armor", 15, 100, "This is a Leather Armor ...");
            shopInv.Add(temp);
            temp = new DefenseItem("Chain Armor", 20, 300, "This is a Chain Armor ...");
            shopInv.Add(temp);
            temp = new DefenseItem("Iron Armor", 30, 750, "This is a Iron Armor ...");
            shopInv.Add(temp);
            temp = new DefenseItem("Cloth Armor", 5, 50, "This is a Cloth Armor ...");
            shopInv.Add(temp);
            temp = new DefenseItem("Dragon Armor", 100, 5000, "This is a Dragon Armor ...");
            shopInv.Add(temp);
            temp = new DefenseItem("Bronze Armor", 25, 500, "This is a Bronze Armor ...");
            shopInv.Add(temp);
        }
Exemplo n.º 2
0
 public void Add(AllItem item)
 {
     // Create a new array if Length + 1
     AllItem[] newAllItem = new AllItem[_item.Length + 1];
     // Put the values of the old array into the new one
     for (int i = 0; i < _item.Length; i++)
     {
         newAllItem[i] = _item[i];
     }
     // Put the new value at the end of the new array
     newAllItem[newAllItem.Length - 1] = item;
     // Sets the current array to the new array
     _item = newAllItem;
 }
Exemplo n.º 3
0
        public void PlayerLoad(string playerInventorySave, Inventory inventory, Player player)
        {
            if (File.Exists(playerInventorySave))
            {   // Create a (shopSave & playerSave) object for the file at our path
                AllItem newitem;
                string  temp;
                string  name;
                int     stat;
                int     cost;
                string  desc;
                bool    loading = true;

                Clear();
                StreamReader playerSaveLoad = File.OpenText(playerInventorySave);
                player.getDatMoney = Convert.ToInt32(playerSaveLoad.ReadLine());
                player._potionHeld = Convert.ToInt32(playerSaveLoad.ReadLine());
                while (loading)
                {
                    loading = false;
                    temp    = playerSaveLoad.ReadLine();
                    if (temp != null)
                    {
                        loading = true;
                        name    = (playerSaveLoad.ReadLine());
                        stat    = Convert.ToInt32(playerSaveLoad.ReadLine());
                        cost    = Convert.ToInt32(playerSaveLoad.ReadLine());
                        desc    = (playerSaveLoad.ReadLine());
                        if (temp == "Weapon")
                        {
                            newitem = new AttackItem(name, stat, cost, desc);
                        }
                        else if (temp == "Armor")
                        {
                            newitem = new DefenseItem(name, stat, cost, desc);
                        }
                        else
                        {
                            newitem = new AllItem();
                        }
                        Add(newitem);
                    }
                }
                playerSaveLoad.Close();
                Console.WriteLine("Player File Loaded.");
            }
            else
            {
                Console.WriteLine("Save File not found.");
            }
        }
Exemplo n.º 4
0
        public virtual void Remove(int index)
        {
            // Create a new array if Length - 1
            AllItem[] newAllItem  = new AllItem[_item.Length - 1];
            int       newPosition = 0;                                                      // Puts it into the new position (newlist array and list array)

            // Put the values of the old array into the new array
            for (int i = 0; i < _item.Length; i++)
            {
                if (i != index)
                {
                    newAllItem[newPosition] = _item[i];
                    newPosition++;
                }
            }
            //Set the current array to the new array
            _item = newAllItem;
        }
Exemplo n.º 5
0
 public bool SellingItem(int index, Player player)
 {
     if (index < shopInv.GetLength() && index >= 0)
     {
         AllItem temp = shopInv[index];
         if (player.getDatMoney /* watchItBurn */ < temp.Cost)
         {
             // If the Player doesn't have enough funds, tell player you cannot and nothing happens.
             temp.Print();
             return(false);
         }
         //player buys item (create BUY function which will be your logic for buying (lose money giving item ect.  (PLAYER BUYING FROM Shopkeeper))
         Console.WriteLine("You have sucessfully bought " + temp.Name + " from the shop.");
         player.getDatMoney -= temp.Cost;
         getShopMoney       += temp.Cost;
         shopInv.Remove(index);
         player.Add(temp);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 6
0
        // The SuperUser Command Function
        public void SuperAdmin(Player player)
        {
            AllItem item     = new AllItem();
            string  choice   = "";
            string  itemname = "";
            string  itemDesc = "";
            int     itemstat;
            int     itemcost;

            Console.WriteLine("Debug Mode Activated\n");
            while (choice != "home")
            {
                int debug = 0;
                Console.WriteLine("Debug Mode (Active)");
                Console.WriteLine("additem, modifygold, home");
                choice = Console.ReadLine();
                if (choice == "additem")
                {
                    while (choice != "back")
                    {
                        Console.WriteLine("weapon, armor, back");
                        choice = Console.ReadLine();
                        if (choice == "weapon")
                        {
                            Console.WriteLine("\nGive the new item a name.");
                            itemname = Console.ReadLine();
                            Console.WriteLine("\nGive the new item an Attack stat.");
                            itemstat = Convert.ToInt32(Console.ReadLine());
                            while (itemstat < 0)
                            {
                                Console.WriteLine("No negative item damage boy. Try Again.");
                                itemstat = Convert.ToInt32(Console.ReadLine());
                            }
                            Console.WriteLine("\nGive the new item a price.");
                            itemcost = Convert.ToInt32(Console.ReadLine());
                            while (itemcost < 0)
                            {
                                Console.WriteLine("No negative item cost boy. Try Again.");
                                itemcost = Convert.ToInt32(Console.ReadLine());
                            }
                            Console.WriteLine("\nGive the new item a description.");
                            itemDesc = Console.ReadLine();

                            Console.WriteLine("Your new item has been added to the shop.\n");
                            Console.ReadKey();

                            item = new AttackItem(itemname, itemstat, itemcost, itemDesc);
                            shopInv.Add(item);
                            choice = "back";
                        }
                        else if (choice == "armor")
                        {
                            Console.WriteLine("\nGive the new item a name.");
                            itemname = Console.ReadLine();
                            Console.WriteLine("\nGive the new item an Defense stat.");
                            itemstat = Convert.ToInt32(Console.ReadLine());
                            while (itemstat < 0)
                            {
                                Console.WriteLine("No negative item defense boy. Try Again.");
                                itemstat = Convert.ToInt32(Console.ReadLine());
                            }
                            Console.WriteLine("\nGive the new item a price.");
                            itemcost = Convert.ToInt32(Console.ReadLine());
                            while (itemcost < 0)
                            {
                                Console.WriteLine("No negative item cost boy.");
                            }
                            Console.WriteLine("\nGive the new item a description.");
                            itemDesc = Console.ReadLine();

                            Console.WriteLine("Your new item has been added to the shop.\n");
                            Console.ReadKey();

                            item = new DefenseItem(itemname, itemstat, itemcost, itemDesc);
                            shopInv.Add(item);
                            choice = "back";
                        }
                        else if (choice == "home")
                        {
                        }
                    }
                }
                else if (choice == "modifygold")
                {
                    Console.WriteLine("How much player gold will you add/remove?");
                    debug = Convert.ToInt32(Console.ReadLine());
                    player.getDatMoney += debug;
                    Console.WriteLine("You have given yourself " + debug + " gold.");
                    if (player.getDatMoney <= 0)
                    {
                        Console.WriteLine("Money set automatically to zero.");
                        player.getDatMoney = 0;
                    }
                    Console.WriteLine(" ");
                }
                else if (choice == "home")
                {
                    Console.WriteLine("Now returning to main menu.\n");
                }
            }
        }
Exemplo n.º 7
0
 public void Add(AllItem toAnyInv)
 {
     shopInv.Add(toAnyInv);
 }
Exemplo n.º 8
0
 public void Add(AllItem toPlayerInv)
 {
     playerInv.Add(toPlayerInv);
 }