Пример #1
0
        private void CreateWalls(
            BreakoutGameController breakoutGameController,
            GameBoardConfig gameBoardConfig)
        {
            var gameBoardWidthHalf  = gameBoardConfig.gameBoardWidth * 0.5f;
            var gameBoardHeightHalf = gameBoardConfig.gameBoardHeight * 0.5f;

            var leftWallConfig = new WallConfig
            {
                x        = -gameBoardWidthHalf,
                angle    = 90.0f,
                width    = gameBoardConfig.gameBoardHeight,
                wallType = WallType.Left
            };

            CreateWall(breakoutGameController, leftWallConfig);

            var rightWallConfig = new WallConfig
            {
                x        = gameBoardWidthHalf,
                angle    = -90.0f,
                width    = gameBoardConfig.gameBoardHeight,
                wallType = WallType.Right
            };

            CreateWall(breakoutGameController, rightWallConfig);

            var topWallConfig = new WallConfig
            {
                y        = gameBoardHeightHalf,
                angle    = 180.0f,
                width    = gameBoardConfig.gameBoardWidth,
                wallType = WallType.Top
            };

            CreateWall(breakoutGameController, topWallConfig);

            var leftCornerConfig = new CornerConfig
            {
                x     = -gameBoardWidthHalf,
                y     = gameBoardHeightHalf,
                angle = 180.0f,
                size  = 1.0f
            };

            CreateCorner(breakoutGameController, leftCornerConfig);

            var rightCornerConfig = new CornerConfig
            {
                x     = gameBoardWidthHalf,
                y     = gameBoardHeightHalf,
                angle = 270.0f,
                size  = 1.0f
            };

            CreateCorner(breakoutGameController, rightCornerConfig);
        }
Пример #2
0
        private void CreateWall(
            BreakoutGameController breakoutGameController,
            WallConfig wallConfig)
        {
            var wallGameObject = Instantiate(_wallPrefab);

            wallGameObject.name = _wallPrefab.name;
            var wall = wallGameObject.GetComponent <Wall>();

            wall.WallType = wallConfig.wallType;

            var unitSize = breakoutGameController.UnitSize;

            var wallTransform = wallGameObject.transform;

            wallTransform.localPosition = new Vector3(wallConfig.x * unitSize, 0.0f, wallConfig.y * unitSize);
            wallTransform.localRotation = Quaternion.Euler(0.0f, wallConfig.angle, 0.0f);
            wallTransform.localScale    = new Vector3(wallConfig.width * unitSize, unitSize, unitSize);

            breakoutGameController.AddWall(wall);
        }