Ejemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        playerInfo = GameObject.FindGameObjectWithTag("GameData").GetComponent <PlayerInfo>();
        foreach (Slider slider in gameObject.GetComponentsInChildren <Slider>())
        {
            if (slider.name == "HealthBar")
            {
                HP = slider;
            }
            else if (slider.name == "ManaBar")
            {
                Mana = slider;
            }
            else if (slider.name == "StaminaBar")
            {
                Stamina = slider;
            }
        }

        playerInfo.AddHp(100);
        HP.maxValue      = playerInfo.GetMaxHp();
        HP.value         = playerInfo.GetHp();
        Mana.maxValue    = playerInfo.GetMaxMana();
        Mana.value       = playerInfo.GetMana();
        Stamina.maxValue = playerInfo.GetMaxStamina();
        Stamina.value    = playerInfo.GetStamina();
    }
 private void OnTriggerStay2D(Collider2D collision)
 {
     if (collision.tag == "PlayerDamageCollision" && EnemyAnimator.GetBool("Attack") && !OnlyOnce)
     {
         playerInfo.AddHp(-10);
         OnlyOnce = true;
     }
 }
Ejemplo n.º 3
0
 public void Use()
 {
     dragAndDrop = ItemUI.gameObject.GetComponent <DragAndDrop>();
     if (item.type == ItemType.Food)
     {
         FoodObject food = (FoodObject)item;
         playerInfo.AddHp(food.HealthRestore);
         playerInfo.AddMana(food.ManaRestore);
         playerInfo.AddStanima(food.HungerRestore);
         dragAndDrop.IfSetSlotsOccupied(false, false);
         inventoryData.RemoveItem(item);
         Destroy(ItemUI.gameObject);
         Debug.Log("Used");
         Destroy(gameObject);
     }
 }