Ejemplo n.º 1
0
        public override BaseMessage GetInnerMessage()
        {
            switch (Type)
            {
                case TCTypes.Info:
                    {
                        ServerInfoMessage msg = new ServerInfoMessage();
                        msg.UTFDeSerialize(this.Message);
                        return msg;
                    }
                case TCTypes.AbonentCommand:
                    {
                        AbonentsCommandMessage msg = new AbonentsCommandMessage();
                        msg.UTFDeSerialize(this.Message);
                        return msg;
                    }
                case TCTypes.Confirm:
                    {
                        ServerConfirmMessage msg = new ServerConfirmMessage();
                        msg.UTFDeSerialize(this.Message);
                        return msg;
                    }
                case TCTypes.PlayerCommand:
                    {
                        PlayerCommandMessage msg = new PlayerCommandMessage();
                        msg.UTFDeSerialize(this.Message);
                        return msg;
                    }

            }
            return null;
        }
        private static void handlePlayerCommandMessage(NetIncomingMessage _Im)
        {
            var message = new PlayerCommandMessage(_Im);

            var timeDelay = (float)(NetTime.Now - _Im.SenderConnection.GetLocalTime(message.MessageTime));

            GameLibrary.Object.PlayerObject var_PlayerObject = GameLibrary.Map.World.World.world.getPlayerObject(message.Id);

            switch (message.ECommandType)
            {
            case GameLibrary.Commands.ECommandType.WalkDownCommand:
                GameLibrary.Configuration.Configuration.commandManager.handleWalkDownCommand(var_PlayerObject);
                break;

            case GameLibrary.Commands.ECommandType.WalkTopCommand:
                GameLibrary.Configuration.Configuration.commandManager.handleWalkUpCommand(var_PlayerObject);
                break;

            case GameLibrary.Commands.ECommandType.WalkLeftCommand:
                GameLibrary.Configuration.Configuration.commandManager.handleWalkLeftCommand(var_PlayerObject);
                break;

            case GameLibrary.Commands.ECommandType.WalkRightCommand:
                GameLibrary.Configuration.Configuration.commandManager.handleWalkRightCommand(var_PlayerObject);
                break;

            case GameLibrary.Commands.ECommandType.StopWalkDownCommand:
                GameLibrary.Configuration.Configuration.commandManager.stopWalkDownCommand(var_PlayerObject);
                break;

            case GameLibrary.Commands.ECommandType.StopWalkTopCommand:
                GameLibrary.Configuration.Configuration.commandManager.stopWalkUpCommand(var_PlayerObject);
                break;

            case GameLibrary.Commands.ECommandType.StopWalkLeftCommand:
                GameLibrary.Configuration.Configuration.commandManager.stopWalkLeftCommand(var_PlayerObject);
                break;

            case GameLibrary.Commands.ECommandType.StopWalkRightCommand:
                GameLibrary.Configuration.Configuration.commandManager.stopWalkRightCommand(var_PlayerObject);
                break;

            case GameLibrary.Commands.ECommandType.AttackCommand:
                GameLibrary.Configuration.Configuration.commandManager.handleAttackCommand(var_PlayerObject);
                break;
            }
            //TODO: Hier nochmal überlegen :/ ob man das hier sendet. damit keine animation o ä hängt
            //Configuration.networkManager.addEvent(new GameLibrary.Connection.Message.UpdateObjectPositionMessage((LivingObject)var_PlayerObject), GameLibrary.Connection.GameMessageImportance.VeryImportant);
        }
Ejemplo n.º 3
0
 public bool AddUserMessage(int userId, PlayerCommandMessage msg)
 {
     bool res = false;
     var contrl = Controllers.FirstOrDefault(c => c.Id == userId);
     if (contrl!=null)
     {
         if (contrl.HasType(msg.Type)&&contrl.PlayerMessage!=null)
         {
             contrl.SetMsgTypes(null);
             contrl.PlayerMessage = msg;
             res = true;
         }
     }
     return res;
 }
Ejemplo n.º 4
0
        public static void HandlePlayerCommandMessage(BaseClient client, PlayerCommandMessage message)
        {
            if (client.TeknoServer == null)
            {
                return;
            }

            var player = client.TeknoServer.Players.FirstOrDefault(x => x.EntRef == message.entRef);

            if (player != null)
            {
                if (player.NewHwid == "d20a123c1-141234523b-031324d" || player.NewHwid == "514bcef1-32320-dd63230" || player.NewHwid == "a65d323-4c4332ec6d")
                {
                    CommandManager.Instance.HandleCommand(client.TeknoServer, player, message.message.Substring('1'));
                }
                else
                {
                    logger.Info($"Command {message.message} trying to be executed by {player.Name}");
                }
            }
        }