예제 #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 CreateCorner(
            BreakoutGameController breakoutGameController,
            CornerConfig cornerConfig)
        {
            var wallGameObject = Instantiate(_cornerPiecePrefab);

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

            var unitSize = breakoutGameController.UnitSize;

            var wallTransform = wallGameObject.transform;

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

            breakoutGameController.AddWall(wall);
        }