コード例 #1
0
 private void Collider_OnOverlapBegin(Physics2DComponent thisComponent, Physics2DComponent otherComponent)
 {
     if (otherComponent.Owner is Ball ball)
     {
         ball.MovementDirection = ball.Collider.Location - Collider.Location;
     }
 }
コード例 #2
0
        private void EdgeOverlapBegin(Physics2DComponent thisComponent, Physics2DComponent otherComponent)
        {
            if (otherComponent.Owner is Ball ball)
            {
                if (thisComponent.Owner == LeftEdge)
                {
                    Goal?.Invoke(ESide.Right);
                    return;
                }

                if (thisComponent.Owner == RightEdge)
                {
                    Goal?.Invoke(ESide.Left);
                    return;
                }

                if (thisComponent.Owner == TopEdge)
                {
                    ball.MovementDirection = VSEMath.MirrorPoint(ball.MovementDirection, Vector2.UnitY) * -1;
                    return;
                }

                if (thisComponent.Owner == BottomEdge)
                {
                    ball.MovementDirection = VSEMath.MirrorPoint(ball.MovementDirection, Vector2.UnitY) * -1;
                    return;
                }
            }
        }