Example #1
0
 void Start()
 {
     anim        = GetComponent <Animator>();
     newScale    = transform.localScale;
     newScaleX   = newScale.x;
     playerState = GetComponent <playerBase>();
 }
Example #2
0
 // Start is called before the first frame update
 void Start()
 {
     Physics2D.IgnoreLayerCollision(8, 11);
     player      = GameObject.FindGameObjectWithTag("Player");
     playerState = player.GetComponent <playerBase>();
     playerMov   = player.GetComponent <playerMovement>();
     anim        = GetComponent <animHandler>();
 }
Example #3
0
    public void DoAction(playerBase player)
    {
        GlobalSettings.PrintDebug(item.ToString());

        storageBase inv = player.PlayerData.Inventory;
        if(inv.CheckAvailableSlots(item))
            Destroy(gameObject);
    }
Example #4
0
    public void CloseContainer(playerBase player)
    {
        CanvasGroup panel;
        GUIController gui;
        gui = player.GetComponentInParent<InputManager>().gui;
        panel = gui.ContainerPanel;

        gui.Container = null;

        StartCoroutine(gui.fadeOut(panel));
        gui.ToggleInventory(false);
    }
Example #5
0
    public void DoAction(playerBase player)
    {
        GlobalSettings.PrintDebug("Clicked on container " + ContainerName);
        CanvasGroup panel;
        GUIController gui;
        gui = player.GetComponentInParent<InputManager>().gui;
        panel = gui.ContainerPanel;

        if (gui.Container == null)
        {
            gui.Container = this;
            panel.transform.FindChild("Details").FindChild("Header").GetComponent<Text>().text = ContainerName;

            for (int r = 0; r < Storage.Rows; r++)
            {
                for (int c = 0; c < Storage.Cols; c++)
                {

                    GameObject slot = (GameObject)Instantiate(Resources.Load("emptySlot"));

                    //slot.transform.SetParent.transform.FindChild("SlotHolder"));
                    slot.transform.SetParent(panel.transform.FindChild("SlotHolder"));
                    slot.GetComponent<RectTransform>().anchoredPosition = new Vector2(64 * c, -64 * r);
                   // slot.GetComponent<Transform>().position = new Vector3(slot.transform.position.x, slot.transform.position.y, 0);

                    slot.name = "X" + c + "Y" + r;
                    slot.GetComponent<slotScript>().x = c;
                    slot.GetComponent<slotScript>().y = r;
                    slot.GetComponent<RectTransform>().localScale = new Vector3(1, 1, 1);

                    slot.GetComponent<RectTransform>().localPosition =
        new Vector3(slot.GetComponent<RectTransform>().localPosition.x,
         slot.GetComponent<RectTransform>().localPosition.y,
         0);

                    Storage.Slots[c, r] = slot.GetComponent<slotScript>();
                    slot.GetComponent<slotScript>().slotNum = Storage.Slots[c, r].ToString();

                }
            }

            panel.GetComponent<RectTransform>().sizeDelta = new Vector2(64 * Storage.Cols, (64 * Storage.Rows) + 30);
            StartCoroutine(gui.fadeIn(panel));
            gui.ToggleInventory(true);
        }
        else
        {
            GlobalSettings.PrintDebug("Can't open two containers!");
        }
        //inventoryHeader.text = "Inventory - " + Player.PlayerData.Name;
        //GlobalSettings.PrintDebug(item.ToString());

        //storageBase inv = player.PlayerData.Inventory;
        //if (inv.CheckAvailableSlots(item))
        //    Destroy(gameObject);
    }