コード例 #1
0
        //This is for a future update :D
        //const string SteamApiKey = "D57A6B0437CB735FFEE9317A9D42CCAA";

        protected override void Load()
        {
            instance = this;

            RocketLogger.Log(string.Format("Welcome to Gun Game v{0}!", Assembly.GetName().Version), ConsoleColor.Yellow);
            RocketLogger.Log("For any update information or support join my Discord Guild: discord.gg/BaE4Tka!", ConsoleColor.Yellow);

            GunGameConfig.Initialize();
            GameManager.Initialize();
            CommandManager.Initialize();
            EconomyManager.Initialize();

            if (GunGameConfig.instance.sqlSettings.enabled)
            {
                if (!SQLManager.Initialize())
                {
                    GunGamePlayerConfig.Initialize();
                    IsMySqlEnabled = false;
                    RocketLogger.Log("NOTE: Connection to MySQL database failed!", ConsoleColor.Red);
                    RocketLogger.Log("Initialized with MySQL support disabled.", ConsoleColor.Yellow);
                }
                else
                {
                    RocketLogger.Log("Initialized with MySQL support enabled.", ConsoleColor.Yellow);
                }
            }
            else
            {
                GunGamePlayerConfig.Initialize();
                IsMySqlEnabled = false;
                RocketLogger.Log("Initialized with MySQL support disabled.", ConsoleColor.Yellow);
            }

            EventManager.Register();

            if (GunGameConfig.instance.positions[0].x == 0 && GunGameConfig.instance.positions[0].y == 0 && GunGameConfig.instance.positions[0].z == 0)
            {
                RocketLogger.Log("NOTE: You have not set any spawn positions yet!", ConsoleColor.Yellow);
            }

            if (GunGameConfig.instance.safezone.x == 0 && GunGameConfig.instance.safezone.y == 0 && GunGameConfig.instance.safezone.z == 0)
            {
                RocketLogger.Log("NOTE: You have not set the lobby yet!", ConsoleColor.Yellow);
            }

            isLoaded = true;
        }
コード例 #2
0
        public static void Initialize()
        {
            if (File.Exists(Directory))
            {
                string file = File.ReadAllText(Directory);

                try {
                    JObject jObj = JObject.Parse(file);
                    instance = new GunGameConfig();

                    bool hasDefaulted = false;

                    //All basic assignments
                    Assign(jObj, "MinimumPlayers", ref instance.minPlayers, Default.minPlayers, ref hasDefaulted);
                    Assign(jObj, "RoundTime", ref instance.maxRoundTime, Default.maxRoundTime, ref hasDefaulted);
                    Assign(jObj, "BroadcastKills", ref instance.broadcastKills, Default.broadcastKills, ref hasDefaulted);
                    Assign(jObj, "MaxSkills", ref instance.maxSkills, Default.maxSkills, ref hasDefaulted);
                    Assign(jObj, "MuteGlobalChat", ref instance.mutePlayers, Default.mutePlayers, ref hasDefaulted);
                    Assign(jObj, "ForceNoGroups", ref instance.forceNoGroup, Default.forceNoGroup, ref hasDefaulted);
                    Assign(jObj, "DisableCosmetics", ref instance.disableCosmetics, Default.disableCosmetics, ref hasDefaulted);

                    //Assign(jObj, "Lobby", ref instance.safezone, Default.safezone, ref hasDefaulted);
                    //Assign(jObj, "SpawnPositions", ref instance.positions, Default.positions);

                    JObject lobby = (JObject)jObj["Safezone"];

                    if (lobby != null)
                    {
                        instance.safezone = new SpawnPosition();
                        ref SpawnPosition lobbySettings = ref instance.safezone;

                        Assign(lobby, "x", ref lobbySettings.x, 0f, ref hasDefaulted);
                        Assign(lobby, "y", ref lobbySettings.y, 0f, ref hasDefaulted);
                        Assign(lobby, "z", ref lobbySettings.z, 0f, ref hasDefaulted);
                        Assign(lobby, "rot", ref lobbySettings.rot, 0f, ref hasDefaulted);
                    }
                    else
                    {
                        instance.safezone = Default.safezone;
                        hasDefaulted      = true;
                    }

                    JObject econ = (JObject)jObj["EconomySettings"];

                    if (econ != null)
                    {
                        instance.econSettings = new EconomySettings();
                        ref EconomySettings econSettings = ref instance.econSettings;

                        Assign(econ, "Enabled", ref econSettings.enabled, false, ref hasDefaulted);

                        JArray rewards = (JArray)econ["Rewards"];

                        if (rewards != null)
                        {
                            ref Reward[] rewardsSettings = ref econSettings.rewards;
                            rewardsSettings = new Reward[rewards.Count];

                            for (int i = 0; i < rewards.Count; i++)
                            {
                                Reward  temp    = new Reward();
                                JObject tempObj = (JObject)rewards[i];

                                Assign(tempObj, "Place", ref temp.place, (byte)0, ref hasDefaulted);
                                Assign(tempObj, "OrdinalIndicator", ref temp.ordinal, string.Empty, ref hasDefaulted);
                                Assign(tempObj, "Reward", ref temp.reward, 0, ref hasDefaulted);

                                rewardsSettings[i] = temp;
                            }
                        }