Esempio n. 1
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Ball") && _isJoiningPossible)
        {
            BallBehavior otherBall = other.GetComponent <BallBehavior>();

            if (this.MassOfBall > otherBall.MassOfBall)
            {
                JoinBalls(otherBall);
            }
            else if (this.MassOfBall < otherBall.MassOfBall)
            {
                DeactivateBall(this);
            }
            else
            {
                if (this.GetInstanceID() > otherBall.GetInstanceID())
                {
                    JoinBalls(otherBall);
                }
                else
                {
                    DeactivateBall(this);
                }
            }
        }
    }