Example #1
0
        //CALLED WHEN PLACING CUBES
        void CubeTypeMessage(_LevelEditor.EditorCubeType cubeType)
        {
            switch (cubeType)
            {
            case _LevelEditor.EditorCubeType.Static:
                cubeData.cubeType = CubeType.Static;
                staticCube        = gameObject.AddComponent(typeof(_StaticCube)) as _StaticCube;
                staticCube        = gameObject.GetComponent <_StaticCube>();
                staticCube.ChangeMaterialPreset(cubeTexture);                                           //Cube texture value is set by the LevelEditor script
                break;

            case _LevelEditor.EditorCubeType.Moveable:
                cubeData.cubeType = CubeType.Moveable;
                movableCube       = gameObject.AddComponent(typeof(_MovableCube)) as _MovableCube;
                movableCube       = gameObject.GetComponent <_MovableCube>();
                movableCube.ChangeMaterialPreset(cubeTexture);                                          //Cube texture value is set by the LevelEditor script
                break;

            case _LevelEditor.EditorCubeType.Victory:
                cubeData.cubeType = CubeType.Victory;
                victoryCube       = gameObject.AddComponent(typeof(_VictoryCube)) as _VictoryCube;
                victoryCube       = gameObject.GetComponent <_VictoryCube>();
                victoryCube.ChangeMaterialPreset(cubeTexture);                                          //Cube texture value is set by the LevelEditor script
                break;

            case _LevelEditor.EditorCubeType.Spawn:
                cubeData.cubeType = CubeType.SpawnPoint;
                characterScript   = gameObject.AddComponent(typeof(_Character)) as _Character;
                characterScript   = gameObject.GetComponent <_Character>();
                staticCube.ChangeMaterialPreset(cubeTexture);                                           //Cube texture value is set by the LevelEditor script
                break;

            case _LevelEditor.EditorCubeType.Delivery:
                cubeData.cubeType = CubeType.Delivery;
                deliveryCube      = gameObject.AddComponent(typeof(_DeliveryCube)) as _DeliveryCube;
                deliveryCube      = gameObject.GetComponent <_DeliveryCube>();
                deliveryCube.ChangeMaterialPreset(cubeTexture);                                         //Cube texture value is set by the LevelEditor script
                break;

            case _LevelEditor.EditorCubeType.Timer:
                cubeData.cubeType = CubeType.Timer;
                timerCube         = gameObject.AddComponent(typeof(_TimerCube)) as _TimerCube;
                timerCube         = gameObject.GetComponent <_TimerCube>();
                timerCube.ChangeMaterialPreset(cubeTexture);                                            //Cube texture value is set by the LevelEditor script
                break;

            case _LevelEditor.EditorCubeType.Sticky:
                cubeData.cubeType = CubeType.Sticky;
                stickyCube        = gameObject.AddComponent(typeof(_StickyCube)) as _StickyCube;
                stickyCube        = gameObject.GetComponent <_StickyCube>();
                stickyCube.ChangeMaterialPreset(cubeTexture);                                           //Cube texture value is set by the LevelEditor script
                break;

            case _LevelEditor.EditorCubeType.Switch:
                cubeData.cubeType = CubeType.Switch;
                switchCube        = gameObject.AddComponent(typeof(_SwitchCube)) as _SwitchCube;
                switchCube        = gameObject.GetComponent <_SwitchCube>();
                switchCube.ChangeMaterialPreset(cubeTexture);                                           //Cube texture value is set by the LevelEditor script
                break;

            case _LevelEditor.EditorCubeType.Mirror:
                cubeData.cubeType = CubeType.Mirror;
                mirrorCube        = gameObject.AddComponent(typeof(_MirrorCube)) as _MirrorCube;
                mirrorCube        = gameObject.GetComponent <_MirrorCube>();
                mirrorCube.ChangeMaterialPreset(cubeTexture);                                           //Cube texture value is set by the LevelEditor script
                break;

            case _LevelEditor.EditorCubeType.Elevator:
                cubeData.cubeType = CubeType.Elevator;
                elevatorCube      = gameObject.AddComponent(typeof(_ElevatorCube)) as _ElevatorCube;
                elevatorCube      = gameObject.GetComponent <_ElevatorCube>();
                elevatorCube.ChangeMaterialPreset(cubeTexture);
                break;

            case _LevelEditor.EditorCubeType.Unmoveable:
                cubeData.cubeType = CubeType.Unmoveable;
                unmoveableCube    = gameObject.AddComponent(typeof(_UnmoveableCube)) as _UnmoveableCube;
                unmoveableCube    = gameObject.GetComponent <_UnmoveableCube>();
                unmoveableCube.ChangeMaterialPreset(cubeTexture);
                break;
            }

            //save the cubeTexture values (file and name)
            cubeData.internalCubeTexture = cubeTexture;
            cubeData.myCubeTextureString = cubeTexture.name;

            cubeTextureRef = cubeTexture;
        }
Example #2
0
        //CALLED ON LOAD, after data has been reassigned, "reconfigures" the cube
        void ConfigureCube()
        {
            cubeTexture = Resources.Load(cubeData.myCubeTextureString) as ScriptObjMaterial;

            switch (cubeData.cubeType)
            {
            case CubeType.Static:
                staticCube = gameObject.AddComponent(typeof(_StaticCube)) as _StaticCube;
                staticCube = gameObject.GetComponent <_StaticCube>();
                staticCube.ChangeMaterialPreset(cubeTexture);
                break;

            case CubeType.Moveable:
                movableCube = gameObject.AddComponent(typeof(_MovableCube)) as _MovableCube;
                movableCube = gameObject.GetComponent <_MovableCube>();
                movableCube.ChangeMaterialPreset(cubeTexture);
                break;

            case CubeType.Victory:
                victoryCube = gameObject.AddComponent(typeof(_VictoryCube)) as _VictoryCube;
                victoryCube = gameObject.GetComponent <_VictoryCube>();
                victoryCube.ChangeMaterialPreset(cubeTexture);
                cubeData.isVictory       = true;
                victoryCube.isUnmoveable = cubeData.isUnmoveableCube;

                break;

            case CubeType.SpawnPoint:
                characterScript = gameObject.AddComponent(typeof(_Character)) as _Character;
                characterScript = gameObject.GetComponent <_Character>();
                characterScript.ChangeMaterialPreset(cubeTexture);
                break;

            case CubeType.Delivery:
                deliveryCube = gameObject.AddComponent(typeof(_DeliveryCube)) as _DeliveryCube;
                deliveryCube = gameObject.GetComponent <_DeliveryCube>();
                deliveryCube.ChangeMaterialPreset(cubeTexture);

                deliveryCube.isMovable = cubeData.isMovable;
                deliveryCube.forward   = cubeData.forward;
                deliveryCube.right     = cubeData.right;
                deliveryCube.left      = cubeData.left;
                deliveryCube.back      = cubeData.back;
                deliveryCube.up        = cubeData.up;
                deliveryCube.down      = cubeData.down;
                break;

            case CubeType.Timer:
                timerCube = gameObject.AddComponent(typeof(_TimerCube)) as _TimerCube;
                timerCube = gameObject.GetComponent <_TimerCube>();
                timerCube.ChangeMaterialPreset(cubeTexture);

                timerCube.numberOfTimesMoved = cubeData.numberOfTimesToMove;
                timerCube.numberOfTimesMoved = cubeData.numberOfTimesMoved;

                timerCube.isMovable = cubeData.isMovable;
                timerCube.forward   = cubeData.forward;
                timerCube.right     = cubeData.right;
                timerCube.left      = cubeData.left;
                timerCube.back      = cubeData.back;
                timerCube.up        = cubeData.up;
                timerCube.down      = cubeData.down;
                break;

            case CubeType.Sticky:
                stickyCube = gameObject.AddComponent(typeof(_StickyCube)) as _StickyCube;
                stickyCube = gameObject.GetComponent <_StickyCube>();
                stickyCube.ChangeMaterialPreset(cubeTexture);                                           //Cube texture value is set by the LevelEditor script

                stickyCube.forward = cubeData.forward;
                stickyCube.right   = cubeData.right;
                stickyCube.left    = cubeData.left;
                stickyCube.back    = cubeData.back;
                stickyCube.up      = cubeData.up;
                stickyCube.down    = cubeData.down;
                break;

            case CubeType.Switch:
                switchCube = gameObject.AddComponent(typeof(_SwitchCube)) as _SwitchCube;
                switchCube = gameObject.GetComponent <_SwitchCube>();
                switchCube.ChangeMaterialPreset(cubeTexture);                                           //Cbe texture value is set by the LevelEditor script

                switchCube.forward = cubeData.forward;
                switchCube.right   = cubeData.right;
                switchCube.left    = cubeData.left;
                switchCube.back    = cubeData.back;
                switchCube.up      = cubeData.up;
                switchCube.down    = cubeData.down;
                break;

            case CubeType.Mirror:
                mirrorCube = gameObject.AddComponent(typeof(_MirrorCube)) as _MirrorCube;
                mirrorCube = gameObject.GetComponent <_MirrorCube>();
                mirrorCube.ChangeMaterialPreset(cubeTexture);                                           //Cube texture value is set by the LevelEditor script

                /*mirrorCube.linkedPositionX = cubeData.savedLinkedPosX;
                *  mirrorCube.linkedPositionY = cubeData.savedLinkedPosY;
                *  mirrorCube.linkedPositionZ = cubeData.savedLinkedPosZ;*/
                break;

            case CubeType.Elevator:
                elevatorCube = gameObject.AddComponent(typeof(_ElevatorCube)) as _ElevatorCube;
                elevatorCube = gameObject.GetComponent <_ElevatorCube>();
                elevatorCube.ChangeMaterialPreset(cubeTexture);

                elevatorCube.moveInScanDirection = cubeData.isGreen;
                elevatorCube.forward             = cubeData.forward;
                elevatorCube.right = cubeData.right;
                elevatorCube.left  = cubeData.left;
                elevatorCube.back  = cubeData.back;
                elevatorCube.up    = cubeData.up;
                elevatorCube.down  = cubeData.down;
                break;

            case CubeType.Unmoveable:
                unmoveableCube = gameObject.AddComponent(typeof(_UnmoveableCube)) as _UnmoveableCube;
                unmoveableCube = gameObject.GetComponent <_UnmoveableCube>();
                unmoveableCube.ChangeMaterialPreset(cubeTexture);
                break;

            default:
                break;
            }

            cubeData.internalCubeTexture = cubeTexture;
            cubeTextureRef = cubeTexture;
        }