コード例 #1
0
ファイル: ButtonEat.cs プロジェクト: Rachellie/Crecipe
    public void EatFood()
    {
        Transform onHead = GameObject.FindWithTag("Player").transform.GetChild(2);

        onHead.SetParent(null, true);
        StartCoroutine(Slerp(onHead));

        FoodObject toEat = PlayerData.player.GetCurrentFood();

        PlayerData.player.SetHappiness(PlayerData.player.GetHappiness() + toEat.getHappiness());
        if (toEat.getHappiness() > 0)
        {
            PlayerData.player.SetXP(PlayerData.player.GetXP() + toEat.getHappiness());
        }

        toEat.subOneQ();

        if (toEat.getQuantity() <= 0)
        {
            toEat = null;
        }

        PlayerData.player.SetCurrentFood(toEat);
    }