public void Regenerate(float regenerationValue, Potion.PotionType potType) { switch (potType) { case Potion.PotionType.HEALTH: this.health = Mathf.Clamp(health + regenerationValue, 0f, this.maxHealth); Companion tComp = this.gameObject.GetComponent <Companion>(); if (tComp != null) { HeaderUI headerUI = CanvasScript.instance.headerUI.GetComponent <HeaderUI>(); RectTransform rTransform = headerUI.companionFills[tComp.id].rectTransform; float lackAmount = 1 - this.health / this.maxHealth; headerUI.companionFills[tComp.id].transform.localPosition = new Vector3(-122.42f * lackAmount * 0.5f, 0.0f, 0.0f); rTransform.sizeDelta = new Vector2(122.42f * (1 - lackAmount), rTransform.sizeDelta.y); headerUI.companionIcons[tComp.id].sprite = tComp.actorIcon; } else if (this == Character.instance) { HeaderUI headerUI = CanvasScript.instance.headerUI.GetComponent <HeaderUI>(); RectTransform rTransform = headerUI.actorFill.rectTransform; float lackAmount = 1 - this.health / this.maxHealth; headerUI.actorFill.transform.localPosition = new Vector3(-122.42f * lackAmount * 0.5f, 0.0f, 0.0f); rTransform.sizeDelta = new Vector2(122.42f * (1 - lackAmount), rTransform.sizeDelta.y); headerUI.actorIcon.sprite = Character.instance.actorIcon; if (CanvasScript.instance.characterPanel.activeInHierarchy) { CanvasScript.instance.characterPanel.GetComponent <CharacterStats>().health.text = "Health: " + this.health; } } break; case Potion.PotionType.MANA: break; case Potion.PotionType.STAMINA: break; default: break; } }
public void CreatePotion(Potion.PotionType potionType, Vector2 position, bool putInBag) { Items.Add(new Potion(new Spritesheet("potionSheet", new Point(0, 0), new Rectangle(0, 0, 1, 1)), position, new Rectangle(1, 1, 1, 1), putInBag, potionType)); }
public PotionEssentials(Potion.PotionType type, float regen) { potType = type; regenValue = regen; }