Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // ABOUT //
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /*
- * This file is a MissionTemplate Template (of the reduntant department of redundancy :D). MissionTemplates can be spawned in to allow the spawning
- * of new actors in a certain way, and are the basis of any RPG level.
- *
- * When copying this file to create a new mission template, be sure to rename the class name AND the file name to the same name, and to change this description
- * to explain what is in the template!
- *
- * - Ramaraunt
- */
- //This class extends Monobehavior, and contains the base methods of Unity.
- #region MissionTemplates Class
- public class MissionTemplates : MonoBehaviour {
- //Initialize spawners here. Say, for instance:
- // public GameObject spawner;
- //Then drag and drop the correct object to the script within Unity IDE.
- #region init spawners here
- #endregion
- //This is the part you edit to make new MTs!
- #region Editable Region
- //This method automatically runs when the object that contains this script is created.
- void Awake ()
- {
- }
- //This method is called once per frame of the game.
- void Update ()
- {
- //if you want to make something that occurs after a certain amount of time, go like this:
- /*
- *
- * if (Time.time >= <enter time here>)
- * {
- * Do stuff here!
- * }
- *
- */
- }
- /*
- //Use this method if you are interested in having actors spawn in after a trigger has been hit!
- void onTriggerEnter()
- {
- }
- */
- #endregion
- //This region contains background methods which are important for MTs to run correctly. DONT TOUCH THESE (unless you know what your doing and you have a good reason).
- //Please, feel free to look around though. :D
- #region Other Stuffs (no touchy)
- //This region contains a series of utility methods, to be called up above and down bellow.
- #region Utilities
- //This method grabs the prefab of a model, and returns it as a GameObject.
- private GameObject returnPrefabFromPath(string path)
- {
- return Resources.Load(path) as GameObject;
- }
- //This method instantiates a prefab with the GameObject as an argument. It returns the GameObject. It has an overloaded method without rotation and position.
- private GameObject instantiatePrefabFromGameObject(Vector3 position, Quaternion rotation, GameObject objectToInstantiate)
- {
- return ((GameObject)Instantiate(objectToInstantiate, position, rotation));
- }
- private GameObject instantiatePrefabFromGameObject(GameObject objectToInstantiate)
- {
- return ((GameObject)Instantiate(objectToInstantiate));
- }
- // This method instantiates a game object from a path argument. It returns the GameObject. It has an overloaded method without rotation and position.
- private GameObject instantiatePrefabFromPath(Vector3 position, Quaternion rotation, string path)
- {
- return instantiatePrefabFromGameObject(position ,rotation, returnPrefabFromPath(path));
- }
- private GameObject instantiatePrefabFromPath(string path)
- {
- return instantiatePrefabFromGameObject(returnPrefabFromPath(path));
- }
- //This method grabs a material from a path and returns it.
- private Material returnMaterialFromPath(string path)
- {
- return Resources.Load<Material>(path);
- }
- //This method adds a material to a specific game object, with an overloaded method grabbing the material directly using a path.
- private void addMaterialToGameObject(Material material, GameObject gameObject)
- {
- gameObject.GetComponent<Renderer>().sharedMaterial = material;
- }
- private void addMaterialToGameObject(string materialPath, GameObject gameObject)
- {
- gameObject.GetComponent<Renderer>().sharedMaterial = returnMaterialFromPath(materialPath);
- }
- //This method creates a parent-child relationship between two gameobjects
- private void setGameObjectParent(GameObject parent, GameObject child)
- {
- child.transform.parent = parent.transform;
- }
- //This method grabs the material from path, grabs the GameObject from path, and instantiates the object and returns its instance id.
- private GameObject setupActorModel(string materialPath, string gameObjectPath, Vector3 position, Quaternion rotation, GameObject parent)
- {
- GameObject cur_prefab = instantiatePrefabFromGameObject(position, rotation, returnPrefabFromPath(gameObjectPath));
- addMaterialToGameObject(materialPath, cur_prefab);
- setGameObjectParent(cur_prefab, parent);
- return cur_prefab;
- }
- #endregion
- //This region WILL contain stuff for AI calculations, but this isn't done yet!
- #region AI Stuffs
- #endregion
- //These methods are used for the actual creation of characters. Simply call these up above to make things happen!
- #region Actor Creation
- //This method makes a naked person, using the default constructor of Actor, at the origin point of the scene. Mostly used for bugtesting.
- public bool makeNaked()
- {
- Actor person = new Actor();
- if (person.getStatus())
- {
- //spawn the frame
- }
- else
- {
- Debug.Log("Creation of Naked Actor failed!");
- }
- return person.getStatus();
- }
- #endregion
- #endregion
- }
- #endregion
Add Comment
Please, Sign In to add comment