Пример #1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.CompareTag("Player"))
        {
            if (inBounds == true && collision.gameObject.GetComponent <SDController>().inBounds == true)
            {
                bothInBounds = true;
            }

            if (collision.gameObject.GetComponent <SDController>().fallen == false)
            {
                collidingPlayer    = collision.gameObject.GetComponent <SDController>();
                isContactingPlayer = true;
            }
        }

        if (collision.gameObject.CompareTag("Team 2"))
        {
            if (goingFast)
            {
                source.PlayOneShot(hit);

                AIBehavior ai = collision.gameObject.GetComponent <AIBehavior>();
                ai.StartCoroutine(ai.isHit());

                if (stabilizer != null)
                {
                    StopCoroutine(stabilizer);
                }

                if (canBeHit)
                {
                    hitNumber++;
                }

                if (hitNumber == SDOptions.hitsToFall)
                {
                    StartCoroutine(Fall());
                }
                else
                {
                    stabilizer = StartCoroutine(reStabilize());
                }
            }
        }

        if (collision.gameObject.CompareTag("Untagged"))
        {
            StartCoroutine(Fall());
        }
    }