コード例 #1
0
        public async override void UseFeature(CircleObject circle)
        {
            circle.ChangeBoolCanMove(false);
            await Task.Delay(3000);

            circle.ChangeBoolCanMove(true);
        }
コード例 #2
0
ファイル: MathExt.cs プロジェクト: lk14kirill/Aero-Hockey
 public static bool IsVectorBiggerThenWindowY(CircleObject circle, Vector2u window)
 {
     if (circle.GetCenter().Y - circle.GetRadius() > GetPercentOf(window.Y, 50))
     {
         return(true);
     }
     return(false);
 }
コード例 #3
0
ファイル: MathExt.cs プロジェクト: lk14kirill/Aero-Hockey
        public static Vector2f CheckForIntersectAndDetectDirection(CircleObject firstCircle, CircleObject secondCircle)      //Ricochets first circle
        {
            double distanceBetweenRadiuses = VectorLength(secondCircle.GetCenter(), firstCircle.GetCenter());;

            if (distanceBetweenRadiuses <= firstCircle.GetRadius() + secondCircle.GetRadius())
            {
                return(DetectSide(firstCircle, secondCircle));
            }
            return(new Vector2f(0, 0));
        }
コード例 #4
0
ファイル: MathExt.cs プロジェクト: lk14kirill/Aero-Hockey
        public static bool CheckForIntersect(CircleObject firstCircle, CircleObject secondCircle)     //Ricochets first circle
        {
            double distanceBetweenRadiuses = VectorLength(secondCircle.GetCenter(), firstCircle.GetCenter());;

            if (distanceBetweenRadiuses <= firstCircle.GetRadius() + secondCircle.GetRadius())
            {
                return(true);
            }
            return(false);
        }
コード例 #5
0
ファイル: Game.cs プロジェクト: lk14kirill/Aero-Hockey
 public void CheckCircleOnCollisionWithItemsAndUseFeature(CircleObject circle, Vector2u window)
 {
     foreach (CircleItem item in circleItems)
     {
         if (MathExt.CheckForIntersect(item, circle))
         {
             item.UseFeature(circle);
             item.ChangePosition(item.RandomSpawn(window));
         }
     }
 }
コード例 #6
0
 public abstract void UseFeature(CircleObject circle);
コード例 #7
0
ファイル: MathExt.cs プロジェクト: lk14kirill/Aero-Hockey
        private static Vector2f DetectSide(CircleObject racket, CircleObject ball)
        {
            Vector2f centreOfRadiuses = new Vector2f((racket.GetCenter().X + ball.GetCenter().X) / 2,
                                                     (racket.GetCenter().Y + ball.GetCenter().Y) / 2);

            if (centreOfRadiuses.X > racket.GetCenter().X&&
                centreOfRadiuses.X < racket.GetCenter().X + racket.GetRadius() - 10 &&
                centreOfRadiuses.Y > racket.GetCenter().Y&&                                //checks for intersect on upLeft
                centreOfRadiuses.Y < racket.GetCenter().Y + racket.GetRadius() - 10)
            {
                return(Vector2Directions.downRight);
            }
            if (centreOfRadiuses.X > racket.GetCenter().X&&
                centreOfRadiuses.X < racket.GetCenter().X + racket.GetRadius() - 10 &&
                centreOfRadiuses.Y < racket.GetCenter().Y&&                                     //checks for intersect on downLeft
                centreOfRadiuses.Y > racket.GetCenter().Y - racket.GetRadius() + 10)
            {
                return(Vector2Directions.upRight);
            }
            if (centreOfRadiuses.X < racket.GetCenter().X&&
                centreOfRadiuses.X > racket.GetCenter().X - racket.GetRadius() + 10 &&
                centreOfRadiuses.Y < racket.GetCenter().Y&&                                  //checks for intersect on downRight
                centreOfRadiuses.Y > racket.GetCenter().Y - racket.GetRadius() + 10)
            {
                return(Vector2Directions.upLeft);
            }
            if (centreOfRadiuses.X < racket.GetCenter().X&&
                centreOfRadiuses.X > racket.GetCenter().X - racket.GetRadius() + 10 &&
                centreOfRadiuses.Y > racket.GetCenter().Y&&                                     //checks for intersect on upRight
                centreOfRadiuses.Y < racket.GetCenter().Y + racket.GetRadius() - 10)
            {
                return(Vector2Directions.downLeft);
            }

            if (centreOfRadiuses.X > racket.GetCenter().X - racket.GetRadius() + 20 &&
                centreOfRadiuses.X < racket.GetCenter().X + racket.GetRadius() - 20 &&
                centreOfRadiuses.Y > racket.GetCenter().Y&&                                     //checks for intersect on up
                centreOfRadiuses.Y < racket.GetCenter().Y + racket.GetRadius() + 10)
            {
                return(Vector2Directions.down);
            }
            if (centreOfRadiuses.X > racket.GetCenter().X - racket.GetRadius() + 20 &&
                centreOfRadiuses.X < racket.GetCenter().X + racket.GetRadius() - 20 &&
                centreOfRadiuses.Y < racket.GetCenter().Y&&                                     //checks for intersect on down
                centreOfRadiuses.Y > racket.GetCenter().Y - racket.GetRadius() - 10)
            {
                return(Vector2Directions.up);
            }
            if (centreOfRadiuses.X > racket.GetCenter().X&&
                centreOfRadiuses.X < racket.GetCenter().X + racket.GetRadius() + 10 &&
                centreOfRadiuses.Y > racket.GetCenter().Y - racket.GetRadius() + 20 &&                                 //checks for intersect on left
                centreOfRadiuses.Y < racket.GetCenter().Y + racket.GetRadius() - 20)
            {
                return(Vector2Directions.right);
            }
            if (centreOfRadiuses.X < racket.GetCenter().X&&
                centreOfRadiuses.X > racket.GetCenter().X - racket.GetRadius() - 10 &&
                centreOfRadiuses.Y > racket.GetCenter().Y - racket.GetRadius() + 20 &&                                    //checks for intersect on right
                centreOfRadiuses.Y < racket.GetCenter().Y + racket.GetRadius() - 20)
            {
                return(Vector2Directions.left);
            }

            return(new Vector2f(0, 0));
        }