예제 #1
0
    private bool Buy(string name, int cost)
    {
        if (PlayerCoin.Get() > cost)
        {
            Debug.Log("Player buy: " + name + " at cost " + cost);
            PlayerMonster.Add(name, 0);
            PlayerCoin.Spend(cost);

            return(true);
        }

        return(false);
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonUp(0))
        {
            RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition),
                                                 Vector2.zero);

            if (hit.transform != null)
            {
                for (int i = 0; i < colliderList.Count; i++)
                {
                    if (hit.transform.gameObject == colliderList[i].gameObject)
                    {
                        if (PlayerCoin.Get() >= itemList[i].GetComponent <Item>().Cost)
                        {
                            PlayerCoin.Spend(itemList[i].GetComponent <Item>().Cost);
                            PlayerItems.Add(itemList[i].name, 1);
                        }
                    }
                }
            }
        }
    }