Beispiel #1
0
    private void OnTriggerEnter2D(Collider2D col)
    {
        if (col.transform.tag == "Player")
        {
            pC = col.GetComponent <PlayerController>();
            fC = col.GetComponentInChildren <FightingController>();
            if (pC.health > 0)
            {
                if (lowAttack == true && fC.lowBlocking == true)
                {
                    pC.health -= damage / 4;
                    pC.updateHealthSlider();
                }
                if (fC.lowBlocking == false && lowAttack == false)
                {
                    pC.knockBack(-knockBackPower);
                    pC.health -= damage;
                    pC.stopSpecial();
                    bloodEffect();
                    pC.updateHealthSlider();
                }
                if (fC.lowBlocking == true && lowAttack == false)
                {
                    pC.knockBack(-knockBackPower);
                    pC.health -= damage;
                    pC.stopSpecial();
                    bloodEffect();
                    pC.updateHealthSlider();
                }

                else if (lowAttack == true && fC.lowBlocking == false)
                {
                    pC.knockBack(-knockBackPower);
                    pC.health -= damage;
                    pC.stopSpecial();
                    bloodEffect();
                    pC.updateHealthSlider();
                }
                if (pC.health <= 0)
                {
                    if (dieNinja == false)
                    {
                        pC.Die(0);
                    }
                    if (dieNinja == true)
                    {
                        pC.Die(1);
                    }

                    gM.DisplayWinner(1);
                    gM.shutItDown(1);
                }
            }
        }
        if (col.transform.tag == "Player2")
        {
            pC = col.GetComponent <PlayerController>();
            fC = col.GetComponentInChildren <FightingController>();
            if (pC.health > 0)
            {
                if (lowAttack == true && fC.lowBlocking == true)
                {
                    pC.health -= damage / 4;
                    pC.updateHealthSlider();
                }
                if (fC.lowBlocking == false && lowAttack == false)
                {
                    pC.knockBack(knockBackPower);
                    pC.health -= damage;
                    pC.stopSpecial();
                    bloodEffect();
                    pC.updateHealthSlider();
                }
                if (fC.lowBlocking == true && lowAttack == false)
                {
                    pC.knockBack(knockBackPower);
                    pC.health -= damage;
                    pC.stopSpecial();
                    bloodEffect();
                    pC.updateHealthSlider();
                }

                else if (lowAttack == true && fC.lowBlocking == false)
                {
                    pC.knockBack(knockBackPower);
                    pC.health -= damage;
                    pC.stopSpecial();
                    bloodEffect();
                    pC.updateHealthSlider();
                }
                if (pC.health <= 0)
                {
                    if (dieNinja == false)
                    {
                        pC.Die(0);
                    }
                    if (dieNinja == true)
                    {
                        pC.Die(1);
                    }
                    gM.DisplayWinner(0);
                    gM.shutItDown(0);
                }
            }
        }
    }
Beispiel #2
0
 private void Awake()
 {
     ParentRB           = transform.parent.GetComponent <Rigidbody2D>();
     rb                 = GetComponent <Rigidbody2D>();
     fightingController = GameObject.Find("Player").GetComponent <FightingController>();
 }