예제 #1
0
    // To be called on ticks where the balls are on the edge between two tiles
    void ExecuteTickOffTurn()
    {
        foreach (BallBehaviour ball in board.activeBalls)
        {
            TileBehaviour tile = board.GetTileEntered(ball);
            if (!tile)
            {
                Debug.LogError("Ball leaving board");
                gameState.isPaused = true;
                continue;
            }

            if (tile.tileType == TileBehaviour.TileType.Block)
            {
                ball.forward *= -1.0f;
            }
            else if (tile.tileType == TileBehaviour.TileType.Vault)
            {
                if (!tile.GetComponentInChildren <VaultBehaviour>().CanEnter(ball.forward))
                {
                    ball.forward *= -1.0f;
                }
            }
            else if (tile.tileType == TileBehaviour.TileType.LockRed || tile.tileType == TileBehaviour.TileType.LockBlue)
            {
                if (tile.GetComponentInChildren <RaiseBehaviour>().isRaised)
                {
                    ball.forward *= -1.0f;
                }
            }
            else
            {
                BounceBall(ball);
            }

            tile.ConditionalBlock(ball.forward * -1.0f);
        }
    }