// public Dictionary <int, LevelChunk> createLevelChunks() { Dictionary <int, LevelChunk> chunks = new Dictionary <int, LevelChunk> (); int i; for (i = 0; i < _numLevels; ++i) { LevelStruct level = _levelByIndex [i]; GameObject gameObject = AssetFactory.Instance.createVoxelsLevelContainer(); gameObject.name = "LevelChunk_" + level.id.ToString(); Vector3 chunkPos = new Vector3(level.x * Globals.LEVEL_WIDTH, -level.y * Globals.LEVEL_HEIGHT, level.z * Globals.LEVEL_DEPTH); gameObject.transform.position = chunkPos; LevelChunk chunk = gameObject.AddComponent <LevelChunk> (); chunk.init(chunkPos); chunk.setLevelData(level); chunks.Add(level.id, chunk); } return(chunks); }
// public void teleportToLevelWithId(int levelId) { if (_curLevelChunk != null) { _curLevelChunk.activate(false); } _curLevelChunk = _levelChunks [levelId]; _curLevelChunk.activate(true); FlyCam.Instance.setNewInitialPosition(_curLevelChunk.getStartPos(), _curLevelChunk.getStartRotation()); resetCamToStartPos(); checkLevelChunkDistances(); }
// public void createLevelChunkWithIndex(int levelId, int levelIndex) { _curLevelChunk = _levelChunks [levelId]; LevelManager.Instance.loadLevelByIndex(levelIndex); _curLevelChunk.activate(false, true); }
void Awake() { Cursor.lockState = CursorLockMode.None; Cursor.visible = true; _createLevelMeshesRunning = false; _createLevelMeshesComplete = true; _isInitialised = false; _levelChunks = new Dictionary <int, LevelChunk> (); _curLevelChunk = null; _voxelsLevelChunks = new Dictionary <int, VoxelsLevelChunk> (); _curVoxelsLevelChunk = null; _aTextures = new List <Texture> (); _aMaterials = new List <Material> (); _aDictMaterials = new Dictionary <string, Material> (); int i, len = Globals.materials.Length; for (i = 0; i < len; ++i) { _aTextures.Add(Resources.Load <Texture> ("Textures/Chunks/" + Globals.materials [i])); _aMaterials.Add(Resources.Load <Material> ("Materials/Chunks/" + Globals.materials [i])); //Debug.Log (_aMaterials[i].name); _aDictMaterials.Add(Globals.materials [i], _aMaterials[_aMaterials.Count - 1]); } _aToolMaterials = new List <Material> (); len = Globals.materialsTools.Length; for (i = 0; i < len; ++i) { _aToolMaterials.Add(Resources.Load <Material> ("Materials/Tools/" + Globals.materialsTools [i])); //Debug.Log (_aToolMaterials[i].name); } _undoActions = new List <undoAction> (); _goCurProp = null; _selectedObjects = new List <GameObject> (); _activeCam = editCam; _nextDistanceUpdate = 0; _fRockSize = VoxelUtils.CHUNK_SIZE; _cubesPerQuadrant = 2; _fQuadrantSize = (float)_cubesPerQuadrant * _fRockSize; _goLevelContainer = new GameObject(); _goLevelContainer.name = "[LevelChunks]"; _goLevelMeshContainer = new GameObject(); _goLevelMeshContainer.name = "[LevelChunkMeshes]"; _GridEditorExperimental.activate(false); // Instantiate app controller singleton if (GameObject.Find(Globals.appContainerName) == null) { GameObject goAppController = new GameObject(Globals.appContainerName); DontDestroyOnLoad(goAppController); goAppController.AddComponent <AppController> (); } if (GameObject.Find(Globals.netContainerName) == null) { GameObject goNetManager = new GameObject(Globals.netContainerName); DontDestroyOnLoad(goNetManager); goNetManager.AddComponent <NetManager> (); } }