// 单场战斗刷新 private void UpdateBattle(Room room, long delta, long time) { if (room == null || room.State != RoomState.Battle) { return; } //房间是否进入结算 if (RoomSettleService.SettleRoom(room, time)) { return; } var record = room.Record; record.BattleTime += delta; if (record.BattleTime < 0) { // 战斗缓冲中 return; } if (record.BattleTime == 0) { room.BattleFrame = 0; room.PendFrame = room.FramePackageLength - ConfigConstants.BATTLE_SERVER_LEAD_FRAME_COUNT; record.FrameCount = 0; // 广播通知玩家战斗开始 BroadcastRoomBattleFramePackage(room); Logger.LogDebug($"[Room-{room.RoomId}][Battle Begin][Broadcast To Users Battle[{record.BattleId}]]"); return; } // 帧数+1 room.BattleFrame++; room.PendFrame++; // 给玩家广播战斗包 if (room.PendFrame == room.FramePackageLength) { record.FrameCount = room.BattleFrame; room.LastPackageBattleFrame = room.BattleFrame; room.PendFrame = 0; BroadcastRoomBattleFramePackage(room); } }
private void Start() { // 启动计时器 timer.Start(); _roomTime = GetTime(); // 初始化房间 if (!InitRoom()) { return; } //开始结算服务 RoomSettleService.TryStart(); // 启动线程 this.StartThreadContext(); // 开始统计 StartStat(); }