public HallOfFameViewModel(HallOfFameManager hallOfFameManager) { _hallOfFameManager = hallOfFameManager; }
private void Start() { // Find GameModeManager component on the scene object named "GameModeManager" gmManager = GameObject.Find("GameModeManager").GetComponent <GameModeManager>(); // Find HallOfFameManager component on the scene object named "HallOfFameManager" hofManager = GameObject.Find("HallOfFameManager").GetComponent <HallOfFameManager>(); // Find GenerationManager component on the scene object named "GenerationManager" genManager = GameObject.Find("GenerationManager").GetComponent <GenerationManager>(); #region Initialize Vars player1.characterName = gmManager.p1Name; player2.characterName = gmManager.p2Name; // Set match timer based on the game mode time limit matchTimer = gmManager.timeLimit * 60; // Disable each player immunity system if the game mode doesn't allow it player1.hB.immunityEnabled = gmManager.respawnImmunity; player2.hB.immunityEnabled = gmManager.respawnImmunity; player1.mB.AMRAuthorized = gmManager.AMRAuthorized; player2.mB.AMRAuthorized = gmManager.AMRAuthorized; if (gmManager.gauntletStartsIncomplete) { player1.sB.SetStartWeapon(false); player2.sB.SetStartWeapon(false); } #endregion _playArena = new List <ArenaPiece>(); _playArena = genManager.Create(); // Get the position further away from the center piece, and then the // position furthest from that one. #region GetPlayerSpawnPositions // this list will hold the distances we want compared and the index // of the piece we measured, for easy access later. List <(float mag, int index)> distAndIndex = new List <(float mag, int index)>(); // Get the central piece´s position Vector3 centerPiece = _playArena[0].transform.position; Vector3 firstPlayerSpawn = new Vector3(); Vector3 secondPlayerSpawn = new Vector3(); // All the piece3's distances from the center: for (int i = 1; i < _playArena.Count; i++) { (float distance, int dex)d; d.distance = (_playArena[i].transform.position - centerPiece).magnitude; d.dex = i; distAndIndex.Add(d); } // sort the list by magnitue distAndIndex.Sort((t1, t2) => t1.mag.CompareTo(t2.mag)); firstPlayerSpawn = _playArena[distAndIndex[0].index].transform.position; //Now get second player spawn, the furthest piece from the // first player's spawn // reset the list to use it for measuring with firstPlayerSpawn distAndIndex = new List <(float mag, int index)>(); for (int i = 1; i < _playArena.Count; i++) { (float distance, int dex)d; d.distance = (_playArena[i].transform.position - firstPlayerSpawn).magnitude; d.dex = i; distAndIndex.Add(d); } // sort the list by magnitue distAndIndex.Sort((t1, t2) => t2.mag.CompareTo(t1.mag)); secondPlayerSpawn = _playArena[distAndIndex[0].index].transform.position; // Now, depending on you want to spawn the players, spawn them at // the positions firstPlayerSpawn and secondPlayerSpawn have stored. player1.mB.SetSpawnPosition(firstPlayerSpawn); player2.mB.SetSpawnPosition(secondPlayerSpawn); player1.mB.SetSpawnRotation(player2.transform); player2.mB.SetSpawnRotation(player1.transform); player1.mB.ResetPosition(); player2.mB.ResetPosition(); #endregion InitArena(); zonesList.AddRange(_playArena[0].GetComponentsInChildren <ZoneBehaviour>()); foreach (ZoneBehaviour z in zonesList) { z.gameObject.SetActive(false); } if (gmManager.zoneBased) { int zone = Random.Range(0, zonesList.Count); zonesList[zone].gameObject.SetActive(true); activeZone = zone; zoneChangeTimer = gmManager.zoneChangeInterval; } Cursor.lockState = CursorLockMode.Locked; StartCoroutine(PreMatchCountdown()); }