Beispiel #1
0
 void OnCollisionEnter2D(Collision2D collider)
 {
     if (collider.gameObject.tag == "Player")
     {
         var source = collider.gameObject.GetComponent <AudioSource>();
         source.clip = clip;
         source.Play();
         if (artifact != null)
         {
             artifact.Activate();
         }
         var stats = collider.gameObject.GetComponent <PlayerStats>();
         stats.money += money;
         if (maxHealth)
         {
             stats.maxHealth += health;
         }
         stats.IncreaseHealth(health);
         Destroy(gameObject);
     }
 }
Beispiel #2
0
 public void RegisterHit(int damage)
 {
     Debug.Log("daamaged" + artifact);
     if (canBeHit())
     {
         if (statusP != null)
         {
             statusP.hit(damage);
             anim?.SetState(AnimState.Hit);
             AudioManager.Instance.Play("playerHit");
             if (statusP.getHealth() <= 0)
             {
                 // Game Over, Player has died
                 AudioManager.Instance.Play("lose");
                 SceneManager.LoadScene(SceneManager.GetActiveScene().name);
             }
         }
         else if (statusE != null)
         {
             statusE.hit(damage);
             if (statusE.getHealth() <= 0)
             {
                 Destroy(this.transform.parent.gameObject);
                 CurrencyController.Instance.GainCurrency(200);
             }
         }
         else if (artifact != null)
         {
             artifact.Activate();
         }
         else
         {
             // Something is wrong
             print("oof");
         }
     }
 }