Ejemplo n.º 1
0
        public static void SetBool(string key, bool value)
        {
            // do cheat key exist
            if (!CheatsSettings.GetOrCreateSettings().DoCheatKeyExist(key))
            {
                Debug.LogErrorFormat("Key {0} doesn't exist in CheatsSettings. Aborting method.", key);
                return;
            }

            // prevent useless calculations
            if (value == GetBool(key))
            {
                return;
            }

            // turn bool into float
            float floatValue = value ? 1 : 0;

            // PlayerPrefs doesn't have "SetBool" value
            PlayerPrefs.SetFloat(playerPrefsPrefix + key, floatValue);

            // find cheat type of key
            bool cheatTypeFounded = CheatsSettings.GetOrCreateSettings().TryGetCheatType(key, out CheatType cheatType);

            if (!cheatTypeFounded)
            {
                Debug.LogFormat("cheatTypeFounded should always be true. There is something weird in the code. Call your coder please.");
                return;
            }

            OnCheatChanged?.Invoke(key, cheatType);
        }
Ejemplo n.º 2
0
        public static void ToggleBool(string key)
        {
            // do cheat key exist
            if (!CheatsSettings.GetOrCreateSettings().DoCheatKeyExist(key))
            {
                Debug.LogErrorFormat("Key {0} doesn't exist in CheatsSettings. Aborting method.", key);
                return;
            }

            SetBool(key, !GetBool(key));
        }
Ejemplo n.º 3
0
        public static bool GetBool(string key)
        {
            if (!CheatsSettings.GetOrCreateSettings().DoCheatKeyExist(key))
            {
                Debug.LogErrorFormat("Key {0} doesn't exist in CheatsSettings. Aborting.", key);
                return(false);
            }

            float value = PlayerPrefs.GetFloat(playerPrefsPrefix + key);

            // float to boolean
            bool output = (value == 1);

            return(output);
        }