private void SaveMessage(Message message) { if (message == null || message.message == null) { return; } var bitBuffer = new BitBuffer(message.message); if (message.messageType == MessageType.JoinACK) { var playerId = bitBuffer.GetInt(0, 10); _engine.playerId = playerId; ClientPlayer.playerId = playerId; return; } var score = bitBuffer.GetInt(0, 10000); var level = bitBuffer.GetInt(0, 10); if (level > this.level) { ClientLevelManager.LevelUp(level); this.level = level; } var playerCount = bitBuffer.GetInt(0, 10); var playerStates = new List <PlayerState>(); var enemyStates = new List <EnemyState>(); for (var i = 0; i < playerCount; i++) { playerStates.Add(new PlayerState(bitBuffer)); } var enemyCount = bitBuffer.GetInt(0, 1000); for (var i = 0; i < enemyCount; i++) { enemyStates.Add(new EnemyState(bitBuffer)); } _snapshot = new Snapshot(playerStates, enemyStates, message.sequence); _snapshot.score = score; _interpolation.AddSnapshot(_snapshot); _prediction.checkState(_snapshot); }