Ejemplo n.º 1
0
 void ShowStats()
 {
     if (currentStats != null)
     {
         canvas.enabled = false;
         foreach (Transform t in container.transform)
         {
             Destroy(t.gameObject);
         }
         ShowStat("Player bytes out", currentStats.playerBytesOut);
         ShowStat("Bytes out", currentStats.bytesOut);
         ShowStat("Messages in/out", currentStats.messageCountInOut);
         ShowStat("Messages in", currentStats.messageCountIn);
         ShowStat("Messages out", currentStats.messageCountOut);
         ShowStat("Connections", currentStats.connectionCount);
         ShowStat("Entities in visual range", GameEntityManager.GameEntityCount());
         canvas.enabled = true;
     }
 }
Ejemplo n.º 2
0
        public CommandResult process(string command)
        {
            List <string> words;
            string        messageType = null;

            if (command.StartsWith("/speed"))
            {
                command = command.Replace("/speed", "");
                //int speed = Int32.Parse(command);
                //string characterId = GameEntityManager.GetPlayerEntity().GetCharacterId();
                //GameEntityController controller = GameEntityManager.GetPlayerEntity().GetGameEntityController();
                return(CommandResult.Ok);
            }
            else if (command.StartsWith("/zone"))
            {
                command = command.Replace("/zone", "").Trim();
                DefaultClient.instance.ConnectToZone(command);
                return(CommandResult.Ok);
            }
            else if (command.StartsWith("/count"))
            {
                chatUI.LocalMessage(Color.yellow, GameEntityManager.GameEntityCount().ToString());
                return(CommandResult.Ok);
            }
            else if (command.StartsWith("/stuck"))
            {
                SpawnPoint.Instance().SpawnHome();
                return(CommandResult.Ok);
            }
            else if (command.StartsWith("/territories"))
            {
                return(CommandResult.Ok);
            }
            else if (command.StartsWith("/guild_create"))
            {
                command = command.Replace("/guild_create", "").Trim();
                //string guildId = Messenger.SanitizeChannelName(command);

                return(CommandResult.Ok);
            }
            else if (command.StartsWith("/guild_destroy"))
            {
                command = command.Replace("/guild_destroy", "").Trim();


                return(CommandResult.Ok);
            }
            else if (command.StartsWith("/guild_invite"))
            {
                command = command.Replace("/guild_invite", "").Trim();


                return(CommandResult.Ok);
            }
            else if (command.StartsWith("/guild_leave"))
            {
                command = command.Replace("/guild_leave", "").Trim();


                return(CommandResult.Ok);
            }
            else if (command.StartsWith("/guild_members"))
            {
                command = command.Replace("/guild_members", "").Trim();


                return(CommandResult.Ok);
            }
            else if (command.StartsWith("/guild_list"))
            {
                command = command.Replace("/guild_list", "").Trim();


                return(CommandResult.Ok);
            }
            else if (command.StartsWith("/guild"))
            {
                command     = command.Replace("/guild", "");
                messageType = "group";
                //messenger.SendText(playerId, "guild name here", command, messageType);

                return(CommandResult.Ok);
            }
            else if (command.StartsWith("/tell"))
            {
                command     = command.Replace("/tell", "");
                messageType = "private";
            }
            else if (command.StartsWith("/join"))
            {
                command = command.Replace("/join", "");
                string channel = Messenger.SanitizeChannelName(command);
                if (IsGuildChannel(channel))
                {
                    Debug.Log("Attempt to join guild channel " + channel);
                    return(CommandResult.Ok);
                }
                messenger.JoinChannel(channel);

                return(CommandResult.Ok);
            }
            else if (command.StartsWith("/leave"))
            {
                command = command.Replace("/leave", "");
                messenger.leaveChannel(Messenger.SanitizeChannelName(command));

                return(CommandResult.Ok);
            }
            else if (command.StartsWith("/channels"))
            {
                chatUI.RemoteChannelList(messenger.channelSubscriptions);

                return(CommandResult.Ok);
            }
            else if (command.StartsWith("/group_create"))
            {
                messenger.JoinChannel(groupName);

                return(CommandResult.Ok);
            }
            else if (command.StartsWith("/group"))
            {
                string msg = command.Replace("/group", "");
                messenger.SendText(playerId, chatUI.CurrentGroup(), msg, "group");

                return(CommandResult.Ok);
            }
            else if (command.StartsWith("/invite"))
            {
                command = command.Replace("/invite", "");
                words   = new List <string>(command.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries));
                string characterId = words[0];
                InviteToChannel(characterId, groupName);

                return(CommandResult.Ok);
            }
            else if (command.StartsWith("/help"))
            {
                string[] commandlist = new string[] {
                    "Valid commands:\n",
                    "/tell [recipient] [message] - send private message",
                    "/join [channel] - join channel",
                    "/leave [channel] - leave channel",
                    "/channels - show channels you are subscribed to",
                    "/group_create - create group",
                    "/group [message] - send group message",
                    "/invite [player] - invite to private group",
                    "/help - this message",
                    "/guild_create [guild characterId] - Create a guild",
                    "/guild_destroy - destroys your guild (must be owner)",
                    "/guild_invite [player] - invite player to guild",
                    "/guild_leave - leave your guild.  If owner, destroys it",
                    "/guild [message] - send message to guild",
                    "/guild_list - show list of all guilds",
                    "/guild_members - show members of your guild"
                };
                chatUI.LocalMessage(Color.yellow, String.Join("\n", commandlist));
                return(CommandResult.Ok);
            }
            else if (command.StartsWith("/"))
            {
                command     = command.Replace("/", "");
                messageType = "group";
            }

            words = new List <string>(command.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries));
            string channelName = words[0];

            command = command.Replace(channelName, "");
            string message = command;

            string logMessage = string.Format("channel={0} message={1} messageType={2}", channelName, message, messageType);

            Debug.Log(logMessage);

            if (message.Length == 0)
            {
                chatUI.LocalMessage(Color.red, "Invalid command");
                return(CommandResult.InvalidCommand);
            }

            if (messageType == "group" && !messenger.channelSubscriptions.Contains(channelName))
            {
                chatUI.LocalMessage(Color.red, "You are not subscribed to " + channelName);
                return(CommandResult.NotSubscribed);
            }

            if (IsGuildChannel(channelName))
            {
                Debug.Log("Attempt to send message to other guild " + channelName);
                return(CommandResult.NoPermission);
            }

            if (messageType == "private")
            {
                channelName = "character_id__" + channelName;
            }
            messenger.SendText(playerId, channelName, message, messageType);

            return(CommandResult.Ok);
        }