Esempio n. 1
0
    public void chooseItem(int index)
    {
        BinaryFormatter bf = new BinaryFormatter();
        FileStream      file;

        string[] currentInv = ReadScript.Read <string[]> ("Inventory");
        if (currentInv == default(string[]))
        {
            currentInv = new string[0];
        }
        string[] newInv = new string[currentInv.Length + lm.items.Length];
        int      i      = 0;

        foreach (string name in currentInv)
        {
            newInv [i] = currentInv [i++];
        }
        newInv [i++] = lm.items[index].name.Replace("(Clone)", "");

        foreach (Button button in lm.itemSlots)
        {
            button.gameObject.SetActive(false);
        }
        lm.lootText.text = lm.items [index].itemName + " added to Inventory.";
        lm.HideTooltip();

        file = File.Create(Application.persistentDataPath + "/Inventory.dat");
        bf.Serialize(file, newInv);
        file.Close();
        //Save progress
        GameObject.Find("ShapesManager").GetComponent <ShapesManager> ().SaveProgress();
        ContinueButton.interactable = true;
    }