Ejemplo n.º 1
0
        public async Task startAndStopMovement(string toStop, string toStart, 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)
                    {
                        Movement whereToStop  = (Movement)Enum.Parse(typeof(Movement), toStop);
                        Movement whereToStart = (Movement)Enum.Parse(typeof(Movement), toStart);
                        ship.StopMoving(whereToStop, at, angle, velocity);
                        ship.StartMoving(whereToStart, at, angle, velocity);
                    }
                }
                catch (Exception e)
                {
                    _logger.LogError("startAndStopMovement", e);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Registers the stop of a movement on a client. Fires when the client presses a movement hotkey.
        /// </summary>
        /// <param name="movement">Direction to stop moving</param>
        public async Task registerMoveStop(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.StopMoving(where, at, angle, velocity);
                    }
                }
                catch (Exception e)
                {
                    _logger.LogError("registerMoveStop", e);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Registers the stop of a movement on a client.  Fires when the client presses a movement hotkey.
        /// </summary>
        /// <param name="movement">Direction to stop moving</param>
        public void registerMoveStop(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.StopMoving(where, at, angle, velocity);
                    }
                }
                catch (Exception e)
                {
                    ErrorLog.Instance.Log(e);
                }
            }
        }
Ejemplo n.º 4
0
        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);
                }
            }
        }
Ejemplo n.º 5
0
        public void bot_stopMoving()
        {
            if (_game.UserHandler.UserExistsAndReady(Context.ConnectionId))
            {
                try
                {
                    Ship ship = _game.UserHandler.GetUserShip(Context.ConnectionId);

                    if (ship.Controllable.Value)
                    {
                        ship.StopMoving(Movement.Forward);
                        ship.StopMoving(Movement.Backward);
                        ship.StopMoving(Movement.RotatingLeft);
                        ship.StopMoving(Movement.RotatingRight);
                    }
                }
                catch (Exception e)
                {
                    _logger.LogError("Stop moving", e);
                }
            }
        }
Ejemplo n.º 6
0
        public void bot_stopMovement(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.StopMoving(where);
                    }
                }
                catch (Exception e)
                {
                    _logger.LogError("registerMoveStart", e);
                }
            }
        }
Ejemplo n.º 7
0
        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);
                }
            }
        }