public void Scored(bool team1) { if (!scored) { Debug.Log("Scored"); goalText.Reset(); scored = true; if (team1) { score1++; score1Text.text = score1.ToString(); } else { score2++; score2Text.text = score2.ToString(); } int side = team1 ? 1 : 2; Goal(side); countTime = false; if (overTime) { Invoke("EndGame", goalDelay); } else { StartCoroutine("SetPuck", goalDelay); } } }
private void EndGame() { if (score1 == score2) { OverTime(); } else { endText.Reset(); foreach (TeamController team in teamControllers) { team.SetPositions(); } //Invoke("SwapSides", 2f); if (currentPeriod % 2 == 0) { Debug.Log("SWPA"); SwapSides(); } foreach (TeamController team in teamControllers) { team.SetPositions(); } FindObjectOfType <TitleController>().TitleScreen(); } }
private void OverTime() { overTime = true; overTimeText.Reset(); periodText.text = "OT"; StartCoroutine("SetPuck", 2f); }
private void Begin() { Debug.Log("Begin"); foreach (TeamController team in teamControllers) { team.ActivatePlayers(); } goText.Reset(); countTime = true; }
private IEnumerator SetPuck(float delay) { yield return(new WaitForSeconds(delay)); Debug.Log("SetPuck"); scored = false; puck.transform.position = Vector3.zero; puck.GetComponent <Rigidbody2D>().velocity = Vector2.zero; foreach (TeamController team in teamControllers) { team.SetPositions(); } readyText.Reset(); Invoke("Begin", startDelay); }
private void EndPeriod() { timeText.Reset(); countTime = false; scored = true; SetPeriodTime(periodTime); currentPeriod++; if (currentPeriod > PeriodAmount) { Invoke("EndGame", 2.1f); } else { Invoke("IncrementPeriod", 2f); StartCoroutine("SetPuck", 2f); } Invoke("SwapSides", 2f); }
public void Out() { outText.Reset(); countTime = false; StartCoroutine("SetPuck", goalDelay); }