ready for matchmaking
This commit is contained in:
@@ -16,6 +16,16 @@ public class GameManager : NetworkBehaviour
|
||||
}
|
||||
[SyncVar]
|
||||
public bool m_isMoving =false;
|
||||
[SyncVar(hook = nameof(OnGameStartedChanged))]
|
||||
public bool gameStarted = false;
|
||||
void OnGameStartedChanged(bool oldStarted, bool newStarted){
|
||||
if(newStarted){
|
||||
GameCanvas.instance.HideWaitingForOpponentPanel();
|
||||
}else{
|
||||
GameCanvas.instance.ShowWaitingForOpponentPanel();
|
||||
}
|
||||
}
|
||||
|
||||
[SyncVar(hook = nameof(OnSelectedTeamChanged))]
|
||||
public Team SelectedTeam = Team.Red;
|
||||
void OnSelectedTeamChanged(Team oldTeam, Team newTeam){
|
||||
@@ -55,6 +65,9 @@ public class GameManager : NetworkBehaviour
|
||||
[SyncVar]
|
||||
public int hitCounter = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
public static GameManager instance;
|
||||
|
||||
public float puckMass{
|
||||
@@ -234,12 +247,23 @@ public class GameManager : NetworkBehaviour
|
||||
m_isMoving=IsMoving();
|
||||
|
||||
HandleTurnTimer();
|
||||
|
||||
if(!gameStarted){
|
||||
|
||||
NetPlayer[] players = FindObjectsOfType<NetPlayer>();
|
||||
if (players.Length == 2)
|
||||
{
|
||||
gameStarted = true;
|
||||
GameCanvas.instance.HideWaitingForOpponentPanel();
|
||||
Debug.Log("Game started On Server");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HandleTurnTimer(){
|
||||
if(turnTimerCounter < turnTimer){
|
||||
if(!isMoving && !switchingTeams){
|
||||
if(!isMoving && !switchingTeams && gameStarted){
|
||||
turnTimerCounter += Time.deltaTime;
|
||||
}
|
||||
}else{
|
||||
@@ -275,14 +299,11 @@ public class GameManager : NetworkBehaviour
|
||||
|
||||
|
||||
if(blueScore >= 3){
|
||||
gameOverPanel.SetActive(true);
|
||||
|
||||
blueWon.SetActive(true);
|
||||
redWon.SetActive(false);
|
||||
RpcGameOver(Team.Blue);
|
||||
gameOver(Team.Blue);
|
||||
}else if(redScore >= 3){
|
||||
gameOverPanel.SetActive(true);
|
||||
blueWon.SetActive(false);
|
||||
redWon.SetActive(true);
|
||||
RpcGameOver(Team.Red);
|
||||
gameOver(Team.Red);
|
||||
}else{
|
||||
StartCoroutine(CoroutineOnGoal(team));
|
||||
}
|
||||
@@ -290,6 +311,22 @@ public class GameManager : NetworkBehaviour
|
||||
hitCounter = 0;
|
||||
}
|
||||
|
||||
[ClientRpc]
|
||||
void RpcGameOver(Team team){
|
||||
gameOver(team);
|
||||
}
|
||||
|
||||
void gameOver(Team team){
|
||||
gameOverPanel.SetActive(true);
|
||||
if(team == Team.Blue){
|
||||
blueWon.SetActive(true);
|
||||
redWon.SetActive(false);
|
||||
}else{
|
||||
blueWon.SetActive(false);
|
||||
redWon.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
bool freezeInput = false;
|
||||
|
||||
IEnumerator CoroutineOnGoal(Team team, bool kickoff = false){
|
||||
|
||||
Reference in New Issue
Block a user