Beispiel #1
0
 public void Execute()
 {
     if (game.shopBalance >= game.itemPrices[game.currentShopItem])
     {
         ItemShopState.displayError = false;
         System.Diagnostics.Debug.WriteLine("purchase item: " + game.currentShopItem + "\n cost: " + game.itemPrices[game.currentShopItem]);
         game.shopBalance           -= game.itemPrices[game.currentShopItem];
         game.Link.Inventory.Rupees -= (int)game.itemPrices[game.currentShopItem];
         if (game.currentShopItem == "sword")
         {
             WhiteSword newSword = new WhiteSword();
             newSword.Collect(this.game.Link);
         }
         else if (game.currentShopItem == "heart")
         {
             Heart newheart = new Heart();
             newheart.Collect(this.game.Link);
         }
         else
         {
             this.game.Link.Inventory.HasBluePotion = true;
         }
         System.Diagnostics.Debug.WriteLine("new balance: " + game.shopBalance);
     }
     else
     {
         ItemShopState.displayError = true;
         System.Diagnostics.Debug.WriteLine("Insufficient funds. Please find more rupees by killing enemies.");
     }
 }
Beispiel #2
0
        public IList <IItem> LoadItems(IDictionary <int, IPlayer> players)
        {
            List <IItem> items = new List <IItem>();
            IDictionary <Vector2, string> itemInfo = parser.Items;

            foreach (KeyValuePair <Vector2, String> entry in itemInfo)
            {
                IItem item;
                if (entry.Value.Equals("Arrow"))
                {
                    item = new Arrow();
                }
                else if (entry.Value.Equals("BlueCandle"))
                {
                    item = new BlueCandle();
                }
                else if (entry.Value.Equals("BluePotion"))
                {
                    item = new BluePotion();
                }
                else if (entry.Value.Equals("BlueRing"))
                {
                    item = new BlueRing(players);
                }
                else if (entry.Value.Equals("BlueRupee"))
                {
                    item = new BlueRupee();
                }
                else if (entry.Value.Equals("Bomb"))
                {
                    item = new Bomb();
                }
                else if (entry.Value.Equals("Bow"))
                {
                    item = new Bow();
                }
                else if (entry.Value.Equals("Boomerang"))
                {
                    item = new Boomerang();
                }
                else if (entry.Value.Equals("Clock"))
                {
                    item = new Clock(players);
                }
                else if (entry.Value.Equals("Compass"))
                {
                    item = new Compass();
                }
                else if (entry.Value.Equals("Fairy"))
                {
                    item = new Fairy();
                }
                else if (entry.Value.Equals("Heart"))
                {
                    item = new Heart();
                }
                else if (entry.Value.Equals("HeartContainer"))
                {
                    item = new HeartContainer();
                }
                else if (entry.Value.Equals("Key"))
                {
                    item = new Key();
                }
                else if (entry.Value.Equals("Map"))
                {
                    item = new Map();
                }
                else if (entry.Value.Equals("Rupee"))
                {
                    item = new Rupee();
                }
                else if (entry.Value.Equals("TriforceShard"))
                {
                    item = new TriforceShard(game);
                }
                else if (entry.Value.Equals("RedRing"))
                {
                    item = new RedRing(players);
                }
                else if (entry.Value.Equals("RedPotion"))
                {
                    item = new RedPotion();
                }
                else if (entry.Value.Equals("WhiteSword"))
                {
                    item = new WhiteSword();
                }
                else //wood sword
                {
                    item = new WoodSword();
                }
                item.X = (int)entry.Key.X;
                item.Y = 120 + (int)entry.Key.Y;
                items.Add(item);
            }
            return(items);
        }