private IEnumerator PlayAudioCoroutine(Vector3 position, AudioClip clip)
    {
        var source = audioSources.Lock();

        source.transform.position = position;
        source.clip = clip;
        source.Play();
        yield return(new WaitForSeconds(clip.length));

        audioSources.Free(source);
    }
Beispiel #2
0
    public override void Init()
    {
        Debug.Log("[TEST] GameManager.Init()");
        inGameUI.SetActive(false);

        touchWidget.OnStartControl += HandleStartControl;
        touchWidget.OnEndControl   += HandleEndControl;

        explosions = ObjectsPoolUtils.CreateBehavioursPool(() =>
        {
            var explosion         = Instantiate(explosionPrefab);
            explosion.OnComplete += () => explosions.Free(explosion);
            return(explosion);
        }, false);

        regularBombs = ObjectsPoolUtils.CreateBehavioursPool(() =>
        {
            var bomb = Instantiate(regularBombPrefab);
            bomb.explosive.OnExplode += () =>
            {
                var pos       = bomb.transform.position;
                var explosion = explosions.Lock();
                explosion.Explode(pos);
                soundManager.PlayExplosion(pos);
                regularBombs.Free(bomb);
            };
            return(bomb);
        }, false);

        powerBombs = ObjectsPoolUtils.CreateBehavioursPool(() =>
        {
            var bomb = Instantiate(powerBombPrefab);
            bomb.explosive.OnExplode += () =>
            {
                var pos       = bomb.transform.position;
                var explosion = explosions.Lock();
                explosion.Explode(pos);
                soundManager.PlayExplosion(pos);
                powerBombs.Free(bomb);
            };
            return(bomb);
        }, false);

        player = Instantiate(skins[0]);
        player.DORadius(testRadius, levelChangeDuration);
        cameraController.moveTarget = player.cameraAnchor;
    }
Beispiel #3
0
    public void Rebuild()
    {
        var len = 2 * Mathf.PI * radius;

        steps = Mathf.FloorToInt(len / segmentWidth);

        var count = _nodes.Count;

        if (count > steps)
        {
            // Если блоков в избытке - убираем
            for (int i = steps; i < count; i++)
            {
                _pool.Free(_nodes[i]);
            }
            _nodes.RemoveRange(steps, count - steps);
        }
        else if (count < steps)
        {
            // Если не хватает блоков - добавляем
            for (; count < steps; count++)
            {
                _nodes.Add(_pool.Lock());
            }
        }

        Debug.Assert(_nodes.Count == steps);

        for (int i = 0; i < steps; i++)
        {
            var angle = 360f * i / steps;
            var item  = _nodes[i];
            item.localPosition = new Vector3(
                radius * Mathf.Cos(Mathf.Deg2Rad * angle), 0,
                radius * Mathf.Sin(Mathf.Deg2Rad * angle)
                );
            item.localRotation = Quaternion.Euler(0, -angle + segmentAngle, 0);
        }
    }