Ejemplo n.º 1
0
 private void Update()
 {
     if (dMG != null)
     {
         if (dMG.isunderImpact)
         {
             if (unihog.IsFacingRight())
             {
                 chackRay(Vector3.right);
             }
             else
             {
                 chackRay(Vector3.left);
             }
         }
         else
         {
             chackRay(Vector3.right);
             Debug.DrawRay(startPos.position, startPos.TransformDirection(Vector3.right) * 0.5f, Color.red);
         }
     }
     else
     {
         return;
     }
 }
Ejemplo n.º 2
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        if (unihog.kicking)
        {
            if (collision.gameObject.tag == "Player")
            {
                // print("hit");
                if (collision.GetComponent <PlayerStats>() != null)
                {
                    print("detected player");
                    if (!attack)
                    {
                        print("attack");
                        if (unihog.IsFacingRight())
                        {
                            print("excuted attack");
                            attack = true;
                            collision.GetComponent <PlayerStats>().TakeDmg(dmg, Vector3.left);
                            unihog.kicking = false;
                            Invoke("resetAttack", 0.5f);

                            isunderImpact = true;
                        }
                        else if (!unihog.IsFacingRight())
                        {
                            attack = true;
                            collision.GetComponent <PlayerStats>().TakeDmg(dmg, Vector3.right);
                            Invoke("resetAttack", 0.5f);
                            unihog.kicking = false;
                            isunderImpact  = true;
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 3
0
    private void OnTriggerExit2D(Collider2D collision)
    {
        if (unihog.attacking)
        {
            if (collision.gameObject.tag == "Player")
            {
                // print("hit");
                if (collision.GetComponent <PlayerStats>() != null)
                {
                    if (!attack)
                    {
                        if (unihog.IsFacingRight())
                        {
                            attack = true;
                            collision.GetComponent <PlayerStats>().TakeDmg(dmg, Vector3.left);
                            Invoke("resetAttack", 0.5f);
                            impact = unihog.rb2d.DOJump((transform.position - Vector3.right * force), jumpForce, 0, 0.5f);
                            impact.SetEase(Ease.Flash);
                            impact.SetUpdate(UpdateType.Fixed);
                            isunderImpact   = true;
                            unihog.isFlying = true;
                        }
                        else if (!unihog.IsFacingRight())
                        {
                            attack = true;
                            collision.GetComponent <PlayerStats>().TakeDmg(dmg, Vector3.right);
                            Invoke("resetAttack", 0.5f);
                            impact = unihog.rb2d.DOJump((transform.position - Vector3.left * force), jumpForce, 0, 0.5f);
                            impact.SetEase(Ease.Flash);
                            impact.SetUpdate(UpdateType.Fixed);
                            isunderImpact   = true;
                            unihog.isFlying = true;
                        }
                    }

                    if (collision.GetComponent <PlayerStats>().ParryWindow)
                    {
                        if (!isunderImpact)
                        {
                            // print("Parry");
                            if (unihog.IsFacingRight())
                            {
                                // print("Right");
                                impact = unihog.rb2d.DOJump((transform.position - Vector3.right * force), jumpForce, 0, 0.5f);
                                impact.SetEase(Ease.Flash);
                                impact.SetUpdate(UpdateType.Fixed);
                                isunderImpact   = true;
                                unihog.isFlying = true;
                            }
                            else if (!unihog.IsFacingRight())
                            {
                                // print("left");
                                impact = unihog.rb2d.DOJump((transform.position - Vector3.left * force), jumpForce, 0, 0.5f);
                                impact.SetEase(Ease.Flash);
                                impact.SetUpdate(UpdateType.Fixed);
                                isunderImpact   = true;
                                unihog.isFlying = true;
                            }
                        }
                    }
                }
            }
        }
    }