MessageHandleResult LoginHandler( NetConnection connection, ByteBuffer byteBuffer, NetIncomingMessage message) { Msg_SC_Login msg = InstancePool.Get <Msg_SC_Login>(); Msg_SC_Login.GetRootAsMsg_SC_Login(byteBuffer, msg); if (!msg.Success) { GameStateLog.Error("Login failed:" + msg.Error); TransitTo <Error>(msg.Error); } else { game.id = msg.Id; GameStateLog.Info("Login success, game id:" + msg.Id); Msg_SC_UpdatePlayers updateplayers = InstancePool.Get <Msg_SC_UpdatePlayers>(); msg.GetPlayers(updateplayers); PlayerManagerClient.Instance.UpdatePlayers(updateplayers); GameStateLog.Info("Update players"); TransitTo <DataFullUpdate>(); } return(MessageHandleResult.Finished); }
void MonitorNetwork(UdpConnector netlayer, NetConnectionStatus status, string reason) { if (ConnectionLost(status)) { GameStateLog.ErrorFormat("net status:{0}, reason:{1}", status, reason); TransitTo <Error>(reason); } }
void FullUpdateRequest() { using (var builder = MessageBuilder.Get()) { FlatBufferBuilder fbb = builder.fbb; Msg_CS_FullUpdate.StartMsg_CS_FullUpdate(fbb); fbb.Finish(Msg_CS_FullUpdate.EndMsg_CS_FullUpdate(fbb).Value); var msg = game.netlayer.CreateMessage(MessageID.Msg_CS_FullUpdate, fbb); game.netlayer.SendMessage(msg, NetDeliveryMethod.ReliableOrdered); } GameStateLog.Info("full update request"); }
public void Parse(Line line) { if (line.Text.StartsWith("GameState.")) { HandleGameState(line); GameStateLog?.Invoke(new LogEventArgs(line)); } else { HandlePowerTaskList(line); PowerTaskListLog?.Invoke(new LogEventArgs(line)); } }
MessageHandleResult SnapshotHandler( NetConnection connection, ByteBuffer byteBuffer, NetIncomingMessage message) { Msg_SC_Snapshot snapshot = InstancePool.Get <Msg_SC_Snapshot>(); Msg_SC_Snapshot.GetRootAsMsg_SC_Snapshot(byteBuffer, snapshot); SyncManagerClient.Instance.FullUpdate(snapshot); GameStateLog.Info("apply full update"); TransitTo <InGame>(); return(MessageHandleResult.Finished); }
public static void Update(ref GameState gameState) { if (null != gameState.next) { GameState next = gameState.next; gameState.Destroy(); next.Start(); GameStateLog.InfoFormat( "game state transition: {0} -> {1}", gameState.GetType().Name, next.GetType().Name); gameState = next; } gameState.Update(); }
protected override void Update() { if (game.netlayer.connectionStatus != NetConnectionStatus.Connected && (mTimer -= Time.deltaTime) <= 0f) { mTimer = 5f; if (mAttempts++ >= 3) { TransitTo <Error>("reconnect timeout"); return; } ConnectAttempt(); GameStateLog.Info("reconnect attempt #" + mAttempts); } }
private void Awake() { cc = GameObject.Find("CameraController").GetComponent <CameraController>(); gameStateLog = new GameStateLog(SceneManager.GetActiveScene().name); tutorialStateMachine = FindObjectOfType <TutorialStateMachine>(); hudController = FindObjectOfType <HUDController>(); if (startInStatic.HasValue) { startIn = startInStatic.Value; } loadingScreen.SetActive(false); }
void OnNetStatusChanged(UdpConnector netlayer, NetConnectionStatus status, string reason) { if (!ConnectionLost(status)) { GameStateLog.Info("connect net status:" + status); if (status == NetConnectionStatus.Connected) { TransitTo <Login>(); } } else { GameStateLog.ErrorFormat("connect net status:{0}, reason:{1}", status, reason); TransitTo <Error>(reason); } }
public override void Start() { InputManager.Instance.Initialize(); GameStateLog.Info("Init Input"); SyncManagerClient.Instance.Initialize(); GameStateLog.Info("Init SyncManagerClient"); PlayerManagerClient.Instance.Initialize(); GameStateLog.Info("Init PlayerManagerClient"); SimpleUI.Login login = UI.Instance.Show <SimpleUI.Login>(); login.onJoinGame = (host, port, name) => { game.serverHost = host; game.serverPort = port; game.playerName = name; TransitTo <Connect>(); }; }
public static GameStateLog LoadFile(string filePath) { FileStream file; if (File.Exists(filePath)) { file = File.OpenRead(filePath); } else { Debug.LogError("File not found"); return(null); } BinaryFormatter bf = new BinaryFormatter(); GameStateLog instance = (GameStateLog)bf.Deserialize(file); file.Close(); return(instance); }
void OnNetStatusChanged(UdpConnector netlayer, NetConnectionStatus status, string reason) { GameStateLog.Info("reconnect net status:" + status); }