示例#1
0
    // Check input
    public void checkInput(Vector3 inputPosition)
    {
        Vector2       position = Camera.main.ScreenToWorldPoint(inputPosition);
        BoxCollider2D collider = gameController.greenZoneCollider;

        if (collider != null && collider.OverlapPoint(position))
        {
            if (polygonTrigger.OverlapPoint(position))
            {
                if (sides == maxSides)
                {
                    gameController.GameOver(); //Game Over
                }

                Vector3 pos = new Vector3(Random.Range(-5f, 5f), 10);
                playerBody.AddForce(pos * forceStrength, ForceMode2D.Impulse);

                audioSource.pitch = Random.Range(0.8f, 1.2f);
                audioSource.Play();

                DataManager.instance.AddScore(1);
                angle += angleStep;
                material.SetFloat("_Angle", angle);
                sides++;
            }
        }
    }