Beispiel #1
0
    //Use tags for different objects to make a difference. (so that for example fire will do zone damage, but medicine box pickup
    //will refill health in an instance.

    //Trigger collider:
    //For zone damage (runs every frame and damages/heals player when inside trigger zone (eg. fire, radiation field, etc)
    void OnTriggerStay(Collider other)
    {
        if (other.transform.tag == "Player")
        {
            healthbar.SendMessage("ModifyHealth", health, SendMessageOptions.DontRequireReceiver);
        }
    }
Beispiel #2
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     //al entrar en contacto con el objeto que tenga Tag de "Item", el cofre recibirá Daño
     if (other.gameObject.tag == "ITEM")
     {
         Vidacofre.SendMessage("TakeDamage", 10);
     }
 }
Beispiel #3
0
    void TakeDamage(float dmg)
    {
        if (dead)
        {
            return;
        }

        // decrease our health
        curHealth -= dmg;

        // send the message to the health bar to update
        healthBar.SendMessage("UpdateBar", (curHealth / maxHealth * 100.0f));

        // flash our character red
        StartCoroutine(colorDamage());

        // if we're not knocked down already knock the player down
        if (!anim.GetBool("Knocked Down"))
        {
            StartCoroutine(knockDown(knockDownDuration));
        }
    }
Beispiel #4
0
    IEnumerator showDamageDelay(float s)
    {
        yield return(new WaitForSeconds(s));

        dmgBar.SendMessage("UpdateBar", pct);
    }