Beispiel #1
0
 //Enviroment Related
 /// <summary>
 /// Loads the Envieoment Entity Data with the geiven arguments
 /// </summary>
 /// <param name="enviromentDataPath">path to the enviroment data</param>
 /// <param name="enviromentData">reference to a enviomentData variable</param>
 /// <param name="position">reference to position</param>
 /// <param name="rotation">reference to Rotation</param>
 /// <param name="scale">reference to Scale</param>
 /// <returns>true if successful, false otherwise</returns>
 public static bool LoadEnviromentData(string enviromentDataPath, ref EnviromentData enviromentData, ref Translation position, ref Rotation rotation, ref Scale scale)
 {
     if (File.Exists(enviromentDataPath))
     {
         BinaryFormatter bf = new BinaryFormatter();
         Debug.Log("assaas: " + enviromentDataPath);
         FileStream file = File.Open(enviromentDataPath, FileMode.Open);
         EnviromentEntityDataSave enviromentEntityDataSave = new EnviromentEntityDataSave();
         try { enviromentEntityDataSave = (EnviromentEntityDataSave)bf.Deserialize(file); }
         catch (System.ArgumentNullException ex) { PrintString("LoadEnviromentData", "The given file information was null or invalid:" + ex.Message, 2); file.Close(); return(false); }
         catch (SerializationException ex) { PrintString("LoadEnviromentData", "Failed to Deserialize the data with path:" + enviromentDataPath + "," + ex.Message); file.Close(); return(false); }
         catch (System.Security.SecurityException ex) { PrintString("LoadEnviromentData", "Deserialization security Exception:" + ex.Message); file.Close(); return(false); }
         enviromentData = new EnviromentData()
         {
             entityName     = enviromentEntityDataSave.EntityName,
             entityId       = enviromentData.entityId,
             entityParentId = enviromentData.entityParentId,
             pathString     = enviromentData.pathString
         };
         position = enviromentEntityDataSave.Position;
         rotation = enviromentEntityDataSave.Rotation;
         scale    = enviromentEntityDataSave.Scale;
         file.Close();
         return(true);
     }
     else
     {
         PrintString("LoadEnviromentData", "Failed to load enviroment data with path: \"" + enviromentDataPath + "\"", 2);
     }
     return(false);
 }
        public async Task <IActionResult> PutEnviromentData(int?id, EnviromentData enviromentData)
        {
            Enviroment tochange = new Enviroment {
                ID = (int)id, EnviromentName = enviromentData.EnviromentName
            };

            if (id != tochange.ID)
            {
                return(BadRequest());
            }

            _context.Entry(tochange).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EnviromentDataExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <ActionResult <Enviroment> > PostEnviromentData(EnviromentData enviromentData)
        {
            _context.Enviroments.Add(new Enviroment {
                EnviromentName = enviromentData.EnviromentName
            });
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetEnviromentData", new { id = enviromentData.ID }, enviromentData));
        }
Beispiel #4
0
        //create changePokemon
        //create generateId
        /// <summary>
        /// generates a new Load RenderMesh value using the given values
        /// </summary>
        /// <param name="pokemonName"></param>
        /// <returns></returns>

        /*	public static RenderMesh LoadPokemonRenderMesh(string pokemonName)
         *      {
         *      ///	string dataPath = Application.dataPath + "/Resources/Pokemon/" + pokemonName + "/" + pokemonName + ".prefab";
         *      //	if (!File.Exists(dataPath))
         *      //	{
         *      //		Debug.LogError(dataPath);
         *      //	}
         *              GameObject go = Resources.Load("Pokemon/" + pokemonName + "/" + pokemonName, typeof(GameObject)) as GameObject;
         *              if (go == null) Debug.LogError("Failed to get the render mesh gameobject");
         *              else Debug.Log("Succesfully Loaded \""+pokemonName+"\"");
         *              //verify this works with physics
         *              RenderMesh renderer = new RenderMesh
         *              {
         *                      mesh = go.GetComponent<MeshFilter>().sharedMesh,
         *                      material = go.GetComponent<MeshRenderer>().sharedMaterial,
         *                      castShadows = UnityEngine.Rendering.ShadowCastingMode.On,
         *                      receiveShadows = true
         *              };
         *
         *              return renderer;
         *      }*/
        public static RenderMesh LoadEnviromentRenderMesh(EnviromentData enviromentData, string startPath)
        {
            startPath += enviromentData.entityName.ToString() + "/" + enviromentData.entityName.ToString();
            Debug.Log("adasdadasd" + startPath);
            GameObject go = Resources.Load("Enviroment/Models/" + startPath, typeof(GameObject)) as GameObject;

            UnityEngine.Material _mat     = Resources.Load("Enviroment/Models/" + startPath, typeof(UnityEngine.Material)) as UnityEngine.Material;
            UnityEngine.Mesh     _mesh    = go.GetComponent <MeshFilter>().sharedMesh;
            RenderMesh           renderer = new RenderMesh
            {
                mesh     = _mesh,
                material = _mat
            };

            return(renderer);
        }
Beispiel #5
0
 void Awake()
 {
     Instance = this;
 }