예제 #1
0
        public void Cargar()
        {
            Debug.Log("Liberado");
            Liberar();
            Debug.Log("Cargando");
            mapaVoxel = new MapaVoxel();

            string m_Path = Application.dataPath;
            string ruta   = m_Path + "/JoinCatCode/ArchivosGuardados/" + "Mundo1";

            mapaVoxel.CargarMapa(ruta, "Mundo1", DataFormat.Binary);
        }
예제 #2
0
 public Mundo(string nombre, int ancho, int altura, int largo, int idMaterialTerreno)
 {
     //Output the Game data path to the console
     this.nombre = nombre;
     tamAzulejo  = new Vector3Int(1, 1, 1);
     tamMundo.x  = ancho;
     tamMundo.z  = largo;
     tamMundo.y  = altura;
     //Se asume que se maneja texturas de 128 x 128 un total de 16 texturas de largo 16 ancho
     mapaVoxel = new MapaVoxel(nombre, idMaterialTerreno, new Vector3Int(ancho, altura, largo), 16);
     mapaVoxel.LlenarMapaTodo(1);
     mapaPosiciones = new Mapa <byte>(nombre, new Vector3Int(ancho, altura, largo), new Vector3Int(1, 1, 1), 30, false);
     mapaRecursos   = new MapaNativo <Entity>(nombre, new Vector3Int(ancho, altura, largo), new Vector3(1, 1, 1), 30, false);
 }
예제 #3
0
        //	public byte[,,] mapaVoxelsDirecciones;

        public BloqueVoxel(MapaVoxel mapa, Vector3 posicion)
        {
            this.mapa  = mapa;
            mapaVoxels = new byte[(int)mapa.voxelTam.x, (int)mapa.voxelTam.y, (int)mapa.voxelTam.z];
            //	mapaVoxelsDirecciones= new byte[mapa.voxelTam.x, mapa.voxelTam.y, mapa.voxelTam.z];
            gameObject            = new GameObject();
            meshFilter            = gameObject.AddComponent <MeshFilter>();
            meshRenderer          = gameObject.AddComponent <MeshRenderer>();
            meshRenderer.material = mapa.material;
            meshRenderer.allowOcclusionWhenDynamic = false;
            this.posicion = posicion;
            gameObject.transform.localPosition = new Vector3((posicion.x * mapa.voxelTam.x) - 0.5f, -0.5f, (posicion.z * mapa.voxelTam.z) - 0.5f);
            gameObject.transform.parent        = mapa.gameObject.transform;
            gameObject.name = "Voxel_" + posicion.x + "_" + posicion.z;
            BloqueLleno     = false;
        }
예제 #4
0
        public void CargarMapa(string rutaArchivo, string nombre, DataFormat tipoFormato)
        {
            string ruta       = rutaArchivo + "/MapaVoxel_" + nombre;
            string rutaNombre = ruta + "/MapaVoxel_" + nombre + ".jcc";

            if (!File.Exists(rutaNombre))
            {
                return; // No state to load
            }
            else
            {
                byte[]    bytes = File.ReadAllBytes(rutaNombre);
                MapaVoxel temp  = SerializationUtility.DeserializeValue <MapaVoxel>(bytes, tipoFormato);
                this.mapaTam           = temp.mapaTam;
                this.nombre            = temp.nombre;
                this.texturasCuadrante = temp.texturasCuadrante;
                this.voxelTam          = temp.voxelTam;
                this.xV         = temp.xV;
                this.zV         = temp.zV;
                this.idMaterial = temp.idMaterial;
                this.material   = AdministradorMateriales.Instanciar().ObtenerMaterial(temp.idMaterial).material;
                /*-----*/
                this.gameObject  = new GameObject(nombre + "Cargado");
                contenedorVoxels = new BloqueVoxel[this.xV, this.zV];
                for (int x = 0; x < xV; x++)
                {
                    for (int z = 0; z < zV; z++)
                    {
                        BloqueVoxel nuevo = new BloqueVoxel(this, new Vector3(x, 0, z));

                        nuevo.CargarBloque(ruta, tipoFormato);
                        contenedorVoxels[x, z] = nuevo;
                    }
                }
            }
        }