protected virtual void ServerUpdate() { if (gameRule != null && canUpdateGameRule) { gameRule.OnUpdate(); } if (Time.unscaledTime - updateScoreTime >= 1f) { if (gameRule == null || !gameRule.IsMatchEnded) { var msgSendScores = new OpMsgSendScores(); msgSendScores.scores = GetSortedScores(); NetworkServer.SendToAll(msgSendScores.OpId, msgSendScores); } updateScoreTime = Time.unscaledTime; } if (gameRule != null && Time.unscaledTime - updateMatchTime >= 1f) { RemainsMatchTime = gameRule.RemainsMatchTime; var msgMatchStatus = new OpMsgMatchStatus(); msgMatchStatus.remainsMatchTime = gameRule.RemainsMatchTime; msgMatchStatus.isMatchEnded = gameRule.IsMatchEnded; NetworkServer.SendToAll(msgMatchStatus.OpId, msgMatchStatus); if (!IsMatchEnded && gameRule.IsMatchEnded) { IsMatchEnded = true; MatchEndedAt = Time.unscaledTime; } updateMatchTime = Time.unscaledTime; } }
protected virtual void ServerUpdate() { if (gameRule != null && canUpdateGameRule) { gameRule.OnUpdate(); if (!IsMatchEnded && gameRule.IsMatchEnded) { UpdateMatchScores(); UpdateMatchStatus(); RestartWhenMatchEnd(); IsMatchEnded = true; MatchEndedAt = Time.unscaledTime; } if (!IsMatchEnded && Time.unscaledTime - updateMatchTime >= 1f) { RemainsMatchTime = gameRule.RemainsMatchTime; UpdateMatchStatus(); updateMatchTime = Time.unscaledTime; } } if (!IsMatchEnded && Time.unscaledTime - updateScoreTime >= 1f) { if (gameRule == null || !gameRule.IsMatchEnded) { UpdateMatchScores(); } updateScoreTime = Time.unscaledTime; } }
protected virtual void ServerUpdate() { if (GetRoomState() == RoomState.Waiting) { return; } if (!MasterStarted) { return; } if (gameRule != null) { gameRule.OnUpdate(); if (!IsMatchEnded && gameRule.IsMatchEnded) { UpdateMatchScores(); if (isConnectOffline) { RpcMatchStatus(gameRule.RemainsMatchTime, gameRule.IsMatchEnded); } else { photonView.OthersRPC(RpcMatchStatus, gameRule.RemainsMatchTime, gameRule.IsMatchEnded); } IsMatchEnded = true; MatchEndedAt = Time.unscaledTime; } if (!IsMatchEnded && Time.unscaledTime - updateMatchTime >= 1f) { RemainsMatchTime = gameRule.RemainsMatchTime; if (isConnectOffline) { RpcMatchStatus(gameRule.RemainsMatchTime, gameRule.IsMatchEnded); } else { photonView.OthersRPC(RpcMatchStatus, gameRule.RemainsMatchTime, gameRule.IsMatchEnded); } updateMatchTime = Time.unscaledTime; } } if (!IsMatchEnded && Time.unscaledTime - updateScoreTime >= 1f) { if (gameRule == null || !gameRule.IsMatchEnded) { UpdateMatchScores(); } updateScoreTime = Time.unscaledTime; } }
protected virtual void ServerUpdate() { if (GetRoomState() == RoomState.Waiting) { return; } if (gameRule != null && startUpdateGameRule) { gameRule.OnUpdate(); } if (Time.unscaledTime - updateScoreTime >= 1f) { if (gameRule != null && !gameRule.IsMatchEnded) { int length = 0; List <object> objects; GetSortedScoresAsObjects(out length, out objects); if (isConnectOffline) { RpcUpdateScores(length, objects.ToArray()); } else { photonView.RPC("RpcUpdateScores", PhotonTargets.All, length, objects.ToArray()); } } updateScoreTime = Time.unscaledTime; } if (gameRule != null && Time.unscaledTime - updateMatchTime >= 1f) { RemainsMatchTime = gameRule.RemainsMatchTime; if (isConnectOffline) { RpcMatchStatus(gameRule.RemainsMatchTime, gameRule.IsMatchEnded); } else { photonView.RPC("RpcMatchStatus", PhotonTargets.All, gameRule.RemainsMatchTime, gameRule.IsMatchEnded); } if (!IsMatchEnded && gameRule.IsMatchEnded) { IsMatchEnded = true; MatchEndedAt = Time.unscaledTime; } updateMatchTime = Time.unscaledTime; } }