// ------------------------------------------------------------------------------ // Function Name: // Return types: // Argument types: // Author: // Date: // ------------------------------------------------------------------------------ // Purpose: // ------------------------------------------------------------------------------ public void NewGameButton() { //SceneManager.LoadScene(WLD_GameController.levels[Scenes.Tutorial].SceneIndex); if (placeHolderPanel != null) { placeHolderPanel.SetActive(false); } Dictionary<Scenes, UNA_Level> temp = null; WLD_GameController.controller.BuildGameLevels(temp); WLD_GameController.player.GetComponent<WLD_HealthDmg>().ChangeHealth(100); WLD_GameController.player.GetComponent<PLR_Points>().OverallPoints = 0; WLD_GameController.player.GetComponent<PLR_Points>().ResetToZero(); WLD_GameController.endPieces = null; WLD_GameController.AddGravitySettings(null); loader.LoadLevel(Scenes.Tutorial, Vector3.zero); }
// ------------------------------------------------------------------------------ // FUNCTIONS // ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------ // Function Name: Awake // Return types: N/A // Argument types: N/A // Author: Michael Smith // Date: 9/25/2017 // ------------------------------------------------------------------------------ // Purpose: Runs before any other script element; ensures this object is the only // game controller in the game, regardless of start point. // ------------------------------------------------------------------------------ private void Awake() { if (controller == null) { DontDestroyOnLoad(gameObject); controller = this; } else if (controller != this) { Destroy(gameObject); } if (levels == null) { if (BuildGameLevels(levels)) { Debug.Log("Levels and segments built.", this); } else { Debug.LogError("A problem was encountered when attempting to build the game levels.", this); } AttributeGravityValues(); } for (int i = 0; i < levels.Count; i++) { if (levels[(Scenes)i].SceneIndex == SceneManager.GetActiveScene().buildIndex) { activeLevel = levels[(Scenes)i]; } } if (player == null) { player = GameObject.FindGameObjectWithTag(UNA_Tags.player); } if (endPieces == null) { endPieces = new bool[7]; } if (mainUICanvas == null) { mainUICanvas = GameObject.Find("MainUICanvas"); } if (uIButtonManager == null) { uIButtonManager = GetComponentInChildren<UI_UIButtonManager>().gameObject; } LocateReferences(); Debug.Log(activeLevel.LevelName); if (activeLevel == levels[Scenes.Controls] || activeLevel == levels[Scenes.Credits] || activeLevel == levels[Scenes.MainMenu] || activeLevel == levels[Scenes.LoadGame]) { player.SetActive(false); Camera.main.GetComponent<WLD_CameraFollow_SL>().enabled = false; Camera.main.transform.position = new Vector3(0, 0, -16); Camera.main.transform.rotation = Quaternion.identity; } else { player.SetActive(true); Camera.main.GetComponent<WLD_CameraFollow_SL>().enabled = true; } if (activeLevel == levels[Scenes.Hub] || activeLevel == levels[Scenes.Controls] || activeLevel == levels[Scenes.Credits] || activeLevel == levels[Scenes.MainMenu] || activeLevel == levels[Scenes.LoadGame]) { mainUICanvas.GetComponent<Canvas>().enabled = false; } else { mainUICanvas.GetComponent<Canvas>().enabled = true; } WLD_Teleporter[] teleporters = FindObjectsOfType<WLD_Teleporter>(); for (int i = 0; i < activeLevel.LevelSegments.Length; i++) { for (int z = 0; z < teleporters.Length; z++) { if (activeLevel.LevelSegments[i].SegmentNumber == teleporters[z].segmentNumber) { activeLevel.LevelSegments[i].TeleporterX = teleporters[z].transform.position.x; activeLevel.LevelSegments[i].TeleporterY = teleporters[z].transform.position.y; activeLevel.LevelSegments[i].TeleporterZ = teleporters[z].transform.position.z; } } } if (gravitySettingDictionary == null) { AddGravitySettings(gravitySettingDictionary); } }