示例#1
0
    public void playerHit(Polygon aPolygon)
    {
        if (!paused) {
            noOfPolygons [level - 1]--;
            if (player.validHit (aPolygon,mute)) {
                animatorScore.SetTrigger ("scoreUp");
                levelScore++;
                score++;
                if (!bonus) {
                    animatorTime.SetTrigger ("timeIncrease");
                    time += 5;
                    debug.text = "" + time;
                }
                scoreText.text = score + "";
                scoreSlider.value = (levelScore * 100f / levelPolygons);
                aPolygon.destroyPolygon (mute);
                if (noOfPolygons [level - 1] == 0)
                    nextLevel ();
            } else {
                lives--;
                livesSlider.value--;
                if (lives <= 0) {
                    aPolygon.rigidbody2D.isKinematic = true;
                    player.rigidbody2D.isKinematic = true;
                    StartCoroutine ("gameOver", (player.transform.position + aPolygon.transform.position) / 2);
                } else {
                    player.hitOther (aPolygon);
                    aPolygon.destroyPolygon (true);
                    if (noOfPolygons [level - 1] == 0)
                        nextLevel ();
                }

            }
        }
    }