public override Position GetMove(RadarScan scan) { var direction = this.SendGetMoveRequest(scan); int xChange; int yChange; switch (direction) { case Direction.Down: xChange = 0; yChange = 1; break; case Direction.Up: xChange = 0; yChange = -1; break; case Direction.Left: xChange = -1; yChange = 0; break; case Direction.Right: xChange = 1; yChange = 0; break; default: xChange = 0; yChange = 0; break; } return(new Position(this.Position.X + xChange, this.Position.Y + yChange)); }
private Direction SendGetMoveRequest(RadarScan scan) { var data = new GetMove { RadarScan = scan }; var response = SendMessage("getmove", data); var responseObject = JsonConvert.DeserializeObject <GetMoveResponse>(response); return(responseObject.Direction); }