Beispiel #1
0
    // don't use it
    // public List<GameObject> CreateAndGetPins(Vector3 startPosition)
    // {
    //     List<GameObject> resultPins = new List<GameObject>();
    //
    //     // first row
    //     GameObject pin = Instantiate(pinPrefab, startPosition, Quaternion.identity);
    //     resultPins.Add(pin);
    //     //second row
    //     pin = Instantiate(pinPrefab, startPosition + new Vector3(-0.15f, 0, 0.26f ), Quaternion.identity);
    //     resultPins.Add(pin);
    //     pin = Instantiate(pinPrefab, startPosition + new Vector3(0.15f, 0, 0.26f ), Quaternion.identity);
    //     resultPins.Add(pin);
    //     //third row
    //     pin = Instantiate(pinPrefab, startPosition + new Vector3(-0.3f, 0, 0.52f ), Quaternion.identity);
    //     resultPins.Add(pin);
    //     pin = Instantiate(pinPrefab, startPosition + new Vector3(0.0f, 0, 0.52f ), Quaternion.identity);
    //     resultPins.Add(pin);
    //     pin = Instantiate(pinPrefab, startPosition + new Vector3(0.3f, 0, 0.52f ), Quaternion.identity);
    //     resultPins.Add(pin);
    //     //forth row
    //     pin = Instantiate(pinPrefab, startPosition + new Vector3(-0.45f, 0, 0.78f ), Quaternion.identity);
    //     resultPins.Add(pin);
    //     pin = Instantiate(pinPrefab, startPosition + new Vector3(-0.15f, 0, 0.78f ), Quaternion.identity);
    //     resultPins.Add(pin);
    //     pin = Instantiate(pinPrefab, startPosition + new Vector3(0.0f, 0, 0.78f ), Quaternion.identity);
    //     resultPins.Add(pin);
    //     pin = Instantiate(pinPrefab, startPosition + new Vector3(0.15f, 0, 0.78f ), Quaternion.identity);
    //     resultPins.Add(pin);
    //     pin = Instantiate(pinPrefab, startPosition + new Vector3(0.45f, 0, 0.78f ), Quaternion.identity);
    //     resultPins.Add(pin);
    //
    //     return resultPins;
    // }

    private void RespawnPins()
    {
        int  standingPins = _setter.CountStanding();
        bool isStrike     = _isFirstRoll && standingPins == 0;


        if (isStrike)
        {
            _player.AddStrike();
            _setter.ResetAllPins();
        }
        else if (_isFirstRoll)
        {
            _player.AddResultRoll(standingPins, _isFirstRoll);
            _setter.ResetStandingPins();
        }
        else
        {
            _player.AddResultRoll(standingPins, _isFirstRoll);
            _setter.ResetAllPins();
        }

        _isFirstRoll = isStrike || !_isFirstRoll;

        _setter.SetPinsToStart();
        manager.UpdateScoreUI();
    }