public async override void UseFeature(CircleObject circle) { circle.ChangeBoolCanMove(false); await Task.Delay(3000); circle.ChangeBoolCanMove(true); }
public static bool IsVectorBiggerThenWindowY(CircleObject circle, Vector2u window) { if (circle.GetCenter().Y - circle.GetRadius() > GetPercentOf(window.Y, 50)) { return(true); } return(false); }
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)); }
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); }
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)); } } }
public abstract void UseFeature(CircleObject circle);
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)); }