예제 #1
0
 public PrefabManager(TerrainSettings s)
 {
     th       = new TransformHelpers();
     Pool     = new PrefabPool();
     settings = s;
     InstantiatePrefabManagerObject();
 }
예제 #2
0
 public PrefabManager(Settings s)
 {
     th = new TransformHelpers();
     Pool = new PrefabPool();
     settings = s;
     InstantiatePrefabManagerObject();
 }
예제 #3
0
        public void InstantiatePrefab(Vector3 position, GameObject prefabManager, PrefabPool pool, float angle)
        {
            var prefab = pool.Add(PrefabToClone, position, angle, YRotation, PrefabToClone.name, MatchGroundAngle);

            prefab.transform.parent = prefabManager.transform;

            //If we have an offset (and we are placing prefabs at an angle), get the direction of that offset.
            //In otherwords, if our offset says to move one up in the y direction, getting the transform direction means the
            //prefab will move one up relative to the rotation it currently has
            Vector3 transformDirection = prefab.transform.TransformDirection(Offset);

            prefab.transform.position = transformDirection + prefab.transform.position;
        }
예제 #4
0
 public PrefabManager(Settings s, Transform parentTransform)
 {
     th       = new TransformHelpers();
     Pool     = new PrefabPool();
     settings = s;
     for (int i = 0; i < settings.PrefabRules.Count(); i++)
     {
         settings.PrefabRules[i].StartLocation      = Vector3.zero;
         settings.PrefabRules[i].CurrentLocation    = Vector3.zero;
         settings.PrefabRules[i].LastPrefabLocation = Vector3.zero;
     }
     this.parentTransform = parentTransform;
     InstantiatePrefabManagerObject(ManagerName);
 }
예제 #5
0
        public void InstantiatePrefab(Vector3 position, GameObject prefabManager, PrefabPool pool, float angle)
        {
            var prefab = pool.Add(PrefabToClone, position, angle, PrefabToClone.name, MatchGroundAngle);            
            prefab.transform.parent = prefabManager.transform;

			// Create randomised offset based on rule
			Vector3 randomisedOffset = new Vector3(UnityEngine.Random.Range (-1, 1) * RandomOffset.x, 
			                                       UnityEngine.Random.Range (-1, 1) * RandomOffset.y, 
			                                       UnityEngine.Random.Range (-1, 1) * RandomOffset.z);

            //If we have an offset (and we are placing prefabs at an angle), get the direction of that offset.
            //In otherwords, if our offset says to move one up in the y direction, getting the transform direction means the 
            //prefab will move one up relative to the rotation it currently has
            Vector3 transformDirection = prefab.transform.TransformDirection(Offset + randomisedOffset);
            prefab.transform.position = transformDirection + prefab.transform.position;
        }