Exemplo n.º 1
0
    /// <summary>
    /// Raises the pointer click event.
    /// </summary>
    /// <param name="eventData">Event data.</param>
    public void OnPointerClick(PointerEventData eventData)
    {
        DadCell cell = this.GetComponentInParent <DadCell>();

        if (cell.loc == DadCell.Location.crate)
        {
            DadCell[] cells = FindObjectsOfType <DadCell>();
            for (int i = 0; i < cells.Length; i++)
            {
                if (cells[i].GetDadItem() == null && cells[i].loc == DadCell.Location.backpack)
                {
                    if (cell.GetComponentInChildren <ClickItem>().type == Type.scroll)
                    {
                        int       win    = 0;
                        DadCell[] cellsI = FindObjectOfType <DummyInventoryControl>().inventory.GetComponentsInChildren <DadCell>();
                        for (int j = 0; j < cellsI.Length; j++)
                        {
                            if (cellsI[j].GetItem() != null && cellsI[j].GetComponentInChildren <ClickItem>().type == ClickItem.Type.scroll)
                            {
                                win++;
                            }
                        }
                        if (win == 8)
                        {
                            TimeController.butterflies = 9;
                            SceneManager.LoadScene("DeathScene");
                        }
                    }
                    cells[i].AddItem(cell.GetItem());
                    cell.RemoveItem();
                    cell.UpdateBackgroundState();
                    break;
                }
            }
        }
        else if (cell.loc == DadCell.Location.backpack && this.type == Type.consumable)
        {
            DadItem.eat(cell, this);
        }
        else if (cell.loc == DadCell.Location.backpack && this.type == Type.weapon)
        {
            DadCell[] cells = FindObjectsOfType <DadCell>();
            for (int i = 0; i < cells.Length; i++)
            {
                if (cells[i].GetDadItem() == null && cells[i].loc == DadCell.Location.body)
                {
                    cells[i].AddItem(cell.GetItem());
                    cell.RemoveItem();
                    cell.UpdateBackgroundState();
                    break;
                }
            }
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// Updates stack's condition.
    /// </summary>
    private void UpdateCondition()
    {
        int stack = GetStack();

        if (stack > 1)
        {
            ShowStack();
        }
        else if (stack == 1)
        {
            // Hide stack text if stack == 0
            HideStack();
        }
        else
        {
            // Stack <= 0
            DadCell dadCell = Gets.GetComponentInParent <DadCell>(transform);
            if (dadCell != null)
            {
                dadCell.RemoveItem();
            }
            else
            {
                Destroy(gameObject);
            }
        }
    }
Exemplo n.º 3
0
    public static void burn(DadCell cell, ClickItem item)
    {
        SpiderSpawner[] spiders = FindObjectsOfType <SpiderSpawner>();
        int             index   = -1;
        float           dist    = 100;

        for (int i = 0; i < spiders.Length; i++)
        {
            Vector3 relative = GameObject.FindGameObjectWithTag("Dreamer").transform.InverseTransformPoint(spiders[i].transform.position);
            if (relative.x < 3 && relative.x > -3 && relative.z > 0 && dist > Vector3.Distance(spiders[i].transform.position, GameObject.FindGameObjectWithTag("Dreamer").transform.position))
            {
                index = i;
                dist  = Vector3.Distance(spiders[i].transform.position, GameObject.FindGameObjectWithTag("Dreamer").transform.position);
            }
        }
        if (dist < 10)
        {
            Destroy(spiders[index].gameObject, 1f);
            item.uses--;
            if (item.uses == 0)
            {
                cell.RemoveItem();
            }
        }
    }
Exemplo n.º 4
0
    public static void attack(DadCell cell, ClickItem item)
    {
        Spider[] spiders = FindObjectsOfType <Spider>();
        int      index   = -1;
        float    dist    = 15;

        for (int i = 0; i < spiders.Length; i++)
        {
            Vector3 relative = GameObject.FindGameObjectWithTag("Dreamer").transform.InverseTransformPoint(spiders[i].transform.position);
            if (relative.x < 3 && relative.x > -3 && relative.z > 0 && dist > Vector3.Distance(spiders[i].transform.position, GameObject.FindGameObjectWithTag("Dreamer").transform.position))
            {
                index = i;
                dist  = Vector3.Distance(spiders[i].transform.position, GameObject.FindGameObjectWithTag("Dreamer").transform.position);
            }
        }
        if (dist < 5)
        {
            spiders[index].walking = false;
            spiders[index].CancelInvoke();
            spiders[index].anim.SetTrigger("Die");
            Destroy(spiders[index].gameObject, 1f);
            item.uses--;
            item.GetComponentInChildren <EditText>().updateText(item.uses);
            if (item.uses == 0)
            {
                cell.RemoveItem();
            }
        }
    }
Exemplo n.º 5
0
    private static int canvasSortOrder = 100;                                       // Sort order for canvas

    public static void eat(DadCell cell, ClickItem item)
    {
        HungerBar hunger = GameObject.FindObjectOfType <HungerBar>();

        hunger.AddHunger(item.value);
        cell.RemoveItem();
    }
Exemplo n.º 6
0
    /// <summary>
    /// Removes the stack item from this cell.
    /// </summary>
    public void RemoveStackItem()
    {
        DadCell dadCell = GetComponent <DadCell>();

        if (dadCell != null)
        {
            dadCell.RemoveItem();
        }
    }
Exemplo n.º 7
0
    /// <summary>
    /// Remove quick item.
    /// </summary>
    public void Remove()
    {
        DadCell dadCell = AccessUtility.GetComponentInParent <DadCell>(transform);

        if (dadCell != null)
        {
            dadCell.RemoveItem();
        }
        else
        {
            Destroy(gameObject);
        }
    }