//! Called by unity engine on start up to initialize variables.
 public void Start()
 {
     playerController   = GetComponent <PlayerController>();
     machineInteraction = new MachineInteraction(playerController, this);
     storageInteraction = new StorageInteraction(playerController, this);
     blockInteraction   = new BlockInteraction(playerController, this);
 }
Ejemplo n.º 2
0
    public void CreateInterface(StorageInteraction si)
    {
        // guard from multiple interactions ////
        interactions += 1;
        if (interactions > 1)
        {
            return;
        }
        ////////////////////////////////////////

        if (si.contents.Count > 0)
        {
            header.text = "Contents:";
        }
        else
        {
            header.text = "Empty";
        }

        for (int i = 0; i < si.contents.Count; i++)
        {
            GameObject g = Instantiate(buttonprefab, transform);
            g.GetComponent <RectTransform>().localPosition = new Vector3(0f, (0f - (20f * i)), 0f);
            var text = g.GetComponent <UnityEngine.UI.Text>();
            text.text = outfits.nameMap[si.contents[i].item.name];
            var button = g.GetComponentInChildren <UnityEngine.UI.Button>();
            int index  = i;
            button.onClick.AddListener(() => ButtonOnClick(si, index));
        }
    }
Ejemplo n.º 3
0
    void ButtonOnClick(StorageInteraction s, int ind)
    {
        // if there is an active object
        if (outfits.mmomData.currentHat != null)
        {
            // get it, add to storage, and deactivate
            GameObject g = outfits.mmomData.currentHat.gameObject;
            s.AddContents(g, ItemType.hats);
            g.SetActive(false);
        }

        // make new hat current hat, activate, remove from storage
        outfits.mmomData.currentHat = s.contents[ind].item.transform;
        s.contents[ind].item.SetActive(true);
        s.RemoveContents(s.contents[ind]);
        HideInterface();
    }