public KeyboardPlayerControler(Keys up, Keys down,Player player) : base(player) { this.KeyboardState = new KeyboardState(); this.UpKey = up; this.DownKey = down; }
//Vérification de la collision entre la balle et un joueur public Boolean CheckPlayerColision(Player player) { if (!this.HitBox.Intersects(player.HitBox)) { player.isInIntersection = false; } if (this.HitBox.Intersects(player.HitBox)&&!player.isInIntersection) { int middle = (int)player.position.Y + Conf.BAT_HEIGHT / 2; float coef = (-middle + this.position.Y) / (Conf.BAT_HEIGHT / 2); if (this.Speed.X > 0) { coef = -1 * coef; } Vector2 vector = new Vector2(-this.Speed.X, this.Speed.Y); float angle = (float)(Math.PI / 180) * 45; Vector2 final = new Vector2(); final.X = (int)(this.Acceleration * (vector.X * Math.Cos(coef * angle) - vector.Y * Math.Sin(coef * angle)) +(vector.X * Math.Cos(coef * angle) - vector.Y * Math.Sin(coef * angle))); final.Y = (int)(this.Acceleration * (vector.Y * Math.Cos(coef * angle) + vector.X * Math.Sin(coef * angle)) + (vector.Y * Math.Cos(coef * angle) + vector.X * Math.Sin(coef * angle))); if (final.Length() > 20) { final.X = (int)((vector.X * Math.Cos(coef * angle) - vector.Y * Math.Sin(coef * angle))); final.Y = (int)((vector.Y * Math.Cos(coef * angle) + vector.X * Math.Sin(coef * angle))); } this.Speed = final; this.correctSpeed(); player.isInIntersection = true; return true; } return false; }
public ArtificialPlayerControler(Player player) : base(player) { this.Player.IsAccelerating = true; }
public IPlayerControler(Player player) { this.Player = player; }