Exemplo n.º 1
0
    private void LoadEquipment() //this will replace the current items
    {
        try
        {
            string loadData = USecurity.DecryptString(PlayerPrefs.GetString(saveName + ".eqm"), encryptPassword);

            string itemsString = USecurity.ExtractBetween(loadData, "[items]", "[/items]", false);

            equip.equipmentSlots.Clear();

            string[] itemLines = itemsString.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            for (int i = 0; i < itemLines.Length; i++)
            {
                if (itemLines[i] != "")
                {
                    if (itemLines[i] != "-1")
                    {
                        equip.equipmentSlots.Add(itemsList.allItems[int.Parse(itemLines[i])]);
                    }
                    else
                    {
                        equip.equipmentSlots.Add(null);
                    }
                }
            }
            equip.UpdateEquipmentUI();
        }
        catch (Exception ex)
        {
            Debug.LogException(ex);
        }
    }
Exemplo n.º 2
0
    public void LoadInventory() //this will replace the current items
    {
        try
        {
            string loadData = USecurity.DecryptString(PlayerPrefs.GetString(saveName), encryptPassword);

            string Lver        = USecurity.ExtractBetween(loadData, "[ver]", "[/ver]", false);
            bool   Lforce_ver  = bool.Parse(USecurity.ExtractBetween(loadData, "[force_ver]", "[/force_ver]", false));
            string itemsString = USecurity.ExtractBetween(loadData, "[items]", "[/items]", false);
            string stackString = USecurity.ExtractBetween(loadData, "[stack]", "[/stack]", false);
            string durString   = USecurity.ExtractBetween(loadData, "[dur]", "[/dur]", false);
            loadData = "0";
            if (Lforce_ver == false)
            {
                if (Lver == UI_Inventory.currentVersion)
                {
                    LoadItems(itemsString, stackString, durString);
                }
                else
                {
                    Debug.LogError("Save version is incompatible!");
                }
            }
            else
            {
                Debug.Log("Save file's version is forced!");
                LoadItems(itemsString, stackString, durString);
            }
        }
        catch (Exception ex)
        {
            Debug.LogException(ex);
        }
        LoadHotbar();
        LoadEquipment();
    }
Exemplo n.º 3
0
    private void LoadHotbar() //this will replace the current items
    {
        try
        {
            string loadData = USecurity.DecryptString(PlayerPrefs.GetString(saveName + ".htb"), encryptPassword);

            string itemsString = USecurity.ExtractBetween(loadData, "[items]", "[/items]", false);
            string stackString = USecurity.ExtractBetween(loadData, "[stack]", "[/stack]", false);
            string durString   = USecurity.ExtractBetween(loadData, "[dur]", "[/dur]", false);
            loadData = "0";

            htbar.hotbarSlots.Clear();
            htbar.hotbarStack.Clear();
            htbar.hotDurability.Clear();

            string[] itemLines = itemsString.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            for (int i = 0; i < itemLines.Length; i++)
            {
                if (itemLines[i] != "")
                {
                    if (itemLines[i] != "-1")
                    {
                        htbar.hotbarSlots.Add(itemsList.allItems[int.Parse(itemLines[i])]);
                    }
                    else
                    {
                        htbar.hotbarSlots.Add(null);
                    }
                }
            }

            string[] stackLines = stackString.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            for (int i = 0; i < stackLines.Length; i++)
            {
                if (stackLines[i] != "")
                {
                    if (stackLines[i] != "-1")
                    {
                        htbar.hotbarStack.Add(int.Parse(stackLines[i]));
                    }
                    else
                    {
                        htbar.hotbarStack.Add(0);
                    }
                }
            }

            string[] durLines = durString.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            for (int i = 0; i < durLines.Length; i++)
            {
                if (durLines[i] != "")
                {
                    if (durLines[i] != "-1")
                    {
                        htbar.hotDurability.Add(float.Parse(durLines[i]));
                    }
                    else
                    {
                        htbar.hotDurability.Add(0);
                    }
                }
            }

            htbar.UpdateHotbarUI();
        }
        catch (Exception ex)
        {
            Debug.LogException(ex);
        }
    }