void Awake() { this.persistentInfoPrefab = Resources.Load <PersistentShipInfo>("Prefabs/ShipInfo"); this.ships = GetComponentsInChildren <ShipInfo>(); foreach (ShipInfo ship in ships) { ship.selectingPlayer = this.player; } #region Keyboard Support if (this.player == PlayerEnum.player1) { this.left = KeyCode.A; this.right = KeyCode.D; this.A = KeyCode.Alpha1; this.B = KeyCode.Alpha2; this.Y = KeyCode.Alpha4; this.start = KeyCode.Space; } else if (this.player == PlayerEnum.player2) { this.left = KeyCode.LeftArrow; this.right = KeyCode.RightArrow; this.A = KeyCode.Keypad1; this.B = KeyCode.Keypad2; this.Y = KeyCode.Keypad4; this.start = KeyCode.KeypadEnter; } #endregion }
IEnumerator OnLevelWasLoaded(int levelIndex) { if (SceneManager.GetActiveScene().name != GameManager.MainSceneName) { yield break; } //Wait for GameManager to initialize itself while (GameManager.S == null) { yield return(null); } //Wait 2 frames, since GameManager takes 1 frame to re-assign player references yield return(null); yield return(null); //Wait an additional frame to initialize player 2's ship to guarantee initialization order if (selectedShip.selectingPlayer == PlayerEnum.player2) { yield return(null); } //Create the object that will pass the information to GameManager PersistentShipInfo persistentShipInfo = Instantiate(persistentInfoPrefab); persistentShipInfo.gameObject.name = "P" + ((int)selectedShip.selectingPlayer + 1) + "ShipInfo"; persistentShipInfo.Initialize(selectedShip, device); Destroy(gameObject); }
//TODO: JPS: OnLevelWasLoaded is deprecated. Replace this implementation with SceneManager stuff at some point IEnumerator OnLevelWasLoaded(int levelIndex) { if (SceneManager.GetActiveScene().name != GameManager.MainSceneName) { yield break; } //Wait for GameManager to initialize itself while (GameManager.S == null) { yield return(null); } //Wait 2 frames, since GameManager takes 1 frame to re-assign player references //TODO: Can we have a more general implementation of this? yield return(null); yield return(null); for (int curControlsIndex = 0; curControlsIndex < this.shipSelectionControls.Count; curControlsIndex++) { //Create the object that will pass the information to GameManager PersistentShipInfo persistentShipInfo = Instantiate(this.shipSelectionControls[curControlsIndex].persistentInfoPrefab); persistentShipInfo.gameObject.name = "P" + ((int)this.shipSelectionControls[curControlsIndex].player + 1) + "_ShipInfo"; persistentShipInfo.Initialize(this.shipSelectionControls[curControlsIndex].selectedShip, this.shipSelectionControls[curControlsIndex].device); } Destroy(this.gameObject); }
void Awake() { persistentInfoPrefab = Resources.Load <PersistentShipInfo>("Prefabs/ShipInfo"); DontDestroyOnLoad(this.gameObject); if (selectionMenus == null) { selectionMenus = new List <ShipSelectionManager>(); } selectionMenus.Add(this); }