void Awake() { //FPController = FindObjectOfType<CharacterControls>(); loadSceneryAndLore = FindObjectOfType <LoadSceneryAndLore>(); player = FPController.GetComponent <Transform>(); // get terrain actTerrain = Terrain.activeTerrain; terrainData = actTerrain.terrainData; StartCoroutine(EnterLoadingMode()); }
public void Update() { //!sceneObjects.ToList().Where(x => x.modelLocation == null).Any() if (!spawned && beginCheck && !sceneObject.namedModels.Where(pair => pair.Value == null).Any()) { Debug.Log("Spawning... "); debugDisplay.text = "Spawning... "; int j = 0; for (int i = (sceneObjects.Count > 1) ? 1 : 0; i < sceneObjects.Count; i++) { if (sceneObjects[i].firstInSentence || i == sceneObjects.Count - 1) { Vector3?d = null; for (int k = i - ((i == sceneObjects.Count - 1) ? 0 : 1); k >= j; k--) { var subject = sceneObjects[k]; //Debug.Log(subject.modelLocation); //debugDisplay.text = "From " + subject.modelLocation; //var e = Instantiate (Resources.Load ("Empty") as GameObject,new Vector3(UnityEngine.Random.value*10 - 5,0,UnityEngine.Random.value*10-5),Quaternion.identity); //var loader = e.GetComponent<Loader3DS>(); //loader.modelPath = subject.modelLocation; //StartCoroutine(loader.Loader(loader.modelPath)); // we want to pass a direction and relative location for each object. // In most case the reletive location will be the center of camera space Vector3 startingLoc = (k == i - ((i == sceneObjects.Count - 1) ? 0 : 1)) ? Camera.main.transform.position : previousPos; Vector3 dir = d ?? new Vector3(UnityEngine.Random.value, 0, UnityEngine.Random.value); // set the dir for next d = subject.direction; // if its the first thing in the sceen we need to apply the direction to it (from the camera) if (subject.firstInSentence && d != null) { dir = d ?? new Vector3(UnityEngine.Random.value, 0, UnityEngine.Random.value); } int amt = subject.multiple ? 2 + (int)(5 * UnityEngine.Random.value * UnityEngine.Random.value) : 1; Position.PlaceObject(subject.name, startingLoc, dir, amt); } j = i; } } spawned = true; // Remove gui foreach (GameObject g in disableOnLoad) { g.SetActive(false); } // activate movement fps.enabled = true; fps.GetComponent <CharacterController>().enabled = true; restartText.SetActive(true); } if (spawned && Input.GetKeyDown(KeyCode.Escape)) { DeleteOld(); SceneManager.LoadScene("Main"); } }