示例#1
0
    void OnCollisionEnter2D(Collision2D coll)
    {
        if (coll.gameObject.tag == "InstaKill")
        {
            Die();
        }
        else if (coll.gameObject.tag == "Enemy")
        {
            totalDamage = totalDamage + 1;
            liveBar.Damage(totalDamage);

            if (totalDamage == MainPlayerHP)
            {
                Die();
            }
        }
    }
示例#2
0
    // Use this for initialization
    void Start()
    {
        //the cklass with the main player animations
        AnimationClass = GetComponent <MainPlayerAnimations>();

        var DamageBar = GameObject.FindGameObjectsWithTag("LiveBar");

        //rigid body control
        rigid = GetComponent <Rigidbody2D>();

        DamageBarAnimation = DamageBar[0];
        liveBar            = DamageBarAnimation.GetComponent("MainPlayerLiveBar") as MainPlayerLiveBar;


        liveBar.Damage(totalDamage);
    }