private void PotionManagement() { if (!Player.InFountain() && !Player.HasBuff("Recall")) { if (ManaPotion.IsReady() && !Player.HasBuff("FlaskOfCrystalWater")) { if (Player.CountEnemiesInRange(1200) > 0 && Player.Mana < 200) { ManaPotion.Cast(); } } if (Player.HasBuff("RegenerationPotion") || Player.HasBuff("ItemMiniRegenPotion") || Player.HasBuff("ItemCrystalFlask")) { return; } if (Flask.IsReady()) { if (Player.CountEnemiesInRange(700) > 0 && Player.Health + 200 < Player.MaxHealth) { Flask.Cast(); } else if (Player.Health < Player.MaxHealth * 0.6) { Flask.Cast(); } else if (Player.CountEnemiesInRange(1200) > 0 && Player.Mana < 200 && !Player.HasBuff("FlaskOfCrystalWater")) { Flask.Cast(); } return; } if (Potion.IsReady()) { if (Player.CountEnemiesInRange(700) > 0 && Player.Health + 200 < Player.MaxHealth) { Potion.Cast(); } else if (Player.Health < Player.MaxHealth * 0.6) { Potion.Cast(); } return; } if (Biscuit.IsReady()) { if (Player.CountEnemiesInRange(700) > 0 && Player.Health + 200 < Player.MaxHealth) { Biscuit.Cast(); } else if (Player.Health < Player.MaxHealth * 0.6) { Biscuit.Cast(); } return; } } }
private void Update() { if (Input.GetKeyDown(KeyCode.V)) //debug { Bag bag = (Bag)Instantiate(items[0]); bag.Initialize(16); bag.Use(); } if (Input.GetKeyDown(KeyCode.C)) //debug { Bag bag = (Bag)Instantiate(items[0]); bag.Initialize(16); AddItem(bag); } if (Input.GetKeyDown(KeyCode.H)) //debug { HealthPotion potion = (HealthPotion)Instantiate(items[1]); AddItem(potion); } if (Input.GetKeyDown(KeyCode.Y)) //debug { ManaPotion potion = (ManaPotion)Instantiate(items[2]); AddItem(potion); } }
public void ManaPotionUnitTest() { OutputHelper.Display.ClearUserOutput(); Player player = new Player("test", PlayerClassType.Mage) { MaxManaPoints = 100, ManaPoints = 10, Inventory = new List <IItem> { new ManaPotion(PotionStrength.Minor) } }; int potionIndex = player.Inventory.FindIndex(f => f.GetType() == typeof(ManaPotion)); string[] input = new[] { "drink", "mana" }; string potionName = InputHelper.ParseInput(input); Assert.AreEqual("mana", potionName); int? baseMana = player.ManaPoints; ManaPotion potion = player.Inventory[potionIndex] as ManaPotion; int manaAmount = potion.ManaAmount; player.AttemptDrinkPotion(InputHelper.ParseInput(input)); string drankManaString = $"You drank a potion and replenished {manaAmount} mana."; Assert.AreEqual(drankManaString, OutputHelper.Display.Output[0][2]); Assert.AreEqual(baseMana + manaAmount, player.ManaPoints); Assert.IsEmpty(player.Inventory); player.AttemptDrinkPotion(InputHelper.ParseInput(input)); Assert.AreEqual("What potion did you want to drink?", OutputHelper.Display.Output[1][2]); }
public void recreateFighterItem(int x, int y, int i){ Item item; if(PlayerPrefs.GetString("Fighter Item type" + i) == "ManaPotion"){ item = new ManaPotion(); inventory.addItem(x,y,item, inventorySlots, inventoryItems); } else if(PlayerPrefs.GetString("Fighter Item type" + i) == "HealthPotion"){ item = new HealthPotion(); inventory.addItem(x,y,item, inventorySlots, inventoryItems); } else if(PlayerPrefs.GetString("Fighter Item type" + i) == "Axe"){ item = new Axe(); inventory.addItem(x,y,item, inventorySlots, inventoryItems); } else if(PlayerPrefs.GetString( "Fighter Item type" + i) == "Ring"){ item = new Ring(); inventory.addItem(x,y,item, inventorySlots, inventoryItems); } else if(PlayerPrefs.GetString("Fighter Item type" + i) == "Chest"){ item = new Chest(); inventory.addItem(x,y,item, inventorySlots, inventoryItems); } else if(PlayerPrefs.GetString("Fighter Item type" + i) == "Boots"){ item = new Boots(); inventory.addItem(x,y,item, inventorySlots, inventoryItems); } else if(PlayerPrefs.GetString("Fighter Item type" + i) == "Amulet"){ item = new Amulet(); inventory.addItem(x,y,item, inventorySlots, inventoryItems); } else if(PlayerPrefs.GetString( "Fighter Item type" + i) == "Sword"){ item = new Sword(); inventory.addItem(x,y,item, inventorySlots, inventoryItems); } }
public void Setup() { potion = new ManaPotion(PotionStrength.Minor); player = new Player("test", PlayerClassType.Mage) { Inventory = new List <IItem>() }; }
public void GreaterPotionCreationTest() { potion = new ManaPotion(PotionStrength.Greater); Assert.AreEqual("greater mana potion", potion.Name); Assert.AreEqual("A greater mana potion that restores 150 mana.", potion.Desc); Assert.AreEqual(150, potion.ManaAmount); Assert.AreEqual(75, potion.ItemValue); }
public void NormalPotionCreationTest() { potion = new ManaPotion(PotionStrength.Normal); Assert.AreEqual("mana potion", potion.Name); Assert.AreEqual("A mana potion that restores 100 mana.", potion.Desc); Assert.AreEqual(100, potion.ManaAmount); Assert.AreEqual(50, potion.ItemValue); }
public void MinorPotionCreationTest() { potion = new ManaPotion(PotionStrength.Minor); Assert.AreEqual("minor mana potion", potion.Name); Assert.AreEqual("A minor mana potion that restores 50 mana.", potion.Desc); Assert.AreEqual(50, potion.ManaAmount); Assert.AreEqual(25, potion.ItemValue); }
public void CannotAddGiantManaPotion() { PotionPack pp = new PotionPack("Small potion sack", 2, 4); ManaPotion mana = new ManaPotion("GIANT Mana Potion", 10); bool expected = false; bool actual = pp.Add(mana); Assert.AreEqual(expected, actual); }
public void CanAddPotion() { PotionPack pp = new PotionPack("Small potion sack", 2, 4); ManaPotion mana = new ManaPotion("Small Mana Potion", 1); bool expected = true; bool actual = pp.Add(mana); Assert.AreEqual(expected, actual); }
public void PlayerDrinkPotionPartialManaTest() { potion = new ManaPotion(PotionStrength.Greater); // Greater mana potion restores 150 mana player.Inventory.Add(potion); player.MaxManaPoints = 200; player.ManaPoints = 100; potion.DrinkPotion(player); Assert.AreEqual(player.MaxManaPoints, player.ManaPoints); }
public void PlayerDrinkPotionFullManaTest() { potion = new ManaPotion(PotionStrength.Greater); // Greater mana potion restores 150 mana player.Inventory.Add(potion); player.MaxManaPoints = 200; player.ManaPoints = 25; int?oldPlayerMana = player.ManaPoints; potion.DrinkPotion(player); Assert.AreEqual(oldPlayerMana + potion.ManaAmount, player.ManaPoints); }
public static void Use() { if (Me.IsCasting) { Spell.StopCasting(); } Utils.LagSleep(); WoWItem manaPotion = ManaPotion; Utils.Log(string.Format("We're having an 'Oh Shit' moment. Using {0}", manaPotion.Name), Utils.Colour("Red")); ManaPotion.Interact(); }
void recreateItem(){ if(selectedItem == healthIndex){ sell[selectedItem] = new HealthPotion(); } else if(selectedItem == manaIndex){ sell[selectedItem] = new ManaPotion(); } else if(selectedItem == amuletIndex){ sell[selectedItem] = new Amulet(); } else if(selectedItem == ringIndex){ sell[selectedItem] = new Ring(); } }
private static IMapObject GetObjectByChar(char c, int y, int x) { var position = new Vector2(x + 0.5f, y + 0.5f); return(c switch { 'R' => (IMapObject)Rat.Create(ResourceCachedLoader.Instance, position, 0), 'S' => Skeleton.Create(ResourceCachedLoader.Instance, position, 0), 'L' => Lich.Create(ResourceCachedLoader.Instance, position, 0), 'H' => HealingPotion.Create(position), 'M' => ManaPotion.Create(position), 'A' => ArrowPack.Create(position), 'D' => Ded.Create(position), _ => null });
public Player() { AttackMessages = new string[] { "You thrash at the", "You fiercly lunge at the", "You tighten your grip and swing at the" }; GreetMessages = new string[] { "You begin your quest to defeat the DragonLord", "You embark on your journey to slay the Dragonlord", "Good luck on your journey" }; DeathMessages = new string[] { "You are dead, not a big surprise", "You fall over dead", "You crumble down to the floor and breathe your last", "You died" }; Attack = 2; AttackChance = 40; Awareness = 13; Color = Colors.Player; Defense = 1; DefenseChance = 15; Gold = 50; Health = 20; MaxHealth = 20; Mana = 10; MaxMana = 10; Name = "Novice"; Speed = 10; Level = 1; MaxLevel = 16; Experience = 8; TotalExperience = 0; Hunger = 1000; MaxHunger = 1200; Symbol = '@'; Status = "Healthy"; Inventory = new Inventory(this); Inventory.AddInventoryItem(new FoodRation(2)); QAbility = new DoNothing(); WAbility = new DoNothing(); EAbility = new DoNothing(); RAbility = new DoNothing(); XAbility = new Look(); HPRegen = new RegainHP(1, 10); MPRegen = new RegainMP(1, 20); State = new DoNothing(); Item1 = new HealingPotion(); Item2 = new ManaPotion(); Item3 = new ToughnessPotion(); Item4 = new TeleportScroll(); }
public void SellManaPotion() { var manaPotion = new ManaPotion(); manaPotion.sprite = manaPotionSprite; if (Player.Instance.gold >= ManaPotionPrice) { Player.Instance.AddPotion(manaPotion); Player.Instance.gold -= ManaPotionPrice; Debug.Log("Gold Count: " + Player.Instance.gold); } else { Debug.Log("Not enough gold."); } }
public void UnitUseItem(string itemName) { // TODO: add some defence... gameBoard.HideIndicatorPlanes(); if (ACTION_READY) { // Disable unit MOVE_REMAINING and IS_ACTIVE MOVE_REMAINING = false; ACTION_READY = false; gameBoard.entityMenu.SetAttackMenu(); // Remove item from player inventory (only here, for own player...) gameBoard.PLAYER_INVENTORY.Remove(itemName); // Do item stuff switch (itemName) { case "Health Potion": gameBoard.effectDisplayer.CreatePopupText(HealthPotion.UseHealthPotion(this).ToString() , new Vector3(transform.position.x, gameBoard.TileArray[(int)transform.position.x, (int)transform.position.z].tile_elevation + 1f, transform.position.z) , Color.green); break; case "Mana Potion": gameBoard.effectDisplayer.CreatePopupText(ManaPotion.UseManaPotion(this).ToString() , new Vector3(transform.position.x, gameBoard.TileArray[(int)transform.position.x, (int)transform.position.z].tile_elevation + 1f, transform.position.z) , Color.blue); break; } // Refresh selected entity gameBoard.RefreshSelectedEntity(); // GOTO next turn gameBoard.turnManager.CoroutineAdvanceTurn(entityName + " UnitUseItem"); gameBoard.turnManager.SetTurnProcessingFalse(entityName + " UnitUseItem"); ACTION_PROCESSING = false; } }
void recreateItem(){ if(selectedItem == healthIndex){ sell[selectedItem] = new HealthPotion(); } else if(selectedItem == manaIndex){ sell[selectedItem] = new ManaPotion(); } else if(selectedItem == swordIndex){ sell[selectedItem] = new Sword(); } else if(selectedItem == axeIndex){ sell[selectedItem] = new Axe(); } else if(selectedItem == chestIndex){ sell[selectedItem] = new Chest(); } else if(selectedItem == bootsIndex){ sell[selectedItem] = new Boots(); } }
public bool Add(Item item) { if (!CanBeAdded(item)) { return(false); } if (item is HealthPotion) { if (HealthPotion == null) { HealthPotion = new HealthPotion(null) { Parent = Game1.Player }; } else { ++HealthPotion.Count; } } else if (item is ManaPotion) { if (ManaPotion == null) { ManaPotion = new ManaPotion(null) { Parent = Game1.Player }; } else { ++ManaPotion.Count; } } else { items.Add(item); } return(true); }
public override void OnDoubleClick(Mobile from) { BagOfReagents regBag = new BagOfReagents(50); Item[] items = new Item[] { new FlamestrikeScroll(25), new LightningScroll(25), new GreaterHealScroll(10), new MagicReflectScroll(10), new Bandage(80) }; foreach (Item i in items) { i.Weight = 0.01; regBag.DropItem(i); } Point3D itemLocation = Point3D.Zero; for (int i = 0; i < 40; ++i) { GreaterHealPotion hp = new GreaterHealPotion(); ManaPotion mana = new ManaPotion(); regBag.DropItem(hp); regBag.DropItem(mana); if (i == 0) { itemLocation = hp.Location; mana.Location = itemLocation; } else { hp.Location = itemLocation; mana.Location = itemLocation; } } if (!from.AddToBackpack(regBag)) { regBag.Delete(); } }
AConsommable <TModuleType> GenerateConsommable(e_consommableProbability consommable) { AConsommable <TModuleType> consommableGenerated = null; switch (consommable) { case e_consommableProbability.Life_Potion: consommableGenerated = new LifePotion <TModuleType>(); break; case e_consommableProbability.Mana_Potion: consommableGenerated = new ManaPotion <TModuleType>(); break; case e_consommableProbability.Life_Food: consommableGenerated = new LifeFood <TModuleType>(); break; case e_consommableProbability.Mana_Food: consommableGenerated = new ManaFood <TModuleType>(); break; case e_consommableProbability.Life_And_Mana_Food: consommableGenerated = new LifeAndManaFood <TModuleType>(); break; case e_consommableProbability.Life_And_Mana_Potion: consommableGenerated = new LifeAndManaPotion <TModuleType>(); break; default: break; } return(consommableGenerated); }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "Player" && type == "bag" && InventoryScript.MyInstance.CanAddBag) { Bag bag = (Bag)Instantiate(InventoryScript.MyInstance.MyItems[0]); bag.Initialize(16); bag.Use(); Destroy(gameObject); } if (collision.tag == "Player" && type == "health" && !InventoryScript.MyInstance.BagsEmpty) { HealthPotion potion = (HealthPotion)Instantiate(InventoryScript.MyInstance.MyItems[1]); InventoryScript.MyInstance.AddItem(potion); Destroy(gameObject); } if (collision.tag == "Player" && type == "mana" && !InventoryScript.MyInstance.BagsEmpty) { ManaPotion potion = (ManaPotion)Instantiate(InventoryScript.MyInstance.MyItems[2]); InventoryScript.MyInstance.AddItem(potion); Destroy(gameObject); } }
public override void OnDoubleClick( Mobile from ) { BagOfReagents regBag = new BagOfReagents( 50 ); Item[] items = new Item[] { new FlamestrikeScroll( 25 ), new LightningScroll( 25 ), new GreaterHealScroll( 10 ), new MagicReflectScroll( 10 ), new Bandage( 80 ) }; foreach( Item i in items ) { i.Weight = 0.01; regBag.DropItem( i ); } Point3D itemLocation = Point3D.Zero; for( int i = 0; i < 40; ++i ) { GreaterHealPotion hp = new GreaterHealPotion(); ManaPotion mana = new ManaPotion(); regBag.DropItem( hp ); regBag.DropItem( mana ); if( i == 0 ) { itemLocation = hp.Location; mana.Location = itemLocation; } else { hp.Location = itemLocation; mana.Location = itemLocation; } } if( !from.AddToBackpack( regBag ) ) regBag.Delete(); }
public Shop() { this.Icon = new Icon(@"Images\MaxMana.ico"); ListBox buyListbox = new ListBox() { Height = 100, Left = 10, ScrollAlwaysVisible = true, Top = 10, Width = 160 }; // Fill buyListbox with sellable items string healthPrice = new HealthPotion().Price.ToString(); string manaPrice = new ManaPotion().Price.ToString(); string hiPrice = new HiPotion().Price.ToString(); string bronzeWPrice = new BronzeSword().Price.ToString(); string bronzeAPrice = new BronzeArmour().Price.ToString(); string glassAPrice = new GlassArmour().Price.ToString(); string chopstickPrice = new ChopStick().Price.ToString(); buyListbox.Items.Add("Health Potion\t- £" + healthPrice); buyListbox.Items.Add("Mana Potion\t- £" + manaPrice); buyListbox.Items.Add("Hi Potion\t\t- £" + hiPrice); buyListbox.Items.Add("Bronze Sword\t- £" + bronzeWPrice); buyListbox.Items.Add("Bronze Armour\t- £" + bronzeAPrice); buyListbox.Items.Add("Glass Armour\t- £" + glassAPrice); buyListbox.Items.Add("ChopStick\t- £" + chopstickPrice); this.Controls.Add(buyListbox); CustomButton buyButton = new CustomButton(CustomButtonType.Buy) { Height = 40, Left = 10, Text = "BUY", Top = 110, Width = 100 }; buyButton.Click += (sender, args) => { if (buyListbox.SelectedItem.ToString() == "Health Potion\t- £" + healthPrice) { HealthPotion item = new HealthPotion(); if (World.character.Gold >= item.Price) { World.character.Items.Add(item); World.character.Gold -= item.Price; MessageBox.Show(string.Format("Item bought: {0}", item.Name)); } else { //Messagebox MessageBox.Show("STOP RIGHT THERE, CRIMINAL SCUM!\nI choose you Debt Collector."); Battle battleForm = new Forms.Battle("Debt Collector", Image.FromFile("Images/Monsters/DebtCollector.png"), item); battleForm.Show(); this.Close(); } } else if (buyListbox.SelectedItem.ToString() == "Mana Potion\t- £" + manaPrice) { ManaPotion item = new ManaPotion(); if (World.character.Gold >= item.Price) { World.character.Items.Add(item); World.character.Gold -= item.Price; MessageBox.Show(string.Format("Item bought: {0}", item.Name)); } else { //Messagebox MessageBox.Show("STOP RIGHT THERE, CRIMINAL SCUM!\nI choose you Debt Collector."); Battle battleForm = new Forms.Battle("Debt Collector", Image.FromFile("Images/Monsters/DebtCollector.png"), item); battleForm.Show(); this.Close(); } } else if (buyListbox.SelectedItem.ToString() == "Hi Potion\t\t- £" + hiPrice) { HiPotion item = new HiPotion(); if (World.character.Gold >= item.Price) { World.character.Items.Add(item); World.character.Gold -= item.Price; MessageBox.Show(string.Format("Item bought: {0}", item.Name)); } else { //Messagebox MessageBox.Show("STOP RIGHT THERE, CRIMINAL SCUM!\nI choose you Debt Collector."); Battle battleForm = new Forms.Battle("Debt Collector", Image.FromFile("Images/Monsters/DebtCollector.png"), item); battleForm.Show(); this.Close(); } } else if (buyListbox.SelectedItem.ToString() == "Bronze Sword\t- £" + bronzeWPrice) { BronzeSword item = new BronzeSword(); if (World.character.Gold >= item.Price) { World.character.Items.Add(item); World.character.Gold -= item.Price; MessageBox.Show(string.Format("Item bought: {0}", item.Name)); } else { //Messagebox MessageBox.Show("STOP RIGHT THERE, CRIMINAL SCUM!\nI choose you Debt Collector."); Battle battleForm = new Forms.Battle("Debt Collector", Image.FromFile("Images/Monsters/DebtCollector.png"), item); battleForm.Show(); this.Close(); } } else if (buyListbox.SelectedItem.ToString() == "Bronze Armour\t- £" + bronzeAPrice) { BronzeArmour item = new BronzeArmour(); if (World.character.Gold >= item.Price) { World.character.Items.Add(item); World.character.Gold -= item.Price; MessageBox.Show(string.Format("Item bought: {0}", item.Name)); } else { //Messagebox MessageBox.Show("STOP RIGHT THERE, CRIMINAL SCUM!\nI choose you Debt Collector."); Battle battleForm = new Forms.Battle("Debt Collector", Image.FromFile("Images/Monsters/DebtCollector.png"), item); battleForm.Show(); this.Close(); } } else if (buyListbox.SelectedItem.ToString() == "Glass Armour\t- £" + glassAPrice) { GlassArmour item = new GlassArmour(); if (World.character.Gold >= item.Price) { World.character.Items.Add(item); World.character.Gold -= item.Price; MessageBox.Show(string.Format("Item bought: {0}", item.Name)); } else { //Messagebox MessageBox.Show("STOP RIGHT THERE, CRIMINAL SCUM!\nI choose you Debt Collector."); Battle battleForm = new Forms.Battle("Debt Collector", Image.FromFile("Images/Monsters/DebtCollector.png"), item); battleForm.Show(); this.Close(); } } else if (buyListbox.SelectedItem.ToString() == "ChopStick\t- £" + chopstickPrice) { ChopStick item = new ChopStick(); if (World.character.Gold >= item.Price) { World.character.Items.Add(item); World.character.Gold -= item.Price; MessageBox.Show(string.Format("Item bought: {0}", item.Name)); } else { //Messagebox MessageBox.Show("STOP RIGHT THERE, CRIMINAL SCUM!\nI choose you Debt Collector."); Battle battleForm = new Forms.Battle("Debt Collector", Image.FromFile("Images/Monsters/DebtCollector.png"), item); battleForm.Show(); this.Close(); } } }; this.Controls.Add(buyButton); ListBox sellListbox = new ListBox() { Height = 100, Left = 180, ScrollAlwaysVisible = true, Top = 10, Width = 100 }; // Fill sellListbox with player items this.Controls.Add(sellListbox); CustomButton sellButton = new CustomButton(CustomButtonType.Sell) { Height = 40, Left = 180, Text = "SELL", Top = 110, Width = 100 }; sellButton.Click += (sender, args) => { switch (sellListbox.SelectedItem.ToString()) { case "Health Potion": { // Remove item from character inventory // Add gold to character break; } case "Mana Potion": { // Remove item from player inventory // Add gold to character break; } } }; this.Controls.Add(sellButton); }
public override void Update() { base.Update(); ShowPlayerInformation(); counter++; animationOn.Start(); if (GetWorld().GetActors().Find(a => a.GetName() == "enemy") == null) { world = GetWorld(); world.SetEndCondition(world => MapStatus.Finished); } if (GetHealth() == 0) { Die(); } if (myState == false) { animationOn.Stop(); world = GetWorld(); world.SetEndCondition(world => MapStatus.Failed); } else { if (Input.GetInstance().IsKeyPressed(Input.Key.LEFT)) { if (side == false) { animationOn.FlipAnimation(); side = true; } } else if (Input.GetInstance().IsKeyPressed(Input.Key.RIGHT)) { if (side == true) { animationOn.FlipAnimation(); side = false; } } else if (Input.GetInstance().IsKeyDown(Input.Key.SPACE) && Input.GetInstance().IsKeyDown(Input.Key.LEFT) && bunnyHop > 0) { SetPhysics(false); foreach (Command command in jumpLeft) { command.Execute(); } bunnyHop--; } else if (Input.GetInstance().IsKeyDown(Input.Key.SPACE) && Input.GetInstance().IsKeyDown(Input.Key.RIGHT) && bunnyHop > 0) { SetPhysics(false); foreach (Command command in jumpRight) { command.Execute(); } bunnyHop--; } else if (Input.GetInstance().IsKeyDown(Input.Key.LEFT)) { SetPhysics(true); moveLeft.Execute(); } else if (Input.GetInstance().IsKeyDown(Input.Key.RIGHT)) { SetPhysics(true); moveRight.Execute(); } else if (Input.GetInstance().IsKeyDown(Input.Key.UP) && bunnyHop > 0) { SetPhysics(false); jump.Execute(); bunnyHop--; } else if (Input.GetInstance().IsKeyPressed(Input.Key.E)) { backpack.ShiftRight(); } else if (Input.GetInstance().IsKeyPressed(Input.Key.Q)) { backpack.ShiftLeft(); } else if (Input.GetInstance().IsKeyDown(Input.Key.F)) { potion = backpack.GetItem(); if (potion is HealingPotion) { healingPotion = (HealingPotion)potion; healingPotion.Use(this); } else if (potion is ManaPotion) { manaPotion = (ManaPotion)potion; manaPotion.Use(this); } else if (potion is SpeedPotion) { speedPotion = (SpeedPotion)potion; speedPotion.Use(this); speedCounter = 1; } else if (potion is JumpPotion) { jumpPotion = (JumpPotion)potion; jumpPotion.Use(this); jumpCounter = 1; } } else if (Input.GetInstance().IsKeyPressed(Input.Key.R)) { backpack.RemoveItem(backpack.GetCapacity() - position); position++; } else { SetPhysics(true); animationOn.Stop(); } if (bunnyHop < 20) { if (counter % 120 == 0) { bunnyHop = 20; } } if (jumpCounter > 0) { jumpCounter++; if (jumpCounter == jumpPotion.GetDuration()) { SetJump(3); jumpCounter = 0; } } if (speedCounter > 0) { speedCounter++; if (speedCounter == speedPotion.GetDuration()) { this.SetSpeedStrategy(speedStrategy); speedCounter = 0; } } } }
public static void ShowInventory(Player player) { OutputHelper.Display.StoreUserOutput( Settings.FormatInfoText(), Settings.FormatDefaultBackground(), "Your inventory contains:"); TextInfo textInfo = new CultureInfo("en-US", false).TextInfo; foreach (IItem item in player.Inventory) { if (!(item is IEquipment equippableItem && equippableItem.Equipped)) { continue; } string itemName = GearHelper.GetItemDetails(item); StringBuilder itemInfo = new StringBuilder(itemName); if (itemName.Contains("Quiver")) { itemInfo.Append($" (Arrows: {player.PlayerQuiver.Quantity}/{player.PlayerQuiver.MaxQuantity})"); } itemInfo.Append(" <_Equipped>"); if (item is Armor || item is Weapon) { IRainbowGear playerItem = item as IRainbowGear; if (playerItem.IsRainbowGear) { GearHelper.StoreRainbowGearOutput(itemInfo.ToString()); continue; } } OutputHelper.Display.StoreUserOutput( Settings.FormatInfoText(), Settings.FormatDefaultBackground(), itemInfo.ToString()); } foreach (IItem item in player.Inventory) { if (item is IEquipment equippableItem && equippableItem.Equipped) { continue; } string itemName = GearHelper.GetItemDetails(item); StringBuilder itemInfo = new StringBuilder(itemName); if (player.PlayerQuiver?.Name == itemName) { itemInfo.Append($"Arrows: {player.PlayerQuiver.Quantity}/{player.PlayerQuiver.MaxQuantity}"); } if (item is Armor || item is Weapon) { IRainbowGear playerItem = item as IRainbowGear; if (playerItem.IsRainbowGear) { GearHelper.StoreRainbowGearOutput(itemInfo.ToString()); continue; } } OutputHelper.Display.StoreUserOutput( Settings.FormatInfoText(), Settings.FormatDefaultBackground(), itemInfo.ToString()); } Dictionary <string, int> consumableDict = new Dictionary <string, int>(); foreach (IItem item in player.Inventory) { StringBuilder itemInfo = new StringBuilder(); itemInfo.Append(item.Name); if (item.Name.Contains("potion")) { if (item is HealthPotion) { HealthPotion potion = item as HealthPotion; itemInfo.Append($" (+{potion.HealthAmount} health)"); } if (item is ManaPotion) { ManaPotion potion = item as ManaPotion; itemInfo.Append($" (+{potion.ManaAmount} mana)"); } if (item is StatPotion) { StatPotion potion = item as StatPotion; itemInfo.Append($" (+{potion.StatAmount} {potion.StatPotionType})"); } } if (item.GetType() == typeof(Arrows)) { Arrows arrows = item as Arrows; itemInfo.Append($" ({arrows.Quantity})"); } string itemName = textInfo.ToTitleCase(itemInfo.ToString()); if (!consumableDict.ContainsKey(itemName)) { consumableDict.Add(itemName, 1); continue; } int dictValue = consumableDict[itemName]; dictValue += 1; consumableDict[itemName] = dictValue; } foreach (KeyValuePair <string, int> consumable in consumableDict) { string Inventorytring = $"{consumable.Key} (Quantity: {consumable.Value})"; OutputHelper.Display.StoreUserOutput( Settings.FormatInfoText(), Settings.FormatDefaultBackground(), Inventorytring); } string goldString = $"_Gold: {player.Gold} coins."; OutputHelper.Display.StoreUserOutput( Settings.FormatInfoText(), Settings.FormatDefaultBackground(), goldString); string weightString = $"_Weight: {GetInventoryWeight(player)}/{player.MaxCarryWeight}"; OutputHelper.Display.StoreUserOutput( Settings.FormatInfoText(), Settings.FormatDefaultBackground(), weightString); }