Ejemplo n.º 1
0
    /// <summary>
    /// Принять выпавшее число
    /// </summary>
    /// <param name="droppedNumber"></param>
    private void ApplyDroppedNumber(int droppedNumber)
    {
        _droppedBones++;
        _droppedNumber += droppedNumber;

        if (_droppedBones < _numberBones)
        {
            return;
        }

        _isBonesSleeping = true;

        OnDroppedNumber?.Invoke(_droppedNumber);
        OnUpdateBonesState?.Invoke(BonesState.Sleep);

        ResetData();
    }
Ejemplo n.º 2
0
    private IEnumerator ThrowBones()
    {
        yield return(new WaitUntil(() => _isGameFieldCleared == true));

        _isGameFieldCleared = false;

        for (int i = 0; i < _numberBones; i++)
        {
            Vector3 spawnPosition = new Vector3(_spawnPoint.position.x + Random.Range(-1f, 1f), _spawnPoint.position.y, _spawnPoint.position.z);

            Bone bone = GetBoneFromPool();
            bone.transform.position = spawnPosition;
            bone.transform.rotation = _spawnPoint.localRotation;

            bone.Init(_power, ApplyDroppedNumber, _targetDroppedValue);
        }

        OnUpdateBonesState?.Invoke(BonesState.Throw);
        OnThrowed?.Invoke();
    }