示例#1
0
    private IEnumerator DestroyBalls()
    {
        yield return(new WaitForEndOfFrame());

        var nextState = GameState.BallDrawNext;

        UpdateLinkedBalls2();

        foreach (var ball in _board)
        {
            if (!ball.IsActive() || ball.IsLinked)
            {
                continue;
            }

            nextState = GameState.BoardMovingDown;

            ball.SetState(BallState.None);

            var ballFall = PoolBoss.SpawnInPool("ball", ball.transform.position, Quaternion.identity).GetComponent <Ball>();
            ballFall.CopyFrom(ball);
            ballFall.SetState(BallState.Fall);
        }

        if (nextState == GameState.BoardMovingDown)
        {
            SoundManager.Instance.PlayFall();
        }

        State = nextState;
        // State = GameState.BallDrawNext;
    }
示例#2
0
    private void ResetBoard(bool complete = false)
    {
        _isEvenLeft = true;
        if (_board == null)
        {
            _board = new Ball[Rows, Columns];
        }

        PoolBoss.DespawnAllPrefabs();

        for (var y = 0; y < Rows; y++)
        {
            var offsetX = y.IsEven() && _isEvenLeft ? 0f : CellWidth / 2;
            for (var x = 0; x < Columns; x++)
            {
                var pos  = new Vector3(BoardLeft + x * CellWidth + offsetX, BoardTop + CellHeight - y * CellHeight, 0f);
                var ball = PoolBoss.SpawnInPool("ball", pos, Quaternion.identity).GetComponent <Ball>();
                ball.BoardX = x;
                ball.BoardY = y;
                ball.SetValue(RandomBallValue());
                ball.SetState(y > 4 || complete ? BallState.None : BallState.Active);

                _board[y, x] = ball;
            }
        }
    }
示例#3
0
        private void SpawnPlayer()
        {
            _player = PoolBoss.SpawnOutsidePool(PlayerPrefab, _playerPosition, PlayerPrefab.transform.rotation);

            var spawnPos = _playerPosition + RespawnParticleOffset;

            if (RespawnParticlePrefab != null)
            {
                PoolBoss.SpawnInPool(RespawnParticlePrefab, spawnPos, RespawnParticlePrefab.transform.rotation);
            }
        }
示例#4
0
    void OnGUI()
    {
        GUI.Label(new Rect(10, 10, 760, 90), "Click the button below to spawn 10 Robot Kyles at a time until you have 50. There are 50 in the pool, so they will spawn instantly with no impact on performance! You can watch them become active under the Pool Boss game object. If you try to spawn more than 50, Pool Boss will refuse and log an error in the Console. There is an option to 'Allow Instantiate More' that you can turn on though. Select the Pool Boss game object for more information and functions on the pool items at runtime.");

        if (GUI.Button(new Rect(10, 80, 100, 30), "Spawn 10"))
        {
            for (var i = 0; i < 10; i++)
            {
                PoolBoss.SpawnInPool(robotKylePrefab, spawnPos, robotKylePrefab.rotation);
                spawnPos += new Vector3(40, 0, 0);
            }

            spawnPos.y  = 0;
            spawnPos.z -= 100;
            spawnPos.x  = -150;
        }

        if (GUI.Button(new Rect(10, 120, 100, 30), "Despawn All"))
        {
            PoolBoss.DespawnAllOfPrefab(robotKylePrefab);
            spawnPos = new Vector3(-150, 0, 150);
        }
    }