public static async void LoadingFinish(RoomTeamComponent roomTeamComponent) { if (roomTeamComponent.DataIsLoaded) { return; } roomTeamComponent.DataIsLoaded = true; //等3秒給Client Lerp await Game.Scene.GetComponent <TimerComponent>().WaitForSecondAsync(3.0f); //設定比賽開始結束時間 var roadSetting = Game.Scene.GetComponent <ConfigComponent>().Get (typeof(RoadSetting), roomTeamComponent.RoomEntity.info.RoadSettingId) as RoadSetting; if (roadSetting != null) { var timerComponent = Game.Scene.GetComponent <TimerComponent>(); roomTeamComponent.RoomRunStartTimeMs = TimeHelper.ClientNowMilliSeconds(); roomTeamComponent.RoadDistance_km = RoadHelper.GetDistance_km(roadSetting); roomTeamComponent.RoadDistance_m = RoadHelper.GetDistance_m(roadSetting); } else { Log.Error($"找不到該路徑資料, RoadSettingId:{roomTeamComponent.RoomEntity.info.RoadSettingId}"); } //設定所有Player StartRoom List <MapUnit> mapUnits = roomTeamComponent.RoomEntity.GetAll(); var proxy = Game.Scene.GetComponent <CacheProxyComponent>(); var playerSync = proxy.GetMemorySyncSolver <Player>(); for (int i = 0; i < mapUnits.Count; i++) { Player target = playerSync.Get <Player>(mapUnits[i].Uid); if (target != null) { target.StartRoom(); await playerSync.Update(target); } } //廣播給所有玩家 所有人載入完成 M2C_TeamGoBattleProgressAllDone m2c_TeamGoBattleProgressAllDone = new M2C_TeamGoBattleProgressAllDone() { StartUTCTick = DateTime.UtcNow.Ticks }; MapMessageHelper.BroadcastRoom(roomTeamComponent.RoomEntity.Id, m2c_TeamGoBattleProgressAllDone); }
public override void Awake(RoomBlockComponent self, Room room) { double roadDistance_m = 0; var roadSetting = Game.Scene.GetComponent <ConfigComponent>().Get(typeof(RoadSetting), room.info.RoadSettingId) as RoadSetting; if (roadSetting != null) { var timerComponent = Game.Scene.GetComponent <TimerComponent>(); roadDistance_m = RoadHelper.GetDistance_m(roadSetting); } else { Log.Error($"RoomBlockComponent Awake Failed, roadSetting = null, Room{room.Id}"); } self.InitAllBlock(roadDistance_m); }