コード例 #1
0
        public static bool ChangeDifficulty(Players.Player player, ColonyState state, string difficulty)
        {
            if (APIConfiguration.DifficutlyCanBeChanged)
            {
                if (!GameDifficulty.GameDifficulties.ContainsKey(difficulty))
                {
                    UnknownCommand(player, difficulty);
                    return(true);
                }

                var newDiff = GameDifficulty.GameDifficulties[difficulty];

                if (newDiff.Rank >= APIConfiguration.MinDifficulty.Rank)
                {
                    state.Difficulty = newDiff;

                    PandaChat.Send(player, _localizationHelper, "CurrentDifficulty", ChatColor.green, state.Difficulty.Name);

                    NetworkUI.NetworkMenuManager.SendColonySettingsUI(player);
                    return(true);
                }

                NetworkUI.NetworkMenuManager.SendColonySettingsUI(player);
                PandaChat.Send(player, _localizationHelper, "DisabledBelow", ChatColor.green, APIConfiguration.MinDifficulty.Name);
            }

            return(true);
        }
コード例 #2
0
        public static void PossibleCommands(Players.Player player, ChatColor color)
        {
            if (player.ActiveColony != null)
            {
                PandaChat.Send(player, _localizationHelper, "CurrentDifficulty", color, ColonyState.GetColonyState(player.ActiveColony).Difficulty.Name);
                PandaChat.Send(player, _localizationHelper, "PossibleCommands", color);

                var diffs = string.Empty;

                foreach (var diff in GameDifficulty.GameDifficulties)
                {
                    diffs += diff.Key + " | ";
                }

                PandaChat.Send(player, _localizationHelper, "/difficulty " + diffs.Substring(0, diffs.Length - 2), color);
            }
        }
コード例 #3
0
        public bool TryDoCommand(Players.Player player, string chat, List <string> split)
        {
            if (!chat.StartsWith("/difficulty", StringComparison.OrdinalIgnoreCase) ||
                !chat.StartsWith("/dif", StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }

            if (player == null || player.ID == NetworkID.Server || player.ActiveColony == null)
            {
                return(true);
            }

            var array = new List <string>();

            CommandManager.SplitCommand(chat, array);

            var state = ColonyState.GetColonyState(player.ActiveColony);

            if (array.Count == 1)
            {
                PandaChat.Send(player, _localizationHelper, "CurrentDifficulty", ChatColor.green, state.Difficulty.Name);
                return(true);
            }

            if (array.Count < 2)
            {
                UnknownCommand(player, chat);
                return(true);
            }

            if (array.Count == 2)
            {
                var difficulty = array[1].Trim();

                return(ChangeDifficulty(player, state, difficulty));
            }

            if (!APIConfiguration.DifficutlyCanBeChanged)
            {
                PandaChat.Send(player, _localizationHelper, "DifficultyChangeDisabled", ChatColor.green);
            }

            return(true);
        }
コード例 #4
0
 private static void UnknownCommand(Players.Player player, string command)
 {
     PandaChat.Send(player, _localizationHelper, "UnknownCommand", ChatColor.white, command);
     PossibleCommands(player, ChatColor.white);
 }