Пример #1
0
    // Start is called before the first frame update
    void Start()
    {
        gameManager = FindObjectOfType <GameManager>();

        if (!multiBlockCreator)
        {
            multiBlockCreator = FindObjectOfType <MultiBlockCreator>();
        }

        if (!playerAgent)
        {
            playerAgent = FindObjectOfType <PlayerAgent>();
        }

        // the code will check whether or not to execute
        // based on the block.name assigned in the Inspector Window
        // in the RandomBlockCreator empty child object
        if (!randomBlockCreator)
        {
            randomBlockCreator = FindObjectOfType <RandomBlockCreator>();
        }

        if (!ball)
        {
            ball = FindObjectOfType <Ball>();
        }
        ballOffset = ball.transform.localPosition;

        // Performance tracking - has to come before countblocks
        if (!isMultiTraining)
        {
            dataManager = FindObjectOfType <PerformanceDataManager>();
        }

        if (!paddle)
        {
            paddle = FindObjectOfType <Paddle>();
        }
        paddleOffset = paddle.transform.localPosition;

        if (!trainingBlocksGroup && gameManager.trainingMode)
        {
            trainingBlocksGroup = GetTrainingBlocksGroupInstance();
        }

        // Check if scene is ready for training
        if (gameManager.trainingMode)
        {
            ResetEnvironmentState();
        }
        else
        {
            if (useRandomBlocks && randomBlockCreator)
            {
                randomBlockCreator.setupBlocks();
            }
            SetBlockSupervisor(randomBlockCreator.transform);

            CountBlocks();
        }

        // Calculate diagonal width
        instanceDiagonalSize = Mathf.Sqrt(Mathf.Pow(instanceHeight, 2) + Mathf.Pow(instanceWidth, 2));

        // Set the playerData's type, name, and points.
        InitializePlayerData();
        gameData.PlayerList.Add(playerData);
    }
Пример #2
0
 public override void Init(LevelInfo level)
 {
     Blocks = new RandomBlockCreator(10, 5, 4).BlocksInfo;
 }