// Set all of the cube's information when it is placed
        private void OnPlaceCube(GameObject newCube)
        {
            grid.placedObjects.Add(newCube);

            switch (currentCube)
            {
            case CubeTypes.FullStaticCube:
                newCube.AddComponent(typeof(StaticCube));
                StaticCube staticCube = newCube.GetComponent <StaticCube>();
                SendInfoToCube(staticCube as _CubeBase, CubeTypes.FullStaticCube, CubeLayers.cubeFull, true);
                break;

            case CubeTypes.EmptyStaticCube:
                newCube.AddComponent(typeof(StaticCube));
                StaticCube emptyStaticCube = newCube.GetComponent <StaticCube>();
                SendInfoToCube(emptyStaticCube as _CubeBase, CubeTypes.EmptyStaticCube, CubeLayers.cubeFull, true);
                break;

            case CubeTypes.TopStaticCube:
                newCube.AddComponent(typeof(StaticCube));
                StaticCube topStaticCube = newCube.GetComponent <StaticCube>();
                SendInfoToCube(topStaticCube as _CubeBase, CubeTypes.TopStaticCube, CubeLayers.cubeFull, true);
                break;

            case CubeTypes.CornerStaticCube:
                newCube.AddComponent(typeof(StaticCube));
                StaticCube cornerStaticCube = newCube.GetComponent <StaticCube>();
                SendInfoToCube(cornerStaticCube as _CubeBase, CubeTypes.CornerStaticCube, CubeLayers.cubeFull, true);
                break;

            case CubeTypes.TripleStaticCube:
                newCube.AddComponent(typeof(StaticCube));
                StaticCube tripleStaticCube = newCube.GetComponent <StaticCube>();
                SendInfoToCube(tripleStaticCube as _CubeBase, CubeTypes.TripleStaticCube, CubeLayers.cubeFull, true);
                break;

            case CubeTypes.QuadStaticCube:
                newCube.AddComponent(typeof(StaticCube));
                StaticCube quadStaticCube = newCube.GetComponent <StaticCube>();
                SendInfoToCube(quadStaticCube as _CubeBase, CubeTypes.QuadStaticCube, CubeLayers.cubeFull, true);
                break;

            case CubeTypes.MoveableCube:
                newCube.AddComponent(typeof(MoveableCube));
                MoveableCube moveableCube = newCube.GetComponent <MoveableCube>();
                SendInfoToCube(moveableCube as _CubeBase, CubeTypes.MoveableCube, CubeLayers.cubeMoveable, false);
                break;

            case CubeTypes.BaseVictoryCube:
                newCube.AddComponent(typeof(BaseVictoryCube));
                BaseVictoryCube victoryCube = newCube.GetComponent <BaseVictoryCube>();
                SendInfoToCube(victoryCube as _CubeBase, CubeTypes.BaseVictoryCube, CubeLayers.cubeMoveable, false);
                break;

            case CubeTypes.ConcreteVictoryCube:
                newCube.AddComponent(typeof(ConcreteVictoryCube));
                ConcreteVictoryCube concreteVictoryCube = newCube.GetComponent <ConcreteVictoryCube>();
                SendInfoToCube(concreteVictoryCube as _CubeBase, CubeTypes.ConcreteVictoryCube, CubeLayers.cubeMoveable, false);
                break;

            case CubeTypes.BombVictoryCube:
                newCube.AddComponent(typeof(BombVictoryCube));
                BombVictoryCube bombVictoryCube = newCube.GetComponent <BombVictoryCube>();
                SendInfoToCube(bombVictoryCube as _CubeBase, CubeTypes.BombVictoryCube, CubeLayers.cubeMoveable, false);
                break;

            case CubeTypes.SwitchVictoryCube:
                newCube.AddComponent(typeof(SwitchVictoryCube));
                SwitchVictoryCube switchVictoryCube = newCube.GetComponent <SwitchVictoryCube>();
                SendInfoToCube(switchVictoryCube as _CubeBase, CubeTypes.SwitchVictoryCube, CubeLayers.cubeFull, true);
                break;

            case CubeTypes.DeliveryCube:
                newCube.AddComponent(typeof(DeliveryCube));
                DeliveryCube deliveryCube = newCube.GetComponent <DeliveryCube>();
                SendInfoToCube(deliveryCube as _CubeBase, CubeTypes.DeliveryCube, CubeLayers.cubeFull, true);
                break;

            case CubeTypes.BlueElevatorCube:
                newCube.AddComponent(typeof(ElevatorCube));
                ElevatorCube blueElevatorCube = newCube.GetComponent <ElevatorCube>();
                blueElevatorCube.isGreen = false;
                SendInfoToCube(blueElevatorCube as _CubeBase, CubeTypes.BlueElevatorCube, CubeLayers.cubeFull, false);
                break;

            case CubeTypes.GreenElevatorCube:
                newCube.AddComponent(typeof(ElevatorCube));
                ElevatorCube greenElevatorCube = newCube.GetComponent <ElevatorCube>();
                greenElevatorCube.isGreen = true;
                SendInfoToCube(greenElevatorCube as _CubeBase, CubeTypes.GreenElevatorCube, CubeLayers.cubeFull, false);
                break;

            case CubeTypes.ConcreteCube:
                newCube.AddComponent(typeof(ConcreteCube));
                ConcreteCube concreteCube = newCube.GetComponent <ConcreteCube>();
                SendInfoToCube(concreteCube as _CubeBase, CubeTypes.ConcreteCube, CubeLayers.cubeMoveable, false);
                break;

            case CubeTypes.BombCube:
                newCube.AddComponent(typeof(BombCube));
                BombCube mineCube = newCube.GetComponent <BombCube>();
                SendInfoToCube(mineCube as _CubeBase, CubeTypes.BombCube, CubeLayers.cubeMoveable, false);
                break;

            case CubeTypes.TimerCube:
                newCube.AddComponent(typeof(TimerCube));
                TimerCube timerCube = newCube.GetComponent <TimerCube>();
                SendInfoToCube(timerCube as _CubeBase, CubeTypes.TimerCube, CubeLayers.cubeFull, true);
                break;

            case CubeTypes.SwitchCube:
                newCube.AddComponent(typeof(SwitchCube));
                SwitchCube switchCube = newCube.GetComponent <SwitchCube>();
                SendInfoToCube(switchCube as _CubeBase, CubeTypes.SwitchCube, CubeLayers.cubeFull, true);
                break;

            case CubeTypes.SwitchButton:
                placingButton = false;
                newCube.AddComponent(typeof(SwitchButton));
                SwitchButton switchButton = newCube.GetComponent <SwitchButton>();
                SendInfoToCube(switchButton as _CubeBase, CubeTypes.SwitchButton, CubeLayers.cubeFull, true);
                break;

            case CubeTypes.RotatorLeftTurner:
                newCube.AddComponent(typeof(RotateLeftCube));
                RotateLeftCube rotateLeftCube = newCube.GetComponent <RotateLeftCube>();
                SendInfoToCube(rotateLeftCube as _CubeBase, CubeTypes.RotatorLeftTurner, CubeLayers.cubeFull, true);
                break;

            case CubeTypes.RotatorRightTurner:
                newCube.AddComponent(typeof(RotateRightCube));
                RotateRightCube rotateRightCube = newCube.GetComponent <RotateRightCube>();
                SendInfoToCube(rotateRightCube as _CubeBase, CubeTypes.RotatorRightTurner, CubeLayers.cubeFull, true);
                break;

            case CubeTypes.RotatorLocker:
                newCube.AddComponent(typeof(RotatorLocker));
                RotatorLocker rotatorLocker = newCube.GetComponent <RotatorLocker>();
                SendInfoToCube(rotatorLocker as _CubeBase, CubeTypes.RotatorLocker, CubeLayers.cubeFull, true);
                break;

            case CubeTypes.ChaosBall:
                newCube.AddComponent(typeof(ChaosBall));
                ChaosBall chaosBall = newCube.GetComponent <ChaosBall>();
                SendInfoToCube(chaosBall as _CubeBase, CubeTypes.ChaosBall, CubeLayers.cubeMoveable, false);
                break;

            default:
                break;
            }
        }
        public void ExtractAndRebuildLevel(LevelEditorData recoveredData)
        {
            finishedBuilding = false;

            grid = _Grid.instance;

            // start by resetting the grid's nodes to their base states
            grid.ResetIndexGrid();

            foreach (Node recoveredNode in recoveredData.nodesToSave)
            {
                // EXTREMELY IMPORTANT -> CONVERTS THE CUBE'S TYPE FROM STRING TO ENUM
                recoveredNode.cubeType = Node.ConvertStringToCubeType(recoveredNode.savedCubeType);

                //Set the universe textures
                _MaterialCentral.instance.ChangeUniverse(recoveredData.biome);

                currentNode = recoveredNode;

                GameObject newCube = Instantiate(cubePrefab);

                _Grid.instance.placedObjects.Add(newCube);

                // get the kuboGrid and set the information on each of the nodes
                SetNodeInfo(newCube, recoveredNode.nodeIndex, recoveredNode.worldPosition, recoveredNode.worldRotation, recoveredNode.facingDirection, recoveredNode.cubeLayers, recoveredNode.cubeType);

                // check the node's cube type and setup the relevant cube and its transform + individual information
                switch (recoveredNode.cubeType)
                {
                case CubeTypes.FullStaticCube:
                    newCube.AddComponent(typeof(StaticCube));
                    StaticCube fullStaticCube = newCube.GetComponent <StaticCube>();
                    SetCubeInfo(fullStaticCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.FullStaticCube, true);
                    break;

                case CubeTypes.EmptyStaticCube:
                    newCube.AddComponent(typeof(StaticCube));
                    StaticCube emptyCube = newCube.GetComponent <StaticCube>();
                    SetCubeInfo(emptyCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.EmptyStaticCube, true);
                    break;

                case CubeTypes.TopStaticCube:
                    newCube.AddComponent(typeof(StaticCube));
                    StaticCube topStaticCube = newCube.GetComponent <StaticCube>();
                    SetCubeInfo(topStaticCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.TopStaticCube, true);
                    break;

                case CubeTypes.CornerStaticCube:
                    newCube.AddComponent(typeof(StaticCube));
                    StaticCube cornerStaticCube = newCube.GetComponent <StaticCube>();
                    SetCubeInfo(cornerStaticCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.CornerStaticCube, true);
                    break;

                case CubeTypes.TripleStaticCube:
                    newCube.AddComponent(typeof(StaticCube));
                    StaticCube tripleStaticCube = newCube.GetComponent <StaticCube>();
                    SetCubeInfo(tripleStaticCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.TripleStaticCube, true);
                    break;

                case CubeTypes.QuadStaticCube:
                    newCube.AddComponent(typeof(StaticCube));
                    StaticCube quadStaticCube = newCube.GetComponent <StaticCube>();
                    SetCubeInfo(quadStaticCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.QuadStaticCube, true);
                    break;

                case CubeTypes.MoveableCube:
                    newCube.AddComponent(typeof(MoveableCube));
                    MoveableCube moveableCube = newCube.GetComponent <MoveableCube>();
                    SetCubeInfo(moveableCube as _CubeBase, CubeLayers.cubeMoveable, CubeTypes.MoveableCube, false);
                    break;

                case CubeTypes.BaseVictoryCube:
                    newCube.AddComponent(typeof(BaseVictoryCube));
                    BaseVictoryCube baseVictoryCube = newCube.GetComponent <BaseVictoryCube>();
                    SetCubeInfo(baseVictoryCube as _CubeBase, CubeLayers.cubeMoveable, CubeTypes.BaseVictoryCube, false);
                    break;

                case CubeTypes.ConcreteVictoryCube:
                    newCube.AddComponent(typeof(ConcreteVictoryCube));
                    ConcreteVictoryCube concreteVictoryCube = newCube.GetComponent <ConcreteVictoryCube>();
                    SetCubeInfo(concreteVictoryCube as _CubeBase, CubeLayers.cubeMoveable, CubeTypes.ConcreteVictoryCube, false);
                    break;

                case CubeTypes.BombVictoryCube:
                    newCube.AddComponent(typeof(BombVictoryCube));
                    BombVictoryCube bombVictoryCube = newCube.GetComponent <BombVictoryCube>();
                    SetCubeInfo(bombVictoryCube as _CubeBase, CubeLayers.cubeMoveable, CubeTypes.BombVictoryCube, false);
                    break;

                case CubeTypes.SwitchVictoryCube:
                    newCube.AddComponent(typeof(SwitchVictoryCube));
                    SwitchVictoryCube switchVictoryCube = newCube.GetComponent <SwitchVictoryCube>();
                    SetCubeInfo(switchVictoryCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.SwitchVictoryCube, true);
                    break;

                case CubeTypes.DeliveryCube:
                    newCube.AddComponent(typeof(DeliveryCube));
                    DeliveryCube deliveryCube = newCube.GetComponent <DeliveryCube>();
                    SetCubeInfo(deliveryCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.DeliveryCube, true);
                    break;

                case CubeTypes.BlueElevatorCube:
                    newCube.AddComponent(typeof(ElevatorCube));
                    ElevatorCube blueElevatorCube = newCube.GetComponent <ElevatorCube>();
                    blueElevatorCube.isGreen = false;
                    SetCubeInfo(blueElevatorCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.BlueElevatorCube, false);
                    break;

                case CubeTypes.GreenElevatorCube:
                    newCube.AddComponent(typeof(ElevatorCube));
                    ElevatorCube greenElevatorCube = newCube.GetComponent <ElevatorCube>();
                    greenElevatorCube.isGreen = true;
                    SetCubeInfo(greenElevatorCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.GreenElevatorCube, false);
                    break;

                case CubeTypes.ConcreteCube:
                    newCube.AddComponent(typeof(ConcreteCube));
                    ConcreteCube concreteCube = newCube.GetComponent <ConcreteCube>();
                    SetCubeInfo(concreteCube as _CubeBase, CubeLayers.cubeMoveable, CubeTypes.ConcreteCube, false);
                    break;

                case CubeTypes.BombCube:
                    newCube.AddComponent(typeof(BombCube));
                    BombCube bombCube = newCube.GetComponent <BombCube>();
                    SetCubeInfo(bombCube as _CubeBase, CubeLayers.cubeMoveable, CubeTypes.BombCube, false);
                    break;

                case CubeTypes.TimerCube:
                    newCube.AddComponent(typeof(TimerCube));
                    TimerCube timerCube = newCube.GetComponent <TimerCube>();
                    SetCubeInfo(timerCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.TimerCube, true);
                    break;

                case CubeTypes.SwitchButton:
                    newCube.AddComponent(typeof(SwitchButton));
                    SwitchButton switchButton = newCube.GetComponent <SwitchButton>();
                    SetCubeInfo(switchButton as _CubeBase, CubeLayers.cubeFull, CubeTypes.SwitchButton, true);
                    break;

                case CubeTypes.SwitchCube:
                    newCube.AddComponent(typeof(SwitchCube));
                    SwitchCube switchCube = newCube.GetComponent <SwitchCube>();
                    SetCubeInfo(switchCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.SwitchCube, true);
                    break;

                case CubeTypes.RotatorRightTurner:
                    newCube.AddComponent(typeof(RotateRightCube));
                    RotateRightCube rotatorRightTurn = newCube.GetComponent <RotateRightCube>();
                    SetCubeInfo(rotatorRightTurn as _CubeBase, CubeLayers.cubeFull, CubeTypes.RotatorRightTurner, true);
                    break;

                case CubeTypes.RotatorLeftTurner:
                    newCube.AddComponent(typeof(RotateLeftCube));
                    RotateLeftCube rotatorLeftTurn = newCube.GetComponent <RotateLeftCube>();
                    SetCubeInfo(rotatorLeftTurn as _CubeBase, CubeLayers.cubeFull, CubeTypes.RotatorLeftTurner, true);
                    break;

                case CubeTypes.RotatorLocker:
                    newCube.AddComponent(typeof(RotatorLocker));
                    RotatorLocker rotatorLocker = newCube.GetComponent <RotatorLocker>();
                    SetCubeInfo(rotatorLocker as _CubeBase, CubeLayers.cubeFull, CubeTypes.RotatorLocker, true);
                    break;

                case CubeTypes.ChaosBall:
                    newCube.AddComponent(typeof(ChaosBall));
                    ChaosBall chaosBall = newCube.GetComponent <ChaosBall>();
                    SetCubeInfo(chaosBall as _CubeBase, CubeLayers.cubeMoveable, CubeTypes.ChaosBall, false);
                    break;

                default:
                    //set epmty cubes as cubeEmpty
                    grid.kuboGrid[recoveredNode.nodeIndex - 1].cubeLayers = CubeLayers.cubeEmpty;
                    grid.kuboGrid[recoveredNode.nodeIndex - 1].cubeType   = CubeTypes.None;
                    break;
                }
            }

            finishedBuilding = true;
        }
Exemple #3
0
        public void RebuildLevel(List <Node> nodes, Biomes biome, List <Decor> decor)
        {
            finishedBuilding = false;

            // start by resetting the grid's nodes to their base states
            _Grid.instance.ResetIndexGrid();

            foreach (Node recoveredNode in nodes)
            {
                // EXTREMELY IMPORTANT -> CONVERTS THE CUBE'S TYPE FROM STRING TO ENUM
                recoveredNode.cubeType = Node.ConvertStringToCubeType(recoveredNode.savedCubeType);

                //Set the universe textures
                _MaterialCentral.instance.ChangeUniverse(biome);

                currentNode = recoveredNode;

                GameObject newCube = Instantiate(cubePrefab);

                _Grid.instance.placedCubes.Add(newCube);

                // get the kuboGrid and set the information on each of the nodes
                SetNodeInfo(newCube, recoveredNode.nodeIndex, recoveredNode.worldPosition, recoveredNode.worldRotation,
                            recoveredNode.facingDirection, recoveredNode.cubeLayers, recoveredNode.cubeType);

                // check the node's cube type and setup the relevant cube and its transform + individual information
                switch (recoveredNode.cubeType)
                {
                case CubeTypes.FullStaticCube:
                    newCube.AddComponent(typeof(StaticCube));
                    StaticCube fullStaticCube = newCube.GetComponent <StaticCube>();
                    SetCubeInfo(fullStaticCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.FullStaticCube, true);
                    break;

                case CubeTypes.EmptyStaticCube:
                    newCube.AddComponent(typeof(StaticCube));
                    StaticCube emptyCube = newCube.GetComponent <StaticCube>();
                    SetCubeInfo(emptyCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.EmptyStaticCube, true);
                    break;

                case CubeTypes.TopStaticCube:
                    newCube.AddComponent(typeof(StaticCube));
                    StaticCube topStaticCube = newCube.GetComponent <StaticCube>();
                    SetCubeInfo(topStaticCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.TopStaticCube, true);
                    break;

                case CubeTypes.CornerStaticCube:
                    newCube.AddComponent(typeof(StaticCube));
                    StaticCube cornerStaticCube = newCube.GetComponent <StaticCube>();
                    SetCubeInfo(cornerStaticCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.CornerStaticCube, true);
                    break;

                case CubeTypes.TripleStaticCube:
                    newCube.AddComponent(typeof(StaticCube));
                    StaticCube tripleStaticCube = newCube.GetComponent <StaticCube>();
                    SetCubeInfo(tripleStaticCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.TripleStaticCube, true);
                    break;

                case CubeTypes.QuadStaticCube:
                    newCube.AddComponent(typeof(StaticCube));
                    StaticCube quadStaticCube = newCube.GetComponent <StaticCube>();
                    SetCubeInfo(quadStaticCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.QuadStaticCube, true);
                    break;

                case CubeTypes.MoveableCube:
                    newCube.AddComponent(typeof(MoveableCube));
                    MoveableCube moveableCube = newCube.GetComponent <MoveableCube>();
                    SetCubeInfo(moveableCube as _CubeBase, CubeLayers.cubeMoveable, CubeTypes.MoveableCube, false);
                    break;

                case CubeTypes.BaseVictoryCube:
                    newCube.AddComponent(typeof(BaseVictoryCube));
                    BaseVictoryCube baseVictoryCube = newCube.GetComponent <BaseVictoryCube>();
                    SetCubeInfo(baseVictoryCube as _CubeBase, CubeLayers.cubeMoveable, CubeTypes.BaseVictoryCube, false);
                    break;

                case CubeTypes.ConcreteVictoryCube:
                    newCube.AddComponent(typeof(ConcreteVictoryCube));
                    ConcreteVictoryCube concreteVictoryCube = newCube.GetComponent <ConcreteVictoryCube>();
                    SetCubeInfo(concreteVictoryCube as _CubeBase, CubeLayers.cubeMoveable, CubeTypes.ConcreteVictoryCube, false);
                    break;

                case CubeTypes.BombVictoryCube:
                    newCube.AddComponent(typeof(BombVictoryCube));
                    BombVictoryCube bombVictoryCube = newCube.GetComponent <BombVictoryCube>();
                    SetCubeInfo(bombVictoryCube as _CubeBase, CubeLayers.cubeMoveable, CubeTypes.BombVictoryCube, false);
                    break;

                case CubeTypes.SwitchVictoryCube:
                    newCube.AddComponent(typeof(SwitchVictoryCube));
                    SwitchVictoryCube switchVictoryCube = newCube.GetComponent <SwitchVictoryCube>();
                    SetCubeInfo(switchVictoryCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.SwitchVictoryCube, true);
                    break;

                case CubeTypes.DeliveryCube:
                    newCube.AddComponent(typeof(DeliveryCube));
                    DeliveryCube deliveryCube = newCube.GetComponent <DeliveryCube>();
                    SetCubeInfo(deliveryCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.DeliveryCube, true);
                    break;

                case CubeTypes.BlueElevatorCube:
                    newCube.AddComponent(typeof(ElevatorCube));
                    ElevatorCube blueElevatorCube = newCube.GetComponent <ElevatorCube>();
                    blueElevatorCube.isGreen = false;
                    SetCubeInfo(blueElevatorCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.BlueElevatorCube, false);
                    break;

                case CubeTypes.GreenElevatorCube:
                    newCube.AddComponent(typeof(ElevatorCube));
                    ElevatorCube greenElevatorCube = newCube.GetComponent <ElevatorCube>();
                    greenElevatorCube.isGreen = true;
                    SetCubeInfo(greenElevatorCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.GreenElevatorCube, false);
                    break;

                case CubeTypes.ConcreteCube:
                    newCube.AddComponent(typeof(ConcreteCube));
                    ConcreteCube concreteCube = newCube.GetComponent <ConcreteCube>();
                    SetCubeInfo(concreteCube as _CubeBase, CubeLayers.cubeMoveable, CubeTypes.ConcreteCube, false);
                    break;

                case CubeTypes.BombCube:
                    newCube.AddComponent(typeof(BombCube));
                    BombCube bombCube = newCube.GetComponent <BombCube>();
                    SetCubeInfo(bombCube as _CubeBase, CubeLayers.cubeMoveable, CubeTypes.BombCube, false);
                    break;

                    #region // TIMER CUBE
                case CubeTypes.TimerCube1:
                    newCube.AddComponent(typeof(TimerCube));
                    TimerCube timerCube = newCube.GetComponent <TimerCube>();
                    SetCubeInfo(timerCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.TimerCube1, true);
                    timerCube.timerValue = 1;
                    break;

                case CubeTypes.TimerCube2:
                    newCube.AddComponent(typeof(TimerCube));
                    TimerCube timerCube2 = newCube.GetComponent <TimerCube>();
                    SetCubeInfo(timerCube2 as _CubeBase, CubeLayers.cubeFull, CubeTypes.TimerCube2, true);
                    timerCube2.timerValue = 2;
                    break;

                case CubeTypes.TimerCube3:
                    newCube.AddComponent(typeof(TimerCube));
                    TimerCube timerCube3 = newCube.GetComponent <TimerCube>();
                    SetCubeInfo(timerCube3 as _CubeBase, CubeLayers.cubeFull, CubeTypes.TimerCube3, true);
                    timerCube3.timerValue = 3;
                    break;

                case CubeTypes.TimerCube4:
                    newCube.AddComponent(typeof(TimerCube));
                    TimerCube timerCube4 = newCube.GetComponent <TimerCube>();
                    SetCubeInfo(timerCube4 as _CubeBase, CubeLayers.cubeFull, CubeTypes.TimerCube4, true);
                    timerCube4.timerValue = 4;
                    break;

                case CubeTypes.TimerCube5:
                    newCube.AddComponent(typeof(TimerCube));
                    TimerCube timerCube5 = newCube.GetComponent <TimerCube>();
                    SetCubeInfo(timerCube5 as _CubeBase, CubeLayers.cubeFull, CubeTypes.TimerCube5, true);
                    timerCube5.timerValue = 5;
                    break;

                case CubeTypes.TimerCube6:
                    newCube.AddComponent(typeof(TimerCube));
                    TimerCube timerCube6 = newCube.GetComponent <TimerCube>();
                    SetCubeInfo(timerCube6 as _CubeBase, CubeLayers.cubeFull, CubeTypes.TimerCube6, true);
                    timerCube6.timerValue = 6;
                    break;

                case CubeTypes.TimerCube7:
                    newCube.AddComponent(typeof(TimerCube));
                    TimerCube timerCube7 = newCube.GetComponent <TimerCube>();
                    SetCubeInfo(timerCube7 as _CubeBase, CubeLayers.cubeFull, CubeTypes.TimerCube7, true);
                    timerCube7.timerValue = 7;
                    break;

                case CubeTypes.TimerCube8:
                    newCube.AddComponent(typeof(TimerCube));
                    TimerCube timerCube8 = newCube.GetComponent <TimerCube>();
                    SetCubeInfo(timerCube8 as _CubeBase, CubeLayers.cubeFull, CubeTypes.TimerCube8, true);
                    timerCube8.timerValue = 8;
                    break;

                case CubeTypes.TimerCube9:
                    newCube.AddComponent(typeof(TimerCube));
                    TimerCube timerCube9 = newCube.GetComponent <TimerCube>();
                    SetCubeInfo(timerCube9 as _CubeBase, CubeLayers.cubeFull, CubeTypes.TimerCube9, true);
                    timerCube9.timerValue = 9;
                    break;
                    #endregion CUBES

                case CubeTypes.SwitchButton:
                    newCube.AddComponent(typeof(SwitchButton));
                    SwitchButton switchButton = newCube.GetComponent <SwitchButton>();
                    SetCubeInfo(switchButton as _CubeBase, CubeLayers.cubeFull, CubeTypes.SwitchButton, true);
                    break;

                case CubeTypes.SwitchCube:
                    newCube.AddComponent(typeof(SwitchCube));
                    SwitchCube switchCube = newCube.GetComponent <SwitchCube>();
                    SetCubeInfo(switchCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.SwitchCube, true);
                    break;

                case CubeTypes.RotatorRightTurner:
                    newCube.AddComponent(typeof(RotateRightCube));
                    RotateRightCube rotatorRightTurn = newCube.GetComponent <RotateRightCube>();
                    SetCubeInfo(rotatorRightTurn as _CubeBase, CubeLayers.cubeFull, CubeTypes.RotatorRightTurner, true);
                    break;

                case CubeTypes.RotatorLeftTurner:
                    newCube.AddComponent(typeof(RotateLeftCube));
                    RotateLeftCube rotatorLeftTurn = newCube.GetComponent <RotateLeftCube>();
                    SetCubeInfo(rotatorLeftTurn as _CubeBase, CubeLayers.cubeFull, CubeTypes.RotatorLeftTurner, true);
                    break;

                case CubeTypes.RotatorLocker:
                    newCube.AddComponent(typeof(RotatorLocker));
                    RotatorLocker rotatorLocker = newCube.GetComponent <RotatorLocker>();
                    SetCubeInfo(rotatorLocker as _CubeBase, CubeLayers.cubeFull, CubeTypes.RotatorLocker, true);
                    break;

                case CubeTypes.ChaosBall:
                    newCube.AddComponent(typeof(ChaosBall));
                    ChaosBall chaosBall = newCube.GetComponent <ChaosBall>();
                    SetCubeInfo(chaosBall as _CubeBase, CubeLayers.cubeMoveable, CubeTypes.ChaosBall, false);
                    break;

                default:
                    //set epmty cubes as cubeEmpty
                    _Grid.instance.kuboGrid[recoveredNode.nodeIndex - 1].cubeLayers = CubeLayers.cubeEmpty;
                    _Grid.instance.kuboGrid[recoveredNode.nodeIndex - 1].cubeType   = CubeTypes.None;
                    break;
                }
            }


            foreach (Decor recoveredDecor in decor)
            {
                //Instantiate new decor thing

                GameObject newDecor = Instantiate(decorPrefab);

                _Grid.instance.placedDecor.Add(newDecor);

                newDecor.AddComponent(typeof(DecorObject));

                DecorObject decorObject = newDecor.GetComponent <DecorObject>();
                decorObject.LoadDecor(recoveredDecor);
            }

            finishedBuilding = true;
        }