Beispiel #1
0
    //This function detects clicks on the different buy options of the shop and calls the appropriate function.
    private void HandleOnTap(Vector3 position)
    {
        Vector3 worldPos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, -Camera.main.transform.position.z) + new Vector3(0, 0, -15.0f));
        Vector3 pointHit = worldPos;


        if (isInside(GameObject.Find("ExitButton").GetComponent <BoxCollider2D>(), pointHit))
        {
            UnityEngine.SceneManagement.SceneManager.LoadScene("Overworld");
        }
        else if (GameObject.Find("MultishotPowerup") != null && isInside(GameObject.Find("MultishotPowerup").transform.Find("BuyUsingPoints").GetComponent <BoxCollider2D>(), pointHit))
        {
            if (UserData.TrySpendPoints((UserData.GetMultishot() + 1) * 5000))
            {
                UserData.IncreaseMultishot();
            }
        }
        else if (GameObject.Find("FireRatePowerup") != null && isInside(GameObject.Find("FireRatePowerup").transform.Find("BuyUsingPoints").GetComponent <BoxCollider2D>(), pointHit))
        {
            if (UserData.TrySpendPoints((UserData.GetFireRate() + 1) * 5000))
            {
                UserData.IncreaseFireRate();
            }
        }
        else if (GameObject.Find("ShotSpeedPowerup") != null && isInside(GameObject.Find("ShotSpeedPowerup").transform.Find("BuyUsingPoints").GetComponent <BoxCollider2D>(), pointHit))
        {
            if (UserData.TrySpendPoints((UserData.GetBulletSpeed() + 1) * 5000))
            {
                UserData.IncreaseBulletSpeed();
            }
        }
        else if (GameObject.Find("SideLasersPowerup") != null && isInside(GameObject.Find("SideLasersPowerup").transform.Find("BuyUsingPoints").GetComponent <BoxCollider2D>(), pointHit))
        {
            if (UserData.TrySpendPoints((UserData.GetSideLaser() + 1) * 5000))
            {
                UserData.IncreaseSideLaser();
            }
        }
        else if (GameObject.Find("MultishotPowerup") != null && isInside(GameObject.Find("MultishotPowerup").transform.Find("BuyUsingMoney").GetComponent <BoxCollider2D>(), pointHit))
        {
            if (UserData.TrySpendRealMoney(2))
            {
                UserData.IncreaseMultishot();
            }
            else
            {
                mPurchaser.BuyCurrency();
            }
        }
        else if (GameObject.Find("FireRatePowerup") != null && isInside(GameObject.Find("FireRatePowerup").transform.Find("BuyUsingMoney").GetComponent <BoxCollider2D>(), pointHit))
        {
            if (UserData.TrySpendRealMoney(2))
            {
                UserData.IncreaseFireRate();
            }
            else
            {
                mPurchaser.BuyCurrency();
            }
        }
        else if (GameObject.Find("ShotSpeedPowerup") != null && isInside(GameObject.Find("ShotSpeedPowerup").transform.Find("BuyUsingMoney").GetComponent <BoxCollider2D>(), pointHit))
        {
            if (UserData.TrySpendRealMoney(2))
            {
                UserData.IncreaseBulletSpeed();
            }
            else
            {
                mPurchaser.BuyCurrency();
            }
        }
        else if (GameObject.Find("SideLasersPowerup") != null && isInside(GameObject.Find("SideLasersPowerup").transform.Find("BuyUsingMoney").GetComponent <BoxCollider2D>(), pointHit))
        {
            if (UserData.TrySpendRealMoney(2))
            {
                UserData.IncreaseSideLaser();
            }
            else
            {
                mPurchaser.BuyCurrency();
            }
        }
    }