コード例 #1
0
    private void CheckCollisions()
    {
        Rect playerRect = collider.GetRect();

        var enemies = FindObjectsOfType <Enemy>();

        foreach (Enemy enemy in enemies)
        {
            Rect r2 = enemy.collider.GetRect();
            if (RectsCollided(playerRect, r2))
            {
                SetDamage();
            }
        }
        if (RectsCollided(playerRect, boss.collider.GetRect()) && boss.isActiveAndEnabled)
        {
            SetDamage();
        }
        if (ball.fly && Input.GetButtonDown("Fire1") &&
            _ballCathcTime.IsComplete() &&
            RectsCollided(playerRect, ball.catchCollider.GetRect()))
        {
            CatchBall();
        }
        if (ball.fly && !_ball && RectsCollided(playerRect, ball.collider.GetRect()))
        {
            SetBallHit();
        }
    }
コード例 #2
0
    private void CheckCollisions()
    {
        Rect bossRect = collider.GetRect();

        if (ball.fly && _damageDelay.IsComplete() && RectsCollided(bossRect, ball.collider.GetRect()))
        {
            SetDamage();
        }
    }