Example #1
0
 public static void SaveFilter(ClientPlayerInfo p, string filterText)
 {
     if (p != null)
     {
         lastFilter[GeneralUtilities.getUniquePlayerString(p)] = filterText;
     }
 }
Example #2
0
            public override void use(ClientPlayerInfo p, string message)
            {
                var match = Regex.Match(message, parent.voteCtrlPattern);

                if (!match.Success)
                {
                    help(p);
                    return;
                }

                string voteType = match.Groups[1].Value.ToLower();
                string percentS = match.Groups[2].Value;
                int    percent  = int.Parse(percentS);

                if (!parent.voteCommand.voteThresholds.ContainsKey(voteType))
                {
                    MessageUtilities.sendMessage(p, $"Invalid <voteType>. ({voteType})");
                    help(p);
                    return;
                }

                parent.voteCommand.voteThresholds[voteType] = Convert.ToDouble(percent) / 100.0;
                Entry.save();
                MessageUtilities.sendMessage(p, $"Pass threshold for {voteType} changed to {percent}%");
            }
Example #3
0
 public override void use(ClientPlayerInfo p, string message)
 {
     index++;  // Tracks when new levels load. Some code needs to stop running if a new level loads.
     if (!autoMode)
     {
         autoMode = true;
         MessageUtilities.sendMessage("Auto mode started!");
         if (GeneralUtilities.isOnLobby())
         {
             G.Sys.GameManager_.StartCoroutine(startFromLobby());
         }
         else if (GeneralUtilities.isModeFinished())
         {
             G.Sys.GameManager_.StartCoroutine(waitAndGoNext());
         }
         else
         {
             onModeStart();
         }
     }
     else
     {
         autoMode = false;
         MessageUtilities.sendMessage("Auto mode stopped!");
     }
 }
Example #4
0
 public override void use(ClientPlayerInfo p, string message)
 {
     if (!autoMode)
     {
         autoMode = true;
         Utilities.sendMessage("Automode started !");
         if (Utilities.isOnLobby())
         {
             G.Sys.GameManager_.StartCoroutine(startFromLobby());
         }
         else if (Utilities.isModeFinished())
         {
             G.Sys.GameManager_.StartCoroutine(waitAndGoNext());
         }
         else
         {
             onModeStart();
         }
     }
     else
     {
         autoMode = false;
         Utilities.sendMessage("Automode stoped !");
     }
 }
Example #5
0
        public override void use(ClientPlayerInfo p, string message)
        {
            if (!Utilities.isOnGamemode())
            {
                Utilities.sendMessage("Can't restart on lobby !");
                return;
            }

            var serverLogic = G.Sys.GameManager_.GetComponent <ServerLogic>();

            if (serverLogic == null)
            {
                Utilities.sendMessage("ServerLogic null !");
                return;
            }

            var clients = (IEnumerable)(serverLogic.GetType().GetField("clientInfoList_", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(serverLogic));

            foreach (var c in clients)
            {
                if (p.NetworkPlayer_.Equals(c.GetType().GetField("networkPlayer_", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(c)))
                {
                    exec(serverLogic, c);
                    break;
                }
            }
        }
Example #6
0
        public override void use(ClientPlayerInfo p, string message)
        {
            if (message == "")
            {
                help(p);
                return;
            }

            if (message == "CHECK" && p == GeneralUtilities.localClient())
            {
                var index = 0;
                foreach (var a in GeneralUtilities.getAllLevelsAndModes())
                {
                    GeneralUtilities.formatLevelInfoText(a, index++, "%NAME% %DIFFICULTY% %MODE% %AUTHOR% %INDEX% %MBRONZE% %MSILVER% %MGOLD% %MDIAMOND% %STARS% %STARSINT% %STARSDEC% %STARSPCT% %CREATED% %UPDATED%");
                }
                Console.WriteLine($"Tried to format {index} levels. Errors are in the console. If you see no errors, it means all levels formatted successfully.");
                MessageUtilities.sendMessage(GeneralUtilities.localClient(), $"Tried to format {index} levels. Errors are in the console. If you see no errors, it means all levels formatted successfully.");
                return;
            }

            FilteredPlaylist filterer = new FilteredPlaylist(GeneralUtilities.getAllLevelsAndModes());

            if (!p.IsLocal_)
            {
                PlayCmd playCmd = Cmd.all.getCommand <PlayCmd>("play");
                filterer.AddFiltersFromString(playCmd.playFilter);
            }

            MessageUtilities.pushMessageOption(new MessageStateOptionPlayer(p));
            GeneralUtilities.sendFailures(GeneralUtilities.addFiltersToPlaylist(filterer, p, message, true), 4);
            MessageUtilities.popMessageOptions();

            MessageUtilities.sendMessage(p, GeneralUtilities.getPlaylistText(filterer, GeneralUtilities.IndexMode.Final, levelFormat));
        }
Example #7
0
 public override void help(ClientPlayerInfo p)
 {
     Utilities.sendMessage("!settings reload: reload the settings for file.");
     Utilities.sendMessage("!settings vote [true/false]: allow players to vote on auto mode.");
     Utilities.sendMessage("!settings play [true/false]: allow player to add maps on the playlist.");
     Utilities.sendMessage("!settings addOne [true/false] : if enabled, allow the players to add only one map at a time.");
 }
Example #8
0
 public override void help(ClientPlayerInfo p)
 {
     MessageUtilities.sendMessage(p, GeneralUtilities.formatCmd("!server") + ": Show the server name");
     MessageUtilities.sendMessage(p, GeneralUtilities.formatCmd("!server [new name]") + ": Modify the server name");
     MessageUtilities.sendMessage(p, GeneralUtilities.formatCmd("!server private [password]") + ": Set the server private");
     MessageUtilities.sendMessage(p, GeneralUtilities.formatCmd("!server public") + ": Set the server public");
 }
Example #9
0
    private void SpawnPlayer(PlayerInfo player)
    {
        Debug.Log("Spawning Player: " + player.ID);
        GameObject playerGO = (GameObject)Instantiate(PlayerPrefab, player.Position, Quaternion.identity);

        //playerGO.GetComponentInChildren<SpriteRenderer>().color = player.Color;
        playerGO.name = "Player" + player.ID;

        player.gameObject = playerGO;

        ClientPlayerInfo localPlayer = player as ClientPlayerInfo;

        PlayerController controller = playerGO.GetComponentInChildren <PlayerController>();

        if (localPlayer != null)
        {
            controller.controller   = localPlayer.controllerID > 4 ? PlayerController.ControllerType.Keyboard : PlayerController.ControllerType.Xbox;
            controller.controllerID = localPlayer.controllerID;
        }
        controller.playerID    = player.ID;
        controller.myAnimation = PlayerIdleClips[player.AnimationIndex];

        controller.enabled = false;

        PlayerRoom[] rooms = FindObjectsOfType <PlayerRoom>();
        foreach (var room in rooms)
        {
            BoxCollider2D box = room.GetComponent <BoxCollider2D>();
            if (box.OverlapPoint(player.Position))
            {
                room.owner = player.ID;
            }
        }
    }
Example #10
0
 public ClientPlayerInfo CreateMySelf(int playerID, bool isMaster)
 {
     m_CurrentPlayerInfo = new ClientPlayerInfo(playerID, "Player" + playerID, Vector3.zero, Color.red, 0, animationIndex, isMaster);
     animationIndex++;
     players.Add(playerID, m_CurrentPlayerInfo);
     return(m_CurrentPlayerInfo);
 }
Example #11
0
        public override void use(ClientPlayerInfo p, string message)
        {
            LevelPlaylist playlist = new LevelPlaylist();

            playlist.CopyFrom(G.Sys.GameManager_.LevelPlaylist_);

            if (G.Sys.GameManager_.ModeID_ == GameModeID.Trackmogrify)
            {
                MessageUtilities.sendMessage(p, "You can't manage the playlist in trackmogrify");
                return;
            }

            if (playlist.Count_ == 0)
            {
                MessageUtilities.sendMessage(p, "The playlist is empty !");
                return;
            }

            var item = playlist.Playlist_[G.Sys.GameManager_.LevelPlaylist_.Index_];

            playlist.Playlist_.Clear();

            G.Sys.GameManager_.LevelPlaylist_.Clear();
            G.Sys.GameManager_.LevelPlaylist_.Add(item);

            G.Sys.GameManager_.NextLevelName_ = item.levelNameAndPath_.levelName_;
            G.Sys.GameManager_.NextLevelPath_ = item.levelNameAndPath_.levelPath_;
            G.Sys.GameManager_.LevelPlaylist_.SetIndex(0);

            MessageUtilities.sendMessage(p, "Playlist cleared !");
        }
Example #12
0
        public override void use(ClientPlayerInfo p, string message)
        {
            const int maxLvls = 10;

            var currentPlaylist = G.Sys.GameManager_.LevelPlaylist_.Playlist_;
            int index           = G.Sys.GameManager_.LevelPlaylist_.Index_;

            if (index >= currentPlaylist.Count)
            {
                Utilities.sendMessage("There are no levels in the playlist !");
                return;
            }

            Utilities.sendMessage("Current and nexts levels:");
            for (int i = 0; i < maxLvls; i++)
            {
                if (i + index >= currentPlaylist.Count)
                {
                    break;
                }
                var map = currentPlaylist[i + index];
                Utilities.sendMessage(map.levelNameAndPath_.levelName_ + " (" + G.Sys.GameManager_.GetModeName(map.mode_) + ")");
            }

            int moreCount = currentPlaylist.Count - (index + maxLvls);

            if (moreCount > 0)
            {
                Utilities.sendMessage("And " + moreCount + " more ...");
            }
        }
Example #13
0
 private void spectatePlayer(ClientPlayerInfo player, bool force = false)
 {
     if (!GeneralUtilities.isOnGamemode())
     {
         return;
     }
     if (!autoSpecAllowPlayers && !player.IsLocal_ && !force)
     {
         return;
     }
     if (spectators.Contains(GeneralUtilities.getUniquePlayerString(player)))
     {
         MessageUtilities.sendMessage(player, "You are in auto-spectate mode. Say " + GeneralUtilities.formatCmd("!autospec") + " to turn it off.");
     }
     Entry.Instance.chatReplicationManager.ReplicateNeeded();
     if (player.IsLocal_)
     {
         if (G.Sys.PlayerManager_.PlayerList_.Count == 1 && GeneralUtilities.isHost() && autoSpecReturnToLobby)
         {
             G.Sys.GameManager_.GoToLobby();
         }
         else
         {
             G.Sys.PlayerManager_.Current_.playerData_.Spectate();
         }
     }
     else
     {
         StaticTargetedEvent <Finished.Data> .Broadcast(player.NetworkPlayer_, default(Finished.Data));
     }
 }
Example #14
0
        public override void use(ClientPlayerInfo p, string message)
        {
            if (message == "" || !Utilities.isHost() || p == null)
            {
                Utilities.sendMessage(G.Sys.NetworkingManager_.serverTitle_);
                return;
            }

            if (!p.IsLocal_)
            {
                Utilities.sendMessage("You don't have the permission to do that !");
                return;
            }

            var words = message.Split(' ');

            if (words[0].ToLower() == "private")
            {
                if (words.Count() < 2)
                {
                    help(p);
                    return;
                }
                setServerPrivate(message.Substring(message.IndexOf(' ') + 1));
                return;
            }

            if (words[0].ToLower() == "public")
            {
                setServerPublic();
                return;
            }

            setServerName(message);
        }
Example #15
0
        public override void use(ClientPlayerInfo p, string message)
        {
            LevelPlaylist playlist = new LevelPlaylist();

            playlist.Copy(G.Sys.GameManager_.LevelPlaylist_);

            if (G.Sys.GameManager_.ModeID_ == GameModeID.Trackmogrify)
            {
                Utilities.sendMessage("You can't manage the playlist in trackmogrify");
                return;
            }

            if (playlist.Count_ == 0)
            {
                Utilities.sendMessage("The playlist is empty !");
                return;
            }

            if (Utilities.isOnGamemode())
            {
                shuffleOnGame(playlist);
            }
            else
            {
                shuffleOnLobby(playlist);
            }

            G.Sys.GameManager_.LevelPlaylist_.SetIndex(0);
            G.Sys.GameManager_.NextLevelName_ = G.Sys.GameManager_.LevelPlaylist_.Playlist_[0].levelNameAndPath_.levelName_;
            G.Sys.GameManager_.NextLevelPath_ = G.Sys.GameManager_.LevelPlaylist_.Playlist_[0].levelNameAndPath_.levelPath_;

            Utilities.sendMessage("Playlist shuffled !");
        }
Example #16
0
        public override void use(ClientPlayerInfo p, string message)
        {
            if (!GeneralUtilities.isOnGamemode())
            {
                MessageUtilities.sendMessage(p, "Can't restart on lobby !");
                return;
            }

            var serverLogic = G.Sys.GameManager_.GetComponent <ServerLogic>();

            if (serverLogic == null)
            {
                MessageUtilities.sendMessage(p, "ServerLogic null !");
                return;
            }

            var clients = (IEnumerable)PrivateUtilities.getPrivateField(serverLogic, "clientInfoList_");

            foreach (var c in clients)
            {
                if (p.NetworkPlayer_ == (UnityEngine.NetworkPlayer)PrivateUtilities.getPrivateField(c, "networkPlayer_"))
                {
                    exec(serverLogic, c);
                    break;
                }
            }
        }
Example #17
0
 public override void help(ClientPlayerInfo p)
 {
     Utilities.sendMessage("!server: Show the server name");
     Utilities.sendMessage("!server [new name]: Modify the server name");
     Utilities.sendMessage("!server private [password]: Set the server private");
     Utilities.sendMessage("!server public: Set the server public");
 }
Example #18
0
 public override void help(ClientPlayerInfo p)
 {
     Utilities.sendMessage("!play [lvl name]: Adds a level to the playlist as the next to be played.");
     Utilities.sendMessage("!play [filter] : Use filters to find a level");
     Utilities.sendMessage("Valid filters : -mode -m -name -n -author -a -index -i -last -l -all");
     Utilities.sendMessage("The level must be know by the server to be show");
 }
Example #19
0
 public override void help(ClientPlayerInfo p)
 {
     Utilities.sendMessage("!level [name]: Find a level who have that keyword on his name");
     Utilities.sendMessage("!level [filter] : Use filters to find a level");
     Utilities.sendMessage("Valid filters : -mode -m -name -n -author -a -index -i");
     Utilities.sendMessage("The level must be know by the server to be show");
 }
Example #20
0
        public override void use(ClientPlayerInfo p, string message)
        {
            if (message == "")
            {
                MessageUtilities.pushMessageOption(new MessageStateOptionPlayer(p));
                printPlaylists();
                MessageUtilities.popMessageOptions();
                return;
            }

            var name = Resource.PersonalLevelPlaylistsDirPath_ + message + ".xml";

            if (!Resource.FileExist(name))
            {
                MessageUtilities.sendMessage(p, "The playlist " + message + " don't exist !");
                return;
            }

            var item = G.Sys.GameManager_.LevelPlaylist_.Count_ == 0 ? null : G.Sys.GameManager_.LevelPlaylist_.Playlist_[G.Sys.GameManager_.LevelPlaylist_.Index_];

            var gameObject   = LevelPlaylist.Load(name);
            var playlistComp = gameObject.GetComponent <LevelPlaylist>();

            G.Sys.GameManager_.LevelPlaylist_.CopyFrom(playlistComp);

            MessageUtilities.sendMessage(p, "Playlist Loaded : " + G.Sys.GameManager_.LevelPlaylist_.Count_ + " levels.");

            if (GeneralUtilities.isOnGamemode() && item != null)
            {
                G.Sys.GameManager_.LevelPlaylist_.Playlist_.Insert(0, item);
            }
        }
Example #21
0
        public override void use(ClientPlayerInfo p, string message)
        {
            LevelPlaylist currentList = G.Sys.GameManager_.LevelPlaylist_;

            if (currentList.Index_ >= currentList.Count_)
            {
                MessageUtilities.sendMessage(p, "There are no levels in the playlist!");
                return;
            }
            else if (currentList.Index_ == currentList.Count_ - 1)
            {
                MessageUtilities.sendMessage(p, "You are on the last level of the playlist!");
                return;
            }

            LevelCmd levelCmd = Cmd.all.getCommand <LevelCmd>("level");

            var levelsUpcoming        = currentList.Playlist_.GetRange(currentList.Index_ + 1, currentList.Count_ - currentList.Index_ - 1);
            FilteredPlaylist filterer = new FilteredPlaylist(levelsUpcoming);

            GeneralUtilities.addFiltersToPlaylist(filterer, p, message, false);

            MessageUtilities.sendMessage(p, "[FFFFFF]Upcoming:[-]");
            MessageUtilities.sendMessage(p, GeneralUtilities.getPlaylistText(filterer, GeneralUtilities.IndexMode.Initial, levelCmd.levelFormat));
        }
Example #22
0
        public override void use(ClientPlayerInfo p, string message)
        {
            Random r     = new Random();
            float  color = (float)r.NextDouble() * 360;

            Utilities.sendMessage("[b][" + ColorEx.ColorToHexNGUI(new ColorHSB(color, 1.0f, 1.0f, 1f).ToColor()) + "]" + winList[r.Next(winList.Count)] + "[-][/b]");
        }
Example #23
0
        public override void use(ClientPlayerInfo p, string message)
        {
            if (message == "")
            {
                help(p);
                return;
            }

            var affects = "";

            foreach (ClientPlayerInfo client in GeneralUtilities.getClientsBySearch(message))
            {
                StaticTargetedEvent <Finished.Data> .Broadcast(client.NetworkPlayer_, default(Finished.Data));

                affects += $"{ client.Username_}, ";
            }
            if (affects == "")
            {
                MessageUtilities.sendMessage(p, "Could not find any players with that name or index");
            }
            else
            {
                MessageUtilities.sendMessage(p, affects + "is now spectating.");
            }
        }
Example #24
0
        public override void use(ClientPlayerInfo p, string message)
        {
            var clientLogic = G.Sys.PlayerManager_.GetComponent <ClientLogic>();

            if (clientLogic == null)
            {
                Utilities.sendMessage("Error : Client logic null !");
                return;
            }

            try
            {
                var client  = clientLogic.GetLocalPlayerInfo();
                var oldName = client.Username_;

                var name = client.GetType().GetField("username_", BindingFlags.NonPublic | BindingFlags.Instance);
                name.SetValue(client, message);

                Utilities.sendMessage(oldName + " renamed to " + client.Username_);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Utilities.sendMessage("Error : can't change your name !");
            }
        }
Example #25
0
        public override void help(ClientPlayerInfo p)
        {
            MessageUtilities.sendMessage(p, GeneralUtilities.formatCmd("!level [name]") + ": Find a level who have that keyword on his name");
            MessageUtilities.sendMessage(p, GeneralUtilities.formatCmd("!level [filter] ") + ": Use filters to find a level");
            List <LevelFilter> filters = new List <LevelFilter>();

            foreach (KeyValuePair <string, LevelFilter> filter in FilteredPlaylist.filterTypes)
            {
                if (!filters.Contains(filter.Value))
                {
                    filters.Add(filter.Value);
                }
            }
            string filtersStr = "";

            foreach (LevelFilter filter in filters)
            {
                foreach (string option in filter.options)
                {
                    filtersStr += "-" + option + " ";
                }
            }
            MessageUtilities.sendMessage(p, "Valid filters: " + filtersStr);
            MessageUtilities.sendMessage(p, "Filter types:  default (and): -filter; not default: !filter; and: &filter; or: |filter; and not: &!filter; or not: |!filter");
            MessageUtilities.sendMessage(p, "The level must be known by the server to be shown");
        }
Example #26
0
        public override void use(ClientPlayerInfo p, string message)
        {
            var clientLogic = G.Sys.PlayerManager_.GetComponent <ClientLogic>();

            if (clientLogic == null)
            {
                MessageUtilities.sendMessage(p, "Error : Client logic null !");
                return;
            }

            try
            {
                var client  = clientLogic.GetLocalPlayerInfo();
                var oldName = client.Username_;

                PrivateUtilities.setPrivateField(client, "username_", message);

                MessageUtilities.sendMessage(p, oldName + " renamed to " + client.Username_);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                MessageUtilities.sendMessage(p, "Error : can't change your name !");
            }
        }
Example #27
0
        public static List <LevelPlaylist.ModeAndLevelInfo> getFilteredLevels(ClientPlayerInfo p, string input)
        {
            var playlist = new FilteredPlaylist(getAllLevelsAndModes());
            var failures = addFiltersToPlaylist(playlist, p, input, true);

            sendFailures(failures, 4);
            return(playlist.Calculate().levelList);
        }
Example #28
0
 public override void help(ClientPlayerInfo p)
 {
     MessageUtilities.sendMessage(p, GeneralUtilities.formatCmd("!welcome") + ": Hear the welcome message.");
     if (GeneralUtilities.isHost())
     {
         MessageUtilities.sendMessage(p, "You can set the welcome message with !settings");
     }
 }
Example #29
0
 public bool playerIsAutoSpec(ClientPlayerInfo p)
 {
     if (!GeneralUtilities.isHost() && !p.IsLocal_)
     {
         return(false);
     }
     return(spectators.Contains(GeneralUtilities.getUniquePlayerString(p)));
 }
Example #30
0
 public LevelPlaylist getActivePlaylist(ClientPlayerInfo p)
 {
     if (p == null)
     {
         return(null);
     }
     return(getActivePlaylist(GeneralUtilities.getUniquePlayerString(p)));
 }