void AliceDrinkPotion() { animController.SetTrigger("Xforming"); string potionType = potion.potionType; potion.Consume(); Hallucinate(); log.text = "Drank " + potionType; switch (potionType) { case "grow": AliceChangeSize(SCALE_BIG, FOV_BIG); break; case "normal": AliceChangeSize(SCALE_NORMAL, FOV_NORMAL); break; case "shrink_half": keyIcon.enabled = true; AliceChangeSize(SCALE_HALF, FOV_HALF); break; case "shrink_tiny": AliceChangeSize(SCALE_TINY, FOV_TINY); break; default: break; } }
static void Main(string[] args) { Potion potion_of_undying = new Potion(1, "@", "Potion of undying", "Potion crafted from the Devil's soul", 25); Inventory.inventory.Add(potion_of_undying); // Consume all potions from inventory foreach (var item in Inventory.inventory) { Potion potion = item as Potion; if (potion != null) { potion.Consume(); } } System.Console.WriteLine(Player.Health); }
/// <summary> /// Consume an item of type Consumable that has an effect on character with the given ID /// </summary> /// <param name="id"></param> /// <param name="itemName"></param> public async Task ConsumeItem(string id, string itemName) { using (var dbContext = ApplicationDbContext.Create()) { var character = await Task.Run(() => dbContext.Characters.SingleOrDefault(c => c.UserId == id)); var inventory = character.Inventory.ToList(); Potion item = await Task.Run(() => (Potion)inventory.FirstOrDefault(w => w.Name == itemName)); if (item != null) { item.Consume(character); inventory.Remove(item); await Task.Run(() => dbContext.Items.Remove(dbContext.Items.Find(item.ItemId))); } await dbContext.SaveChangesAsync(); } }
// Update is called once per frame void Update() { if (PauseMenu.paused || saveMenu.activeSelf) { return; } if (!playerController) { playerController = GetComponent <PlayerController>(); } bool primaryAttackButtonDown = false; bool secondaryAttackButtonDown = false; if (Mathf.Abs(Input.GetAxisRaw("Fire1")) > 0 && !primaryAttackButton) { primaryAttackButtonDown = true; } if (Mathf.Abs(Input.GetAxisRaw("Fire2")) > 0 && !secondaryAttackButton) { secondaryAttackButtonDown = true; } //if(Mathf.Abs(Input.GetAxisRaw(""))) handleWeaponSwitching(); if (Mathf.Abs(Input.GetAxisRaw("Fire1")) > 0) { primaryAttackButton = true; } else { primaryAttackButton = false; } if (Mathf.Abs(Input.GetAxisRaw("Fire2")) > 0) { secondaryAttackButton = true; } else { secondaryAttackButton = false; } if (secondaryAttackButtonDown) { Debug.Log(primaryAttackButton + " " + secondaryAttackButtonDown); } if (items.Count > 0 && items != null) { playerQuestSystem.UpdateCurrentQuestsAmountDone(items); } if (!health.isAlive()) { Die(); } //bool primaryAttack = Input.GetMouseButtonDown(0); //bool secondaryAttack = secondaryAttackButton; if (primaryAttackButtonDown && CurrentWeapon != null && playerController.playerCanMove) { CurrentWeapon.Attack(playerController.DirectionFacing); } //if (Input.GetMouseButton(0)) //{ // primaryAttack = true; //} if (secondaryAttackButtonDown && CurrentWeapon != null && playerController.playerCanMove) { CurrentWeapon.AttackSecondary(playerController.DirectionFacing, primaryAttackButton); } if (Input.GetKeyDown(KeyCode.E)) { if (items[potion] > 0) { potion.Consume(this); items[potion]--; } } }