Ejemplo n.º 1
0
 public void AddItem(itemScript item)
 {
     if (itemList.Count < 15)
     {
         itemList.Add(item);
     }
 }
Ejemplo n.º 2
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag("Item"))
     {
         itemTouched = true;
         Is          = collision.gameObject.GetComponent <itemScript>();
     }
 }
Ejemplo n.º 3
0
 private void OnTriggerExit2D(Collider2D collision)
 {
     if (collision.CompareTag("Item"))
     {
         itemTouched = false;
         itemGrabbed = false;
         Is          = null;
     }
 }
Ejemplo n.º 4
0
 public void RemoveItem(itemScript item)
 {
     itemList.Remove(item);
 }
Ejemplo n.º 5
0
 public void ClearSlot()
 {
     item        = null;
     icon.sprite = null;
 }
Ejemplo n.º 6
0
 public void Add(itemScript newItem)
 {
     item         = newItem;
     icon.sprite  = item.icon;
     icon.enabled = true;
 }
Ejemplo n.º 7
0
    // Use this for initialization
    void Start()
    {
        buttonItems = new GameObject[shopItems.Length];
        counter     = 0;
        foreach (Item i in shopItems)
        {
            GameObject btn = (GameObject)Instantiate(button);

            buttonItems[counter] = btn;
            itemScript scp = btn.GetComponent <itemScript>();
            scp.ClickValue  = i.UpClick;
            scp.FinalUnlock = i.FinalUnlock;
            scp.name.text   = i.name;
            scp.icon.sprite = i.image;
            if (i.cost > 1000)
            {
                if (i.cost > 1000000)
                {
                    if (i.cost > 1000000000)
                    {
                        if (i.cost > 1000000000000)
                        {
                            scp.cost.text = (i.cost / 1000000000000).ToString("F2") + " T";
                        }
                        else
                        {
                            scp.cost.text = (i.cost / 1000000000).ToString("F2") + " B";
                        }
                    }
                    else
                    {
                        scp.cost.text = (i.cost / 1000000).ToString("F2") + " M";
                    }
                }
                else
                {
                    scp.cost.text = (i.cost / 1000).ToString("F2") + " K";
                }
            }
            else
            {
                scp.cost.text = i.cost.ToString("F2");
            }

            if (i.UpClick == false)
            {
                if (i.cps > 1000)
                {
                    if (i.cps > 1000000)
                    {
                        if (i.cps > 1000000000)
                        {
                            if (i.cps > 1000000000000)
                            {
                                scp.cps.text = "+" + (i.cps / 1000000000000).ToString("F2") + " T" + " k/s";
                            }
                            else
                            {
                                scp.cps.text = "+" + (i.cps / 1000000000).ToString("F2") + " B" + " k/s";
                            }
                        }
                        else
                        {
                            scp.cps.text = "+" + (i.cps / 1000000).ToString("F2") + " M" + " k/s";
                        }
                    }
                    else
                    {
                        scp.cps.text = "+" + (i.cps / 1000).ToString("F2") + " K" + " k/s";
                    }
                }
                else
                {
                    scp.cps.text = "+" + i.cps.ToString("F2") + " k/s";
                }
            }
            else
            {
                if (i.cps > 1000)
                {
                    if (i.cps > 1000000)
                    {
                        if (i.cps > 1000000000)
                        {
                            if (i.cps > 1000000000000)
                            {
                                scp.cps.text = "+" + (i.cps / 1000000000000).ToString("F2") + " T";
                            }
                            else
                            {
                                scp.cps.text = "+" + (i.cps / 1000000000).ToString("F2") + " B";
                            }
                        }
                        else
                        {
                            scp.cps.text = "+" + (i.cps / 1000000).ToString("F2") + " M";
                        }
                    }
                    else
                    {
                        scp.cps.text = "+" + (i.cps / 1000).ToString("F2") + " K";
                    }
                }
                else
                {
                    scp.cps.text = "+" + i.cps.ToString("F2");
                }
            }
            scp.Quantity.text = i.quantity.ToString();

            Item thisItem = i;

            scp.thisButton.onClick.AddListener(() => Purchase(thisItem));

            btn.transform.SetParent(this.transform, false);
            counter++;
        }
    }
Ejemplo n.º 8
0
    public void UpdateItems()
    {
        counter = 0;
        foreach (Item i in shopItems)
        {
            itemScript scp = buttonItems[counter].GetComponent <itemScript>();
            if (i.UpClick == false)
            {
                if (i.cps > 1000)
                {
                    if (i.cps > 1000000)
                    {
                        if (i.cps > 1000000000)
                        {
                            if (i.cps > 1000000000000)
                            {
                                scp.cps.text = "+" + (i.cps / 1000000000000).ToString("F2") + " T" + " k/s";
                            }
                            else
                            {
                                scp.cps.text = "+" + (i.cps / 1000000000).ToString("F2") + " B" + " k/s";
                            }
                        }
                        else
                        {
                            scp.cps.text = "+" + (i.cps / 1000000).ToString("F2") + " M" + " k/s";
                        }
                    }
                    else
                    {
                        scp.cps.text = "+" + (i.cps / 1000).ToString("F2") + " K" + " k/s";
                    }
                }
                else
                {
                    scp.cps.text = "+" + i.cps.ToString("F2") + " k/s";
                }
            }
            else
            {
                if (i.cps > 1000)
                {
                    if (i.cps > 1000000)
                    {
                        if (i.cps > 1000000000)
                        {
                            if (i.cps > 1000000000000)
                            {
                                scp.cps.text = "+" + (i.cps / 1000000000000).ToString("F2") + " T";
                            }
                            else
                            {
                                scp.cps.text = "+" + (i.cps / 1000000000).ToString("F2") + " B";
                            }
                        }
                        else
                        {
                            scp.cps.text = "+" + (i.cps / 1000000).ToString("F2") + " M";
                        }
                    }
                    else
                    {
                        scp.cps.text = "+" + (i.cps / 1000).ToString("F2") + " K";
                    }
                }
                else
                {
                    scp.cps.text = "+" + i.cps.ToString("F2");
                }
            }
            scp.name.text   = i.name;
            scp.icon.sprite = i.image;
            if (i.cost > 1000)
            {
                if (i.cost > 1000000)
                {
                    if (i.cost > 1000000000)
                    {
                        if (i.cost > 1000000000000)
                        {
                            scp.cost.text = (i.cost / 1000000000000).ToString("F2") + " T";
                        }
                        else
                        {
                            scp.cost.text = (i.cost / 1000000000).ToString("F2") + " B";
                        }
                    }
                    else
                    {
                        scp.cost.text = (i.cost / 1000000).ToString("F2") + " M";
                    }
                }
                else
                {
                    scp.cost.text = (i.cost / 1000).ToString("F2") + " K";
                }
            }
            else
            {
                scp.cost.text = i.cost.ToString("F2");
            }

            if (i.quantity > 1000)
            {
                scp.Quantity.text = (i.quantity / 1000).ToString("F0") + " K";
            }
            else
            {
                scp.Quantity.text = i.quantity.ToString();
            }



            counter++;
        }
    }
Ejemplo n.º 9
0
    // Update is called once per frame
    void Update()
    {
        GamePadState state = GamePad.GetState(player);
        Vector2      input = new Vector2(state.ThumbSticks.Left.X, state.ThumbSticks.Left.Y);

        bool aPressed    = state.Buttons.A == ButtonState.Pressed && lastState.Buttons.A == ButtonState.Released;
        bool dashPressed = state.Buttons.X == ButtonState.Pressed && lastState.Buttons.X == ButtonState.Released;

        if (canAct)
        {
            rb.AddForce(input * speed, ForceMode2D.Impulse);
            charAnimator.SetBool("IsRunning", input.sqrMagnitude > 0);
            if (input.x > 0f)
            {
                transform.localScale = new Vector3(-1, 1, 1);
            }
            else
            {
                transform.localScale = new Vector3(1, 1, 1);
            }
        }

        if (aPressed && canAct)
        {
            Collider2D[] circleInfo = Physics2D.OverlapCircleAll(transform.position, interactRadius);
            for (int i = 0; i < circleInfo.Length; i++)
            {
                if (circleInfo[i].tag == "chest")
                {
                    Debug.Log("Player " + player + " got a chest");
                    chestScript scriptOfChest = circleInfo[i].gameObject.GetComponent <chestScript>();
                    pickedBuff = scriptOfChest.getBuff();
                    Debug.Log(pickedBuff);

                    if (pickedBuff == "fast")
                    {
                        StartCoroutine(modifySpeed(1f));
                    }
                    else if (pickedBuff == "slow")
                    {
                        StartCoroutine(modifySpeed(-1f));
                    }
                    else if (pickedBuff == "coins")
                    {
                        Debug.Log("got some coins");
                    }
                    //Destroy(circleInfo[i].gameObject);
                }
                else if (circleInfo[i].tag == "item")
                {
                    itemScript scriptOfItem = circleInfo[i].gameObject.GetComponent <itemScript>();
                    string     givenItem    = scriptOfItem.equipThis();
                    equipItem(givenItem);
                    Debug.Log("Equipped " + givenItem.ToString());
                }
            }
        }

        if (dashPressed && canAct && canDash && input != new Vector2(0f, 0f))
        {
            StartCoroutine(dashTransition(input));
            Debug.Log("gets past input if");
        }



        lastState = state;
    }