public TurretSpinningEvent(VTankBot _game, int id, double angle, VTankObject.Direction direction) : base(_game) { this.id = id; this.angle = angle; this.direction = direction; }
public PlayerRotateEvent(GamePlayState _game, int id, double angle, VTankObject.Direction direction) : base(_game) { this.id = id; this.angle = angle; this.direction = direction; }
public PlayerMoveEvent(GamePlayState _game, int id, VTankObject.Point point, VTankObject.Direction direction) : base(_game) { this.id = id; this.direction = direction; this.point = point; }
/// <summary> /// Rotate [player] until he is facing [angleInRadians]. /// </summary> /// <param name="player">Player to rotate.</param> /// <param name="angleInRadians">Angle to rotate to. This is not a theta value.</param> public void RotateTo(Player player, double angleInRadians) { MetaPlayer currentPlayer = players[player.ID]; currentPlayer.GoalAngle = (angleInRadians) % (Math.PI * 2.0f); double currentAngle = player.Angle; double distance = 0; VTankObject.Direction result = ShortestDistance(currentAngle, angleInRadians, out distance); if (result == VTankObject.Direction.RIGHT) { player.RotationDirection = VTankObject.Direction.RIGHT; } else { player.RotationDirection = VTankObject.Direction.LEFT; } // Time = distance/velocity double timeInSeconds = Math.Abs( distance / (ANGULAR_VELOCITY * player.SpeedFactor)); currentPlayer.SecondsUntilAngle = timeInSeconds; bot.GameServer.Rotate(currentAngle, player.RotationDirection); }
/// <summary> /// Ask the game tracker to move a player to a certain position. /// </summary> /// <param name="player">Player to move.</param> /// <param name="x">X-position to move to.</param> /// <param name="y">Y-position to move to.</param> public void StartMoving(VTankObject.Direction direction) { MetaPlayer movingPlayer = players[LocalPlayer.ID]; SetPlayerMovement(LocalPlayer, LocalPlayer.Position, direction); bot.GameServer.Move(movingPlayer.Player.Position.x, movingPlayer.Player.Position.y, direction); }
/// <summary> /// Helper method for changing the rotation of the user. Does nothing if the given /// direction is not actually a change. /// </summary> /// <param name="direction">Direction that the tank is rotating towards.</param> /// <param name="force">If true, forces the movement packet.</param> private void ChangeRotation(VTankObject.Direction direction, bool force) { if (localPlayer.DirectionRotation != direction || force) { localPlayer.DirectionRotation = direction; ServiceManager.Theater.Rotate(localPlayer.Angle, direction); } }
public PlayerMoveEvent(VTankBot _game, int id, VTankObject.Point point, VTankObject.Direction direction) : base(_game) { this.id = id; this.direction = direction; this.point = point; }
/// <summary> /// Helper method for changing the movement of the user. Does nothing if the given /// direction is not actually a change. /// </summary> /// <param name="direction">Direction that the tank is moving towards.</param> /// <param name="force">If set to true, forces a re-sync packet.</param> private void ChangeMovement(VTankObject.Direction direction, bool force) { if (localPlayer.DirectionMovement != direction || force) { localPlayer.DirectionMovement = direction; ServiceManager.Theater.Move(localPlayer.Position.X, localPlayer.Position.Y, direction); } }
public override void TurretSpinning(int id, double angle, VTankObject.Direction direction, Ice.Current current__) { if (!ReceivingMessages()) { return; } buffer.Enqueue(new TurretSpinningEvent(Game, id, angle, direction)); }
public override void PlayerMove(int id, VTankObject.Point point, VTankObject.Direction direction, Ice.Current current__) { if (!ReceivingMessages()) { return; } buffer.Enqueue(new PlayerMoveEvent(Game, id, point, direction)); }
public void InvokeOnPlayerMove(int playerID, VTankObject.Point position, VTankObject.Direction direction) { Player player = Game.GetPlayerByID(playerID); if (player != null) { Game.SetPlayerMovement(player, position, direction); } }
public void InvokeOnPlayerRotate(int playerID, double angle, VTankObject.Direction direction) { Player player = Game.GetPlayerByID(playerID); if (player != null) { Game.SetPlayerRotation(player, angle, direction); } }
/// <summary> /// Send a rotation packet to the game server. You must already be connected and /// authenticated with Theater for this to do anything. /// </summary> /// <param name="angle">Current angle (for sync).</param> /// <param name="direction">New rotation direction.</param> /// <exception cref="Network.Exception.InvalidValueException"> /// Thrown if an invalid direction is passed.</exception> /// <exception cref="System.NullPointerException">Thrown if the /// session was never connected.</exception> public void Rotate(double angle, VTankObject.Direction direction) { if (direction == VTankObject.Direction.FORWARD || direction == VTankObject.Direction.REVERSE) { // Direction is invalid. throw new InvalidValueException(direction.ToString() + " is an invalid value for rotation!"); } sessionOneway.Rotate_async(new Rotate_Callback( new ActionFinished <NoReturnValue>( CommonExceptionHandler <NoReturnValue>)), Network.Util.Clock.GetTimeMilliseconds(), angle, direction); }
/// <summary> /// Send a movement packet to the game server. You must already be connected and /// authenticated with Theater for this to do anything. /// </summary> /// <param name="x">X-position of the player (for sync).</param> /// <param name="y">Y-position of the player (for sync).</param> /// <param name="direction">New direction to move towards. The only valid directions /// are: NONE, FORWARD, REVERSE.</param> /// <exception cref="Network.Exception.InvalidValueException"> /// Thrown if an invalid direction is passed.</exception> /// <exception cref="System.NullPointerException">Thrown if the /// session was never connected.</exception> public void Move(double x, double y, VTankObject.Direction direction) { if (direction == VTankObject.Direction.LEFT || direction == VTankObject.Direction.RIGHT) { // Direction is invalid. throw new InvalidValueException(direction.ToString() + " is an invalid value for movement!"); } sessionOneway.Move_async( new Move_Callback(new ActionFinished <NoReturnValue>( CommonExceptionHandler <NoReturnValue>)), Network.Util.Clock.GetTimeMilliseconds(), new VTankObject.Point(x, y), direction); }
public override void PlayerMove(int id, VTankObject.Point point, VTankObject.Direction direction, Ice.Current current__) { buffer.Push(new PlayerMoveEvent(bot, id, point, direction)); }
/// <summary> /// Helper method for changing the rotation of the user. Does nothing if the given /// direction is not actually a change. /// </summary> /// <param name="direction">Direction that the tank is rotating towards.</param> private void ChangeRotation(VTankObject.Direction direction) { ChangeRotation(direction, false); }
/// <summary> /// Helper method for changing the movement of the user. Does nothing if the given /// direction is not actually a change. /// </summary> /// <param name="direction">Direction that the tank is moving towards.</param> private void ChangeMovement(VTankObject.Direction direction) { ChangeMovement(direction, false); }
/// <summary> /// Set a player's rotation data (who isn't the bot itself). This is done in a /// thread-safe way. /// </summary> /// <param name="player"></param> /// <param name="angle"></param> /// <param name="direction"></param> public void SetPlayerRotation(Player player, double angle, VTankObject.Direction direction) { player.Angle = angle; player.RotationDirection = direction; }
public override void TurretSpinning(int id, double angle, VTankObject.Direction direction, Ice.Current current__) { buffer.Push(new TurretSpinningEvent(bot, id, angle, direction)); }
public override void PlayerRotate(int id, double angle, VTankObject.Direction direction, Ice.Current current__) { buffer.Push(new PlayerRotateEvent(bot, id, angle, direction)); }
/// <summary> /// Set a player's movement data (who isn't the bot itself). This is done in a /// thread-safe way. /// </summary> /// <param name="player"></param> /// <param name="position"></param> /// <param name="direction"></param> public void SetPlayerMovement(Player player, VTankObject.Point position, VTankObject.Direction direction) { player.SetPosition(position); player.MovementDirection = direction; }