public void scene2End(int layer) { scores[layer - 9]++; gameCanvas.transform.GetChild(layer - 9).GetChild(0).GetChild(3).gameObject.GetComponent <UnityEngine.UI.Text>().text = scores[layer - 9].ToString(); if (scores[layer - 9] >= maxPoints) { AkSoundEngine.StopAll(gameObject); AkSoundEngine.PostEvent("Gate_Opera", gameObject); AkSoundEngine.SetSwitch("Music", "Start", gameObject); gameCanvas.SetActive(false); teamCanvas.SetActive(false); victoryCanvas.SetActive(true); victoryCanvas.transform.GetChild(layer - 7).gameObject.SetActive(true); for (int i = 1; i < 5; i++) { if (i == layer - 8) { NetworkServerManager.getInstance().ServerStringMessageSender(i, "Won"); } else { NetworkServerManager.getInstance().ServerStringMessageSender(i, "Lost"); } } } else { LoadMatchmakingScene(); } }
public void LoadMatchmakingScene() { AkSoundEngine.SetState("GameState", "None"); gameCanvas.SetActive(false); teamCanvas.SetActive(true); for (int i = 0; i < maxPlayers; i++) { PlayersGameObjects[i].SetActive(false); NetworkServerManager.getInstance().SwitchInputManager(i, true); } teams[0] = Random.Range(1, 3); teams[1] = Random.Range(1, 3); if (teams[0] == teams[1]) { if (teams[0] == 1) { teams[2] = 2; teams[3] = 2; } else { teams[2] = 1; teams[3] = 1; } } else { teams[2] = Random.Range(1, 3); if (teams[2] == 1) { teams[3] = 2; } else { teams[3] = 1; } } //teams = new int[] { 1, 2, 1, 2 }; keyCollected = new int[] { 0, 0, 0, 0 }; SceneManager.LoadScene("Matchmaking Scene"); //DebugText.instance.Log("Loaded Matchmaking Scene"); int team1Comp = 0, team2Comp = 0; for (int i = 0; i < maxPlayers; i++) { if (teams[i] == 1) { teamCanvas.transform.GetChild(1).GetChild(i).gameObject.GetComponent <RectTransform>().localPosition = teamsFacesPos[team1Comp]; team1Comp++; } else { teamCanvas.transform.GetChild(1).GetChild(i).gameObject.GetComponent <RectTransform>().localPosition = teamsFacesPos[team2Comp + 2]; team2Comp++; } } timer = MatchMakingSceneDuration; isMatchmakingScene = true; }
private void LoadFirstGameScene() { teamCanvas.SetActive(false); gameCanvas.SetActive(true); CounterText.text = ""; timer = FirstSceneDuration; isFirstScene = true; isMatchmakingScene = false; NetworkServerManager.getInstance().ServerStringMessageSenderToAll("Scene1"); //DebugText.instance.Log("Loaded First Scene"); SceneManager.LoadScene("Game Scene 1"); Loading(3f); for (int i = 0; i < maxPlayers; i++) { if (teams[i] == 1) { gameCanvas.transform.GetChild(i).GetChild(0).GetChild(2).gameObject.SetActive(true); gameCanvas.transform.GetChild(i).GetChild(0).GetChild(1).gameObject.SetActive(false); PlayersGameObjects[i].transform.GetChild(0).GetChild(2).GetChild(0).gameObject.SetActive(true); PlayersGameObjects[i].transform.GetChild(0).GetChild(2).GetChild(1).gameObject.SetActive(false); } else { gameCanvas.transform.GetChild(i).GetChild(0).GetChild(2).gameObject.SetActive(false); gameCanvas.transform.GetChild(i).GetChild(0).GetChild(1).gameObject.SetActive(true); PlayersGameObjects[i].transform.GetChild(0).GetChild(2).GetChild(0).gameObject.SetActive(false); PlayersGameObjects[i].transform.GetChild(0).GetChild(2).GetChild(1).gameObject.SetActive(true); } PlayersGameObjects[i].SetActive(true); PlayersGameObjects[i].GetComponent <PlayerInputManager>().Detach(); Vector3 move = spawnPointsFirstScene[i] - PlayersGameObjects[i].transform.GetChild(2).GetChild(0).position; PlayersGameObjects[i].transform.GetChild(2).GetChild(0).GetComponent <PlayerBalanceManager>().SetRandomMoving(true); PlayersGameObjects[i].transform.GetChild(2).GetChild(0).GetComponent <PlayerBalanceManager>().RecoverFromFall(); if (PlayersGameObjects[i].GetComponent <PlayerInputManager>()) { PlayersGameObjects[i].GetComponent <PlayerInputManager>().Detach(); } PlayersGameObjects[i].transform.position += move; PlayersGameObjects[i].transform.rotation = Quaternion.identity; gameCanvas.transform.GetChild(i).GetChild(1).gameObject.SetActive(true); gameCanvas.transform.GetChild(i).GetChild(2).gameObject.SetActive(false); } }
private void scene1End(int win) { int winner = 0, loser = 0; for (int i = 0; i < maxPlayers; i++) { PlayersGameObjects[i].transform.GetChild(2).GetChild(0).GetComponent <PlayerBalanceManager>().SetRandomMoving(false); if (teams[i] != win) { NetworkServerManager.getInstance().ServerStringMessageSender(i, "Scene2"); gameCanvas.transform.GetChild(i).GetChild(1).gameObject.SetActive(false); gameCanvas.transform.GetChild(i).GetChild(2).gameObject.SetActive(true); NetworkServerManager.getInstance().SwitchInputManager(i, false); PlayersGameObjects[i].GetComponent <PlayerInputManager>().Detach(); Vector3 move = spawnPointsSecondScene[loser + 2] - PlayersGameObjects[i].transform.GetChild(2).GetChild(0).position; PlayersGameObjects[i].transform.GetChild(2).GetChild(0).GetComponent <PlayerBalanceManager>().ResetForScene2(); if (PlayersGameObjects[i].GetComponent <PlayerInputManager>()) { PlayersGameObjects[i].GetComponent <PlayerInputManager>().Detach(); } PlayersGameObjects[i].transform.position += move; PlayersGameObjects[i].transform.rotation = Quaternion.identity; loser++; } else { if (scores[i] < maxPoints - 1) { scores[i]++; gameCanvas.transform.GetChild(i).GetChild(0).GetChild(3).gameObject.GetComponent <UnityEngine.UI.Text>().text = scores[i].ToString(); } PlayersGameObjects[i].GetComponent <PlayerInputManager>().Detach(); Vector3 move = spawnPointsSecondScene[winner] - PlayersGameObjects[i].transform.GetChild(2).GetChild(0).position; PlayersGameObjects[i].transform.GetChild(2).GetChild(0).GetComponent <PlayerBalanceManager>().RecoverFromFall(); if (PlayersGameObjects[i].GetComponent <PlayerInputManager>()) { PlayersGameObjects[i].GetComponent <PlayerInputManager>().Detach(); } PlayersGameObjects[i].transform.position += move; PlayersGameObjects[i].transform.rotation = Quaternion.identity; winner++; } } }
public void RecoverFromFall() { //SOUND GOT UP //AkSoundEngine.PostEvent("GotUp", gameObject); InputController.SetCanAttach(true); InputController.BlockControls(false); ResetBar(); BlockBar(true, 5f); BalanceGUI.SetActive(true); IconImage.SetActive(true); Hips.GetComponent <SpringJoint>().spring = 1000f; Hips.GetComponent <Rigidbody>().AddForce(Vector3.up * 250f); NetworkServerManager.getInstance().ServerStringMessageSender(InputController, "GotUp"); }
public void Fall() { if (!Fallen) { Fallen = true; BlockBar(true); InputController.RandomizeControls(); InputController.Detach(); InputController.BlockControls(true); InputController.SetCanAttach(false); BalanceGUI.SetActive(false); IconImage.SetActive(false); Hips.GetComponent <SpringJoint>().spring = 0f; Hips.GetComponent <Rigidbody>().velocity = Vector3.zero; NetworkServerManager.getInstance().ServerStringMessageSender(InputController, "Fallen"); ShootKeys(MatchManager.getInstance().keyCollected[gameObject.layer - 9]); MatchManager.getInstance().keyCollected[gameObject.layer - 9] = 0; } }
// Update is called once per frame void Update() { //DebugText.instance.Set("1"); if (isFirstScene) { //DebugText.instance.Set("2"); timer -= Time.deltaTime; int ftScore = 0, stScore = 0; for (int i = 0; i < maxPlayers; i++) { if (teams[i] == 1) { ftScore += keyCollected[i]; } else { stScore += keyCollected[i]; } } ScoreText.text = "<color=red>" + ftScore + "</color><color=white> - </color><color=#0099ff>" + stScore + "</color>"; //DebugText.instance.Set("3"); if (timer < FirstSceneDuration - 3f) { CounterText.text = "Get Ready!"; CountdownText.text = (int)(timer - 60) + ""; //DebugText.instance.Set("4"); } if (timer < FirstSceneDuration - 5.9f && timer > 0f) { Spawer.getInstance().StartSpawning(); CountdownText.text = ""; CounterText.text = Mathf.Floor(timer).ToString("00"); //CounterText.text = Mathf.Floor(timer / 60).ToString("00") + ":" + (timer % 60).ToString("00"); //DebugText.instance.Set("5"); } if (timer <= 0) { LoadSecondScene(); } } else if (isMatchmakingScene) { timer -= Time.deltaTime; if (timer <= 0) { LoadFirstGameScene(); } } if (Input.GetKeyDown(KeyCode.Alpha1) && !isFirstScene && !isMatchmakingScene) { NetworkServerManager.getInstance().StartGame(); } if (Input.GetKeyDown(KeyCode.Alpha2) && isFirstScene && !isMatchmakingScene) { LoadSecondScene(); } }