/// <summary> /// Registers the start of a movement on a client. Fires when the client presses a movement hotkey. /// </summary> /// <param name="movement">Direction to start moving</param> public async Task registerMoveStart(string movement, Vector2 at, double angle, Vector2 velocity, bool pingBack) { if (_game.UserHandler.UserExistsAndReady(Context.ConnectionId)) { try { if (pingBack) { await Clients.Client(Context.ConnectionId).SendAsync("pingBack"); } Ship ship = _game.UserHandler.GetUserShip(Context.ConnectionId); if (ship.Controllable.Value) { var where = (Movement)Enum.Parse(typeof(Movement), movement); ship.StartMoving(where, at, angle, velocity); } } catch (Exception e) { _logger.LogError("registerMoveStart", e); } } }
/// <summary> /// Registers the start of a movement on a clint. Fires when the client presses a movement hotkey. /// </summary> /// <param name="movement">Direction to start moving</param> public void registerMoveStart(string movement, Vector2 at, double angle, Vector2 velocity, bool pingBack) { if (_game.UserHandler.UserExistsAndReady(Context.ConnectionId)) { try { if (pingBack) { Clients.Caller.pingBack(); } Ship ship = _game.UserHandler.GetUserShip(Context.ConnectionId); if (ship.Controllable.Value) { Movement where = (Movement)Enum.Parse(typeof(Movement), movement); ship.StartMoving(where, at, angle, velocity); } } catch (Exception e) { ErrorLog.Instance.Log(e); } } }
public void startAndStopMovement(string toStop, string toStart, bool pingBack, long commandID) { if (_game.UserHandler.UserExistsAndReady(Context.ConnectionId)) { try { if (pingBack) { Clients.Caller.pingBack(); } Ship ship = _game.UserHandler.GetUserShip(Context.ConnectionId); if (ship.Controllable.Value) { Movement whereToStop = (Movement)Enum.Parse(typeof(Movement), toStop); Movement whereToStart = (Movement)Enum.Parse(typeof(Movement), toStart); ship.StopMoving(whereToStop, commandID); ship.StartMoving(whereToStart, commandID); } } catch (Exception e) { //ErrorLog.Instance.Log(e); } } }
public void bot_startMovement(string movement) { if (_game.UserHandler.UserExistsAndReady(Context.ConnectionId)) { try { Ship ship = _game.UserHandler.GetUserShip(Context.ConnectionId); if (ship.Controllable.Value) { var where = (Movement)Enum.Parse(typeof(Movement), movement); ship.StartMoving(where); } } catch (Exception e) { _logger.LogError("registerMoveStart", e); } } }
public void bot_startAndStopMovement(string toStop, string toStart) { if (_game.UserHandler.UserExistsAndReady(Context.ConnectionId)) { try { Ship ship = _game.UserHandler.GetUserShip(Context.ConnectionId); if (ship.Controllable.Value) { Movement whereToStop = (Movement)Enum.Parse(typeof(Movement), toStop); Movement whereToStart = (Movement)Enum.Parse(typeof(Movement), toStart); ship.StopMoving(whereToStop); ship.StartMoving(whereToStart); } } catch (Exception e) { _logger.LogError("startAndStopMovement", e); } } }