Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        // Set animation and exchange text when the Player is within the distance
        if (Vector3.Distance(transform.position, player.transform.position) <= distance)
        {
            anim.SetTrigger("merchantPop");
            withinDistance = true;
            if (merchantOpen)
            {
                ShowExchangeText();
            }
        }
        else
        {
            withinDistance   = false;
            exchange.enabled = false;
        }

        // Exchange a feather for health on correct input
        if (Input.GetButtonDown("Fire2") && exchange.enabled == true && hd.GetCurHealth() < hd.GetMaxHealth())
        {
            if (p.GetFeathers() > 0)
            {
                p.changeFeathers(-1);
                hp.GainHealth(1);
            }
        }
    }
Exemple #2
0
 // save the player's stats
 void SavePrefs()
 {
     PlayerPrefs.SetInt("MaxHealth", hd.GetMaxHealth());
     PlayerPrefs.SetInt("Health", hd.GetCurHealth());
     PlayerPrefs.SetInt("Feathers", feathers);
 }