IEnumerator RestartRound(playerPlataformerController winner) { yield return(new WaitForSeconds(1)); FadeOut(); yield return(new WaitForSeconds(1)); winningChance = true; timeLeft = totalTime; uiTexts[10].text = timeLeft.ToString("0"); leftPlayerScript.won = false; leftPlayerScript.lost = false; rightPlayerScript.won = false; rightPlayerScript.lost = false; rounds++; leftPlayerScript.health = leftPlayerScript.maxHealth; rightPlayerScript.health = rightPlayerScript.maxHealth; leftPlayerScript.MoveTo(spawnPoints[0].transform.position); rightPlayerScript.MoveTo(spawnPoints[1].transform.position); rightPlayerScript.isLeft = false; leftPlayerScript.isLeft = true; rightPlayerScript.flipCharacterLeft(); leftPlayerScript.flipCharacterRight(); // Faz a camera ficar entre os dois personages sceneCamera.transform.position = new Vector3((leftPlayer.transform.position.x + rightPlayer.transform.position.x) / 2, sceneCamera.transform.position.y, sceneCamera.transform.position.z); // Pega a difereça dos dois players float diffPos = Math.Abs(leftPlayerScript.posX - rightPlayerScript.posX); // Se a difereça for maior que 30 a camera muda de tamanho if (diffPos >= 30) { sceneCamera.GetComponent <Camera>().orthographicSize = diffPos / 3f; } else { sceneCamera.GetComponent <Camera>().orthographicSize = 10; } yield return(new WaitForSeconds(1)); RoundUp(winner); if (leftPlayerScript.roundsWon == 1) { uiTexts[6].gameObject.SetActive(true); } if (rightPlayerScript.roundsWon == 1) { uiTexts[8].gameObject.SetActive(true); } FadeIn(); yield return(new WaitForSeconds(1)); uiTexts[4].enabled = true; uiTexts[4].text = "Round " + rounds; if (rounds == 1) { PlaySound(mode16bit ? narratorLines16bit[1] : narratorLines[1]); } else if (rounds == 2) { PlaySound(mode16bit ? narratorLines16bit[2] : narratorLines[2]); } else if (rounds == 3) { PlaySound(mode16bit ? narratorLines16bit[3] : narratorLines[3]); } yield return(new WaitForSeconds(1)); uiTexts[4].enabled = false; yield return(new WaitForSeconds(0.5f)); coroutineRound = true; roundCount = true; uiTexts[4].enabled = true; gameRunning = true; PlaySound(mode16bit ? narratorLines16bit[0] : narratorLines[0]); uiTexts[4].text = "FIGHT!"; yield return(new WaitForSeconds(0.5f)); uiTexts[4].enabled = false; }
void Start() { // Coloca o mapa var arenaAtual = Instantiate(arenas[Random.Range(0, arenas.Length)]); arenaAtual.GetComponent <ArenaScript>().SpawnInteractable(spawnPoints[2].transform.position); arenaAtual.GetComponent <ArenaScript>().SpawnInteractable(spawnPoints[3].transform.position); timeLeft = totalTime; uiTexts[10].text = timeLeft.ToString(); audioSource = GetComponent <AudioSource>(); // Arrumas os player leftPlayerChosen = Mensageiro.leftPlayerIndex; rightPlayerChosen = Mensageiro.rightPlayerIndex; var leftPlayerPreFab = Instantiate(players[leftPlayerChosen]); leftPlayer = leftPlayerPreFab.transform.GetChild(0).gameObject; leftPlayerScript = leftPlayerPreFab.transform.GetChild(0).GetComponent <playerPlataformerController>(); leftPlayerScript.isPlayer1 = true; leftPlayerScript.gameController = this; var rightPlayerPreFab = Instantiate(players[rightPlayerChosen]); rightPlayer = rightPlayerPreFab.transform.GetChild(0).gameObject; rightPlayerScript = rightPlayerPreFab.transform.GetChild(0).GetComponent <playerPlataformerController>(); rightPlayerScript.isPlayer1 = false; rightPlayerScript.gameController = this; // Acha a camera sceneCamera = GameObject.FindWithTag("MainCamera"); // Pega os scripts dos players leftPlayerScript = leftPlayer.transform.root.GetChild(0).GetComponent <playerPlataformerController>(); rightPlayerScript = rightPlayer.transform.root.GetChild(0).GetComponent <playerPlataformerController>(); leftPlayerScript.MoveTo(spawnPoints[0].transform.position); rightPlayerScript.MoveTo(spawnPoints[1].transform.position); // Vira os personagens rightPlayerScript.isLeft = false; leftPlayerScript.isLeft = true; rightPlayerScript.flipCharacterLeft(); leftPlayerScript.flipCharacterRight(); // Coloca os nomes uiTexts[0].text = leftPlayerScript.characterName; uiTexts[1].text = rightPlayerScript.characterName; // Desativa pause e vitória uiTexts[4].enabled = false; uiTexts[5].enabled = false; uiTexts[6].gameObject.SetActive(false); uiTexts[7].gameObject.SetActive(false); uiTexts[8].gameObject.SetActive(false); uiTexts[9].gameObject.SetActive(false); uiTexts[2].gameObject.SetActive(false); uiTexts[3].gameObject.SetActive(false); // Colocam a cor uiImages[0].color = leftPlayerScript.mainColor; uiTexts[0].color = leftPlayerScript.mainColor; uiTexts[2].color = leftPlayerScript.mainColor; uiImages[6].color = leftPlayerScript.mainColor; uiTexts[1].color = rightPlayerScript.mainColor; uiTexts[3].color = rightPlayerScript.mainColor; uiImages[3].color = rightPlayerScript.mainColor; uiImages[10].color = rightPlayerScript.mainColor; transform.GetChild(2).GetComponent <SpriteRenderer>().color = Color.black; // Coloca o sangue nos prefabs AttachParticles(); StartCoroutine(StartCondition()); /*// Start settings * camera.GetComponent<Camera>().orthographicSize = 15; * foreach (var text in uiTexts){ * text.GetComponent<CanvasRenderer>().SetAlpha(0); * } * foreach (var images in uiImages){ * images.GetComponent<CanvasRenderer>().SetAlpha(0); * } * uiImages[2].rectTransform.localScale = new Vector3(0, uiImages[2].rectTransform.localScale.y, uiImages[2].rectTransform.localScale.z); * uiImages[1].rectTransform.localScale = new Vector3(0, uiImages[1].rectTransform.localScale.y, uiImages[1].rectTransform.localScale.z); * * uiImages[5].rectTransform.localScale = new Vector3(0, uiImages[5].rectTransform.localScale.y, uiImages[5].rectTransform.localScale.z); * uiImages[4].rectTransform.localScale = new Vector3(0, uiImages[4].rectTransform.localScale.y, uiImages[4].rectTransform.localScale.z);*/ }