Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        hit = Physics2D.Raycast(pos, Vector2.zero, 0f);
        if (hit.collider != null)
        {
            if (hit.collider.gameObject == bulletbtn)
            {
                if (Input.GetMouseButtonDown(0))
                {
                    sr.sprite = btn[0];
                }

                if (Input.GetMouseButtonUp(0))
                {
                    sr.sprite = btn[1];
                    if (staticV.bulletCount < 3)
                    {
                        if (staticV.bulletCount == 0)
                        {
                            if (staticV.coin >= staticV.bulletCoin)
                            {
                                um.coinUp(-staticV.bulletCoin);
                                staticV.bulletCoin = 75;
                                bm.bulletUp();
                                staticV.bulletCount += 1;
                            }
                        }
                        if (staticV.bulletCount == 1)
                        {
                            if (staticV.coin >= staticV.bulletCoin)
                            {
                                um.coinUp(-staticV.bulletCoin);
                                staticV.bulletCoin = 100;
                                bm.bulletUp();
                                staticV.bulletCount += 1;
                            }
                        }
                        if (staticV.bulletCount == 2)
                        {
                            if (staticV.coin >= staticV.bulletCoin)
                            {
                                um.coinUp(-staticV.bulletCoin);
                                staticV.bulletCoin = 125;
                                bm.bulletUp();
                                staticV.bulletCount += 1;
                            }
                        }
                    }
                }
            }
        }
        else
        {
            sr.sprite = btn[1];
        }
    }