private void CompleteTransaction(Interfaces.IItem newItem, int coinsSpent) { int newCoinsAmount = this.Coins.Amount - coinsSpent; this.Coins = new Items.Coins(newCoinsAmount); Toolbar.SystemMsg.Instance.AllMessages.Add(new Dictionary <string, Color>() { { String.Format(">> You bought {0}.", newItem.Name), Color.DarkGoldenrod } }); if (newItem.ToString().Contains("Weapon")) { GameScreen.Instance.WeaponBought.Play(); } else if (newItem.ToString().Contains("Armor")) { GameScreen.Instance.ArmorBought.Play(); } else if (newItem.ToString().Contains("ElixirsHP")) { GameScreen.Instance.ElixirBought.Play(); } }
public void BuyItem(Interfaces.IItem newItem, int coinsSpent) { if (coinsSpent <= this.Coins.Amount) { if (newItem.ToString().Contains("Elixir")) { CompleteTransaction(newItem, coinsSpent); this.Elixirs = (Items.ElixirsHP)newItem; } else if (newItem.ToString().Contains("Boots")) { if (this.Boots != null) { Toolbar.SystemMsg.Instance.AllMessages.Add(new Dictionary <string, Color>() { { String.Format(">> First destroy your Boots!"), Color.Red } }); } else { CompleteTransaction(newItem, coinsSpent); this.Boots = (Interfaces.IBoots)newItem; } } else if (newItem.ToString().Contains("Gloves")) { if (this.Gloves != null) { Toolbar.SystemMsg.Instance.AllMessages.Add(new Dictionary <string, Color>() { { String.Format(">> First destroy your Gloves!"), Color.Red } }); } else { CompleteTransaction(newItem, coinsSpent); this.Gloves = (Interfaces.IGloves)newItem; } } else if (newItem.ToString().Contains("Helmet")) { if (this.Helmet != null) { Toolbar.SystemMsg.Instance.AllMessages.Add(new Dictionary <string, Color>() { { String.Format(">> First destroy your Helmet!"), Color.Red } }); } else { CompleteTransaction(newItem, coinsSpent); this.Helmet = (Interfaces.IHelmet)newItem; } } else if (newItem.ToString().Contains("Robe")) { if (this.Robe != null) { Toolbar.SystemMsg.Instance.AllMessages.Add(new Dictionary <string, Color>() { { String.Format(">> First destroy your Robe!"), Color.Red } }); } else { CompleteTransaction(newItem, coinsSpent); this.Robe = (Interfaces.IRobe)newItem; } } else if (newItem.ToString().Contains("Shield")) { if (this.Shield != null) { Toolbar.SystemMsg.Instance.AllMessages.Add(new Dictionary <string, Color>() { { String.Format(">> First destroy your Shield!"), Color.Red } }); } else { CompleteTransaction(newItem, coinsSpent); this.Shield = (Interfaces.IShield)newItem; } } else if (newItem.ToString().Contains("Weapon")) { if (this.Weapon != null) { Toolbar.SystemMsg.Instance.AllMessages.Add(new Dictionary <string, Color>() { { String.Format(">> First destroy your Weapon!"), Color.Red } }); } else { CompleteTransaction(newItem, coinsSpent); this.Weapon = (Interfaces.IWeapon)newItem; } } } else { Toolbar.SystemMsg.Instance.AllMessages.Add(new Dictionary <string, Color>() { { ">> Not enough coins.", Color.Red } }); } }