private void Awake() { setup = FindObjectOfType <GameSetup>(); LevelLoader levelLoader = FindObjectOfType <LevelLoader>(); if (levelLoader != null) { levelLoader.InitializeLevel(); } }
private void Awake() { if (instance == null) { DontDestroyOnLoad(gameObject); instance = this; rankings = new Dictionary <int, MatchStats>(); } else { Destroy(gameObject); } }
public void SetMatchResults() { GameManager gm = FindObjectOfType <GameManager>(); if (gm != null) { GameSetup gs = FindObjectOfType <GameSetup>(); if (gs != null) { foreach (GameObject player in gm.players) { if (player.GetComponent <UserCharacterController>() != null) { int playerIndex = player.GetComponent <UserCharacterController>().playerId; if (gs.rankings.ContainsKey(playerIndex)) { TimerScript ts = FindObjectOfType <TimerScript>(); if (ts != null) { gs.rankings[playerIndex].deathTime = ts.GetElapsedTime(); } gs.rankings[playerIndex].coinReward = 0; gs.rankings[playerIndex].tie = true; } else { MatchStats ms = new MatchStats(); TimerScript ts = FindObjectOfType <TimerScript>(); if (ts != null) { gs.rankings[playerIndex].deathTime = ts.GetElapsedTime(); } ms.coinReward = 0; ms.coinTotal = 0; ms.tie = true; gs.rankings.Add(playerIndex, ms); } } } } } }
void Start() { if ((setup = FindObjectOfType <GameSetup>()) == null) { GameObject gameSetupObj = Instantiate(gameSetupPrefab); setup = gameSetupObj.GetComponent <GameSetup>(); setup.selectedCharacterPrefabs = new GameObject[ReInput.players.playerCount]; } else { int activePanels = 0; for (int i = 0; i < ReInput.players.playerCount; i++) { if (i < panels.Length && setup.selectedCharacterPrefabs[i] != null) { panels[i].SetActive(true); activePanels++; } } if (activePanels > 3) { placeHolder.SetActive(false); } for (int i = 0; i < panels.Length; i++) { if (panels[i] != null) { panels[i].transform.SetParent(null); panels[i].transform.SetParent(grid); } } if (placeHolder.activeSelf) { placeHolder.transform.SetParent(null); placeHolder.transform.SetParent(grid); } } }
public void Start() { setup = FindObjectOfType <GameSetup>(); if (setup != null) { List <MatchStats> l = new List <MatchStats>(); for (int i = 0; i < ReInput.players.playerCount; i++) { if (setup.selectedCharacterPrefabs[i] != null && setup.rankings.ContainsKey(i)) { GameObject matchResultObject = Instantiate(matchResultPanelPrefab, horizontalLayout); MatchResultsPanel matchResultPanel = matchResultObject.GetComponent <MatchResultsPanel>(); MatchStats m = setup.rankings[i]; matchResultPanel.rankText.text = GetRankString(m) + " - P" + i; matchResultPanel.rewardText.text = m.coinReward + " Points"; matchResultPanel.playerImage.sprite = setup.selectedCharacterPrefabs[i].GetComponentInChildren <SpriteRenderer>().sprite; } } } }
private void Awake() { setup = FindObjectOfType <GameSetup>(); }
void TestOneStack() { // Test 1 stack remaining bool onlyOneStack = true; List <GameObject> stack = new List <GameObject>(); foreach (GameObject player in players) { if (!player.GetComponent <Character>().stationary) { stack = player.GetComponent <Character>().m_CharacterStack; break; } } foreach (GameObject player in players) { if (!player.GetComponent <Character>().stationary) { foreach (GameObject player0 in players) { if (!player0.GetComponent <Character>().stationary) { if (!player.GetComponent <Character>().m_CharacterStack.Contains(player0)) { onlyOneStack = false; break; } } } } if (!onlyOneStack) { break; } } // if only 1 stack remains, all win. if (onlyOneStack) { GameSetup gs = FindObjectOfType <GameSetup>(); if (gs != null) { foreach (GameObject winner in stack) { // AI don't get points if (winner.GetComponent <UserCharacterController>() != null) { int playerIndex = winner.GetComponent <UserCharacterController>().playerId; if (gs.rankings.ContainsKey(playerIndex)) { gs.rankings[playerIndex].deathTime = -1; gs.rankings[playerIndex].coinReward = gs.matchPoints / stack.Count; gs.rankings[playerIndex].coinTotal += gs.rankings[playerIndex].coinReward; } else { MatchStats ms = new MatchStats(); ms.deathTime = -1; // winner didn't die ms.coinReward = gs.matchPoints / stack.Count; ms.coinTotal = ms.coinReward; gs.rankings.Add(playerIndex, ms); } } } } LevelLoader.initialized = false; LevelLoader levelLoader = FindObjectOfType <LevelLoader>(); if (levelLoader != null) { Destroy(levelLoader.gameObject); } SceneManager.LoadScene("MatchResults"); } }