Exemplo n.º 1
0
    public IEnumerator CountPins()
    {
        rolls++;
        fallen = 0;
        yield return(new WaitForSecondsRealtime(time));

        foreach (PinniBoy p in pins)
        {
            if (p.hasFallen)
            {
                fallen++;
                Destroy(p.gameObject);
            }
            else
            {
            }
        }
        if (rolls == 1)
        {
            scoreboard.SetFrame(frameI, fallen, 0);
        }
        else if (rolls == 2)
        {
            Destroy(rack.gameObject);
            scoreboard.AddFrame(frameI, 0, fallen);
            frameI++;
            rolls = 0;
            rack  = Instantiate(pinRack, pinPos);
        }
        if (frameI == 10)
        {
            frameI = 0;
        }
        scoreText.text = "Frame: " + frameI;
        pinsText.text  = "Pins: " + fallen;
        rollText.text  = "Roll: " + rolls;
    }