private void OnEnable()
    {
        /*if (!FileBasedPrefs.HasKey(roomSaveKey)) {
         *              //currentRoom = AllRooms[0].name;
         *  FileBasedPrefs.SetString(roomSaveKey, AllRooms[0].name);
         * }*/
        /*  else {
         *    currentRoom = FileBasedPrefs.GetString(roomSaveKey);
         * }*/

        if (!FileBasedPrefs.HasKey(roomSaveKey))
        {
            //currentRoom = AllRooms[0].name;
            FileBasedPrefs.SetString(roomSaveKey, AllRooms[0].name);
        }
        currentRoom = FileBasedPrefs.GetString(roomSaveKey);

        foreach (GameObject level in AllRooms)
        {
            if (level.name.Equals(currentRoom))
            {
                level.SetActive(true);
            }
            else
            {
                level.SetActive(false);
            }
        }
    }
示例#2
0
    public static bool[] GetBoolArray(String key)
    {
        if (FileBasedPrefs.HasKey(key))
        {
            var bytes = System.Convert.FromBase64String(FileBasedPrefs.GetString(key));
            if (bytes.Length < 5)
            {
                Debug.LogError("Corrupt preference file for " + key);
                return(new bool[0]);
            }
            if ((ArrayType)bytes[0] != ArrayType.Bool)
            {
                Debug.LogError(key + " is not a boolean array");
                return(new bool[0]);
            }
            Initialize();

            // Make a new bytes array that doesn't include the number of entries + identifier (first 5 bytes) and turn that into a BitArray
            var bytes2 = new byte[bytes.Length - 5];
            System.Array.Copy(bytes, 5, bytes2, 0, bytes2.Length);
            var bits = new BitArray(bytes2);
            // Get the number of entries from the first 4 bytes after the identifier and resize the BitArray to that length, then convert it to a boolean array
            bits.Length = ConvertBytesToInt32(bytes);
            var boolArray = new bool[bits.Count];
            bits.CopyTo(boolArray, 0);

            return(boolArray);
        }
        return(new bool[0]);
    }
    void Start()
    {
        string spName = GetComponent <SpriteRenderer>().sprite.name;

        if (FileBasedPrefs.HasKey(spName) && (FileBasedPrefs.GetString(spName) == "showed_once"))
        {
            GetComponent <SpriteRenderer>().enabled = true;
            if (GetComponent <BoxCollider>() != null && initialEnableBoxCollider)
            {
                GetComponent <BoxCollider>().enabled = false;
            }
            else if (GetComponent <BoxCollider>() != null && !initialEnableBoxCollider)
            {
                GetComponent <BoxCollider>().enabled = true;
            }
        }
        else
        {
            GetComponent <SpriteRenderer>().enabled = false;
            if (GetComponent <BoxCollider>() != null && initialEnableBoxCollider)
            {
                GetComponent <BoxCollider>().enabled = true;
            }
            else if (GetComponent <BoxCollider>() != null && !initialEnableBoxCollider)
            {
                GetComponent <BoxCollider>().enabled = false;
            }
        }
    }
示例#4
0
    public static void ShowArrayType(String key)
    {
        var bytes = System.Convert.FromBase64String(FileBasedPrefs.GetString(key));

        if (bytes.Length > 0)
        {
            ArrayType arrayType = (ArrayType)bytes[0];
            Debug.Log(key + " is a " + arrayType.ToString() + " array");
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     if (FileBasedPrefs.HasKey(gameObject.name) && FileBasedPrefs.GetString(gameObject.name) == "showed_once")
     {
         gameObject.SetActive(true);
     }
     else
     {
         gameObject.SetActive(false);
     }
 }
 void Start()
 {
     if (FileBasedPrefs.HasKey(gameObject.name))
     {
         if (FileBasedPrefs.GetString(gameObject.name) == "showed_once")
         {
             Debug.Log("<b>Object Showing</b> " + gameObject.name);
             gameObject.SetActive(true);
         }
         else if (FileBasedPrefs.GetString(gameObject.name) == "hidden_once")
         {
             Debug.Log("<b>Object Hiding</b> " + gameObject.name);
             gameObject.SetActive(false);
         }
     }
 }
    void StringTests()
    {
        FileBasedPrefs.SetString("test", "test");

        if (!FileBasedPrefs.GetString("test").Equals("test"))
        {
            Debug.LogException(new System.Exception("SetStringFailed"));
            return;
        }

        FileBasedPrefs.SetString("test", "test2");

        if (!FileBasedPrefs.GetString("test").Equals("test2"))
        {
            Debug.LogException(new System.Exception("ReplaceStringFailed"));
            return;
        }

        if (!FileBasedPrefs.HasKeyForString("test"))
        {
            Debug.LogException(new System.Exception("HasKeyForStringFailed"));
            return;
        }

        FileBasedPrefs.DeleteString("test");

        if (!FileBasedPrefs.GetString("test").Equals(""))
        {
            Debug.LogException(new System.Exception("DeleteStringFailed"));
            return;
        }

        FileBasedPrefs.SetString("test", "test33");

        if (!FileBasedPrefs.GetString("test").Equals("test33"))
        {
            Debug.LogException(new System.Exception("ReplaceStringFailed"));
            return;
        }

        Debug.Log("String Tests Passed");
    }
    //! Loads data from .sav file.
    private void LoadDataFromFile()
    {
        inventory = new InventorySlot[16];
        int count = 0;

        while (count <= 15)
        {
            inventory[count] = gameObject.AddComponent <InventorySlot>();
            string countType = FileBasedPrefs.GetString(stateManager.worldName + "inventory" + ID + "slot" + count + "type");
            if (!countType.Equals(""))
            {
                inventory[count].typeInSlot   = FileBasedPrefs.GetString(stateManager.worldName + "inventory" + ID + "slot" + count + "type");
                inventory[count].amountInSlot = FileBasedPrefs.GetInt(stateManager.worldName + "inventory" + ID + "slot" + count + "amount");
            }
            count++;
        }
        originalID   = ID;
        initialized  = true;
        maxStackSize = ID.Equals("Rocket") ? 100000 : 1000;
    }
示例#9
0
    public static String[] GetStringArray(String key)
    {
        if (FileBasedPrefs.HasKey(key))
        {
            var completeString = FileBasedPrefs.GetString(key);
            var separatorIndex = completeString.IndexOf("|"[0]);
            if (separatorIndex < 4)
            {
                Debug.LogError("Corrupt preference file for " + key);
                return(new String[0]);
            }
            var bytes = System.Convert.FromBase64String(completeString.Substring(0, separatorIndex));
            if ((ArrayType)bytes[0] != ArrayType.String)
            {
                Debug.LogError(key + " is not a string array");
                return(new String[0]);
            }
            Initialize();

            var numberOfEntries = bytes.Length - 1;
            var stringArray     = new String[numberOfEntries];
            var stringIndex     = separatorIndex + 1;
            for (var i = 0; i < numberOfEntries; i++)
            {
                int stringLength = bytes[idx++];
                if (stringIndex + stringLength > completeString.Length)
                {
                    Debug.LogError("Corrupt preference file for " + key);
                    return(new String[0]);
                }
                stringArray[i] = completeString.Substring(stringIndex, stringLength);
                stringIndex   += stringLength;
            }

            return(stringArray);
        }
        return(new String[0]);
    }
示例#10
0
    private static void GetValue <T>(String key, T list, ArrayType arrayType, int vectorNumber, Action <T, byte[]> convert) where T : IList
    {
        if (FileBasedPrefs.HasKey(key))
        {
            var bytes = System.Convert.FromBase64String(FileBasedPrefs.GetString(key));
            if ((bytes.Length - 1) % (vectorNumber * 4) != 0)
            {
                Debug.LogError("Corrupt preference file for " + key);
                return;
            }
            if ((ArrayType)bytes[0] != arrayType)
            {
                Debug.LogError(key + " is not a " + arrayType.ToString() + " array");
                return;
            }
            Initialize();

            var end = (bytes.Length - 1) / (vectorNumber * 4);
            for (var i = 0; i < end; i++)
            {
                convert(list, bytes);
            }
        }
    }
示例#11
0
    // Token: 0x06000ABC RID: 2748 RVA: 0x00042A68 File Offset: 0x00040C68
    private void SetupMoneyReward()
    {
        int num;

        if (PlayerPrefs.GetInt("MissionType") == 0)
        {
            num = 10;
        }
        else if (PlayerPrefs.GetInt("MissionType") == 1)
        {
            num = 30;
        }
        else
        {
            num = 45;
        }
        int num2 = 0;

        if (FileBasedPrefs.GetInt("PlayerDied", 0) == 0)
        {
            this.mainMissionRewardText.text   = ((PlayerPrefs.GetInt("MainMission") == 1) ? ("$" + num) : "$0");
            this.sideMission1RewardText.text  = ((PlayerPrefs.GetInt("SideMission1") == 1) ? "$10" : "$0");
            this.sideMission2RewardText.text  = ((PlayerPrefs.GetInt("SideMission2") == 1) ? "$10" : "$0");
            this.hiddenMissionRewardText.text = ((PlayerPrefs.GetInt("SideMission3") == 1) ? "$10" : "$0");
            this.totalPhotosRewardText.text   = "$" + this.GetPhotosRewardAmount().ToString();
            this.totalDNARewardText.text      = ((PlayerPrefs.GetInt("DNAMission") == 1) ? "$10" : "$0");
            num2 += ((PlayerPrefs.GetInt("MainMission") == 1) ? num : 0);
            num2 += ((PlayerPrefs.GetInt("SideMission1") == 1) ? 10 : 0);
            num2 += ((PlayerPrefs.GetInt("SideMission2") == 1) ? 10 : 0);
            num2 += ((PlayerPrefs.GetInt("SideMission3") == 1) ? 10 : 0);
            num2 += this.GetPhotosRewardAmount();
            num2 += ((PlayerPrefs.GetInt("DNAMission") == 1) ? 10 : 0);
            if (this.levelDifficulty == Contract.LevelDifficulty.Intermediate)
            {
                num2 *= 2;
            }
            else if (this.levelDifficulty == Contract.LevelDifficulty.Professional)
            {
                num2 *= 3;
            }
            if (PlayerPrefs.GetInt("playerCount") == 1)
            {
                if (PlayerPrefs.GetInt("MainMission") == 1)
                {
                    this.insuranceAmountText.text = "$10";
                    num2 += 10;
                }
            }
            else
            {
                this.insuranceAmountText.text = "$0";
            }
        }
        else
        {
            this.mainMissionRewardText.text   = ((PlayerPrefs.GetInt("MainMission") == 1) ? ("$" + num / 2) : "$0");
            this.sideMission1RewardText.text  = ((PlayerPrefs.GetInt("SideMission1") == 1) ? "$5" : "$0");
            this.sideMission2RewardText.text  = ((PlayerPrefs.GetInt("SideMission2") == 1) ? "$5" : "$0");
            this.hiddenMissionRewardText.text = ((PlayerPrefs.GetInt("SideMission3") == 1) ? "$5" : "$0");
            this.totalPhotosRewardText.text   = "$" + (this.GetPhotosRewardAmount() / 2).ToString();
            this.totalDNARewardText.text      = ((PlayerPrefs.GetInt("DNAMission") == 1) ? "$5" : "$0");
            num2 += ((PlayerPrefs.GetInt("MainMission") == 1) ? (num / 2) : 0);
            num2 += ((PlayerPrefs.GetInt("SideMission1") == 1) ? 5 : 0);
            num2 += ((PlayerPrefs.GetInt("SideMission2") == 1) ? 5 : 0);
            num2 += ((PlayerPrefs.GetInt("SideMission3") == 1) ? 5 : 0);
            num2 += this.GetPhotosRewardAmount() / 2;
            num2 += ((PlayerPrefs.GetInt("DNAMission") == 1) ? 5 : 0);
            int num3 = 0;
            if (this.levelDifficulty == Contract.LevelDifficulty.Amateur)
            {
                num3 += PlayerPrefs.GetInt("totalItemCost") / 2;
            }
            else if (this.levelDifficulty == Contract.LevelDifficulty.Intermediate)
            {
                num3 += PlayerPrefs.GetInt("totalItemCost") / 4;
            }
            this.insuranceAmountText.text = "$" + num3.ToString();
            num2 += num3;
            PlayerPrefs.SetInt("totalItemCost", 0);
        }
        this.ghostTypeText.text = LocalisationSystem.GetLocalisedValue("Reward_Ghost") + " " + FileBasedPrefs.GetString("GhostType", "");
        FileBasedPrefs.SetInt("PlayersMoney", FileBasedPrefs.GetInt("PlayersMoney", 0) + num2);
        this.totalMissionRewardText.text = "$" + num2.ToString();
        InventoryManager.ResetTemporaryInventory();
        PlayerPrefs.SetInt("PhotosMission", 0);
        PlayerPrefs.SetInt("MainMission", 0);
        PlayerPrefs.SetInt("MissionType", 0);
        PlayerPrefs.SetInt("SideMission1", 0);
        PlayerPrefs.SetInt("SideMission2", 0);
        PlayerPrefs.SetInt("SideMission3", 0);
        PlayerPrefs.SetInt("DNAMission", 0);
        PlayerPrefs.SetInt("PhotosMission", 0);
        FileBasedPrefs.SetInt("PlayerDied", 0);
        this.storeManager.UpdatePlayerMoneyText();
        this.playerStatsManager.UpdateMoney();
        this.inventoryManager.UpdateItemsTotalText();
    }
示例#12
0
    // Token: 0x06000A71 RID: 2673 RVA: 0x00040F6F File Offset: 0x0003F16F
    public IEnumerator Start()
    {
        if (!PhotonNetwork.connected && !PhotonNetwork.offlineMode)
        {
            FileBasedPrefs.SetInt("StayInServerRoom", 0);
        }
        this.serverVersionText.text = LocalisationSystem.GetLocalisedValue("Menu_ServerVersion") + ": " + this.storeSDKManager.serverVersion;
        yield return(new WaitForSeconds(0.5f));

        if (!XRDevice.isPresent)
        {
            for (int i = 0; i < this.spawns.Count; i++)
            {
                this.spawns[i].Translate(Vector3.up);
            }
        }
        if (!PhotonNetwork.connected || PhotonNetwork.offlineMode)
        {
            if (PhotonNetwork.offlineMode)
            {
                PhotonNetwork.offlineMode = false;
            }
            if (this.storeSDKManager.storeSDKType == StoreSDKManager.StoreSDKType.steam)
            {
                this.steamAuth.ConnectViaSteamAuthenticator();
            }
            if (XRDevice.isPresent)
            {
                this.localPlayer = Object.Instantiate <GameObject>(this.vrPlayerModel, this.spawns[Random.Range(0, this.spawns.Count)].position, Quaternion.identity).GetComponent <Player>();
            }
            else
            {
                this.localPlayer = Object.Instantiate <GameObject>(this.pcPlayerModel, this.spawns[Random.Range(0, this.spawns.Count)].position, Quaternion.identity).GetComponent <Player>();
                this.pcManager.SetValues();
            }
            FileBasedPrefs.SetInt("StayInServerRoom", 0);
            this.LoadRewardScreens();
        }
        else if (FileBasedPrefs.GetInt("StayInServerRoom", 0) == 1)
        {
            PhotonNetwork.LeaveRoom(true);
        }
        else
        {
            FileBasedPrefs.SetInt("StayInServerRoom", 0);
            PhotonNetwork.LeaveRoom(true);
        }
        if (FileBasedPrefs.GetInt("completedTraining", 0) == 0 && !Application.isEditor)
        {
            this.serverLobbyButton.interactable = false;
            this.serverLobbyText.color          = new Color32(50, 50, 50, 119);
        }
        FileBasedPrefs.SetInt("isTutorial", 0);
        this.trainingGhostTypeText.text = LocalisationSystem.GetLocalisedValue("Reward_Ghost") + " " + FileBasedPrefs.GetString("GhostType", "");
        this.SetScreenResolution();
        if (FileBasedPrefs.GetInt("myTotalExp", 0) < 100)
        {
            FileBasedPrefs.SetInt("myTotalExp", 100);
        }
        if (FileBasedPrefs.GetInt("myTotalExp", 0) < 100)
        {
            FileBasedPrefs.SetInt("myTotalExp", 100);
        }
        yield break;
    }