public override bool Equals(object obj) { if (obj is null || obj.GetType() != typeof(TankControlCommand)) { return(false); } TankControlCommand other = obj as TankControlCommand; bool isEqual = (this.Moving == other.Moving) && (this.Fire == other.Fire) && (this.TurretDirection == other.TurretDirection); return(isEqual); }
private void UpdateTankBodyPosition(Tank tank, TankControlCommand command) { // update tank location Vector2D movingDirection = new Vector2D(0, 0); // tank.BodyDirection = movingDirection; movingDirection = ModifyMovingDirection(command.Moving, movingDirection); // Build our velocity vector Vector2D velocity = movingDirection * gameSettings.TankSpeed; // add velocity to position tank.Location = tank.Location + velocity; }
private bool TryParseJsonAsTankControlCommand(string json, out TankControlCommand tankControlCommand) { JObject parsedObject = JObject.Parse(json); JToken movingAttribute = parsedObject["moving"]; if (movingAttribute != null) { tankControlCommand = (TankControlCommand)parsedObject.ToObject <TankControlCommand>(); return(true); } else { tankControlCommand = null; return(false); } }
public GameController() { theWorld = new World(); tankControlCommand = new TankControlCommand(); }
private void SendTankControlCommand(TankControlCommand controlCommand) { string controlCommandJson = JsonConvert.SerializeObject(controlCommand) + "\n"; Networking.Send(serverSocketState.TheSocket, controlCommandJson); }
private void UpdateTankBodyDirection(Tank tank, TankControlCommand command) { Vector2D movingDirection = tank.BodyDirection; tank.BodyDirection = ModifyMovingDirection(command.Moving, movingDirection); }
public bool TryGetTankControlCommandByTankID(int tankID, out TankControlCommand tankControlCommand) { return(controlCommands.TryGetValue(tankID, out tankControlCommand)); }
public void UpdateTankControlCommand(int tankID, TankControlCommand tankControlCommand) { controlCommands[tankID] = tankControlCommand; }
public void AddNewPlayer(int tankID) { controlCommands[tankID] = new TankControlCommand(); }
public void UpdateGameControlState(int tankID, TankControlCommand tankControlCommand) { gameControlState.UpdateTankControlCommand(tankID, tankControlCommand); }