private void Update()
    {
        hpBar.fillAmount = health / maxHealth;

        if (health <= 0 && !dead)
        {
            dead                      = true;
            player.health            += hpRewardOnDeath;
            player.levelThreeComplete = true;
            effect.EmmitBubbles(this.transform.position, 200);
            exitText.enabled = true;
            exit.SetActive(true);
            Destroy(this.gameObject, 0.1f);
        }
    }
 private void OnTriggerStay2D(Collider2D e)
 {
     if (e.tag == "Player")
     {
         if (Input.GetButtonDown("Use") && lootable && !looted)
         {
             effect.EmmitBubbles(e.transform.position, 50);
             player.health          += stashRewardInHealth;
             player.levelOneComplete = true;
             looted = true;
             claimRewardPrompt.enabled = false;
         }
     }
 }
Beispiel #3
0
    private void OnTriggerStay2D(Collider2D c)
    {
        if (c.tag == "Player" && spawner.levelComplete && !looted)
        {
            if (Input.GetButtonDown("Use"))
            {
                rewardPrompt.enabled = false;
                looted = true;
                effect.EmmitBubbles(c.transform.position, 50);
                player.health          += stashRewardInHealth;
                player.levelTwoComplete = true;

                this.GetComponent <SpriteRenderer>().sprite = doorOpened;
                this.GetComponent <BoxCollider2D>().enabled = false;
            }
        }
    }
Beispiel #4
0
    public virtual void Update()
    {
        if (player == null)
        {
            player           = GameObject.FindGameObjectWithTag("Player").transform;
            playerController = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();
        }

        if (this.currentHealth <= 0 && !dead)
        {
            dead = true;
            this.GetComponent <AudioSource>().Play();
            playerController.AddHealth(reward);
            var bubbleAmount = (int)Mathf.Ceil(maxHealth / 4);
            effect.EmmitBubbles(this.transform.position, bubbleAmount);
            Destroy(this.gameObject, 0.1f);
        }
    }