/// <summary> /// 查询城镇开启情况列表 /// </summary> public void GetCitySceneMenuData(string cityId) { List <string> openedCityIds = new List <string>(); db = OpenDb(); SqliteDataReader sqReader = db.ExecuteQuery("select CityId from EnterCityTable where BelongToRoleId = '" + currentRoleId + "'"); while (sqReader.Read()) { openedCityIds.Add(sqReader.GetString(sqReader.GetOrdinal("CityId"))); } db.CloseSqlConnection(); SceneData scene = JsonManager.GetInstance().GetMapping <SceneData>("Scenes", cityId); scene.MakeJsonToModel(); CityScenePanelCtrl.Show(scene, openedCityIds); }
/// <summary> /// Tasks the notify init. /// </summary> public static void TaskNotifyInit() { Messenger.AddListener <string>(NotifyTypes.GetTaskListDataInCityScene, (cityId) => { if (CityScenePanelCtrl.Ctrl != null) { DbManager.Instance.GetTaskListDataInCityScene(cityId); } }); Messenger.AddListener <List <TaskData> >(NotifyTypes.GetTaskListDataInCitySceneEcho, (list) => { CityScenePanelCtrl.ShowTask(list); }); Messenger.AddListener(NotifyTypes.GetTaskListData, () => { DbManager.Instance.GetTaskListData(); }); Messenger.AddListener <List <TaskData> >(NotifyTypes.GetTaskListDataEcho, (list) => { TaskListPanelCtrl.Show(list); }); Messenger.AddListener(NotifyTypes.HideTaskListPanel, () => { TaskListPanelCtrl.Hide(); }); Messenger.AddListener(NotifyTypes.ShowTaskBtnPanel, () => { TaskBtnPanelCtrl.Show(); }); Messenger.AddListener(NotifyTypes.HideTaskBtnPanel, () => { TaskBtnPanelCtrl.MakeMoveOut(); }); Messenger.AddListener(NotifyTypes.MakeTaskListHide, () => { TaskBtnPanelCtrl.MakeTaskListHide(); }); Messenger.AddListener <string>(NotifyTypes.GetTaslDetailInfoData, (taskId) => { DbManager.Instance.GetTaskDetailInfoData(taskId); }); Messenger.AddListener(NotifyTypes.ReloadTaslDetailInfoData, () => { TaskDetailInfoPanelCtrl.Reload(); }); Messenger.AddListener <string>(NotifyTypes.MakeFightWinedBtnDisable, (fightId) => { TaskDetailInfoPanelCtrl.MakeFightWinedBtnDisable(fightId); }); Messenger.AddListener <JArray>(NotifyTypes.ShowTaskDetailInfoPanel, (data) => { TaskDetailInfoPanelCtrl.Show(data); Messenger.Broadcast(NotifyTypes.MakeTaskListHide); //任务详情界面打开时需要关闭角色信息面板和任务列表入口按钮 Messenger.Broadcast(NotifyTypes.HideRoleInfoPanel); }); Messenger.AddListener(NotifyTypes.HideTaskDetailInfoPanel, () => { TaskDetailInfoPanelCtrl.Hide(); //关闭任务对话详情界面时重新请求动态事件列表 Messenger.Broadcast <string>(NotifyTypes.GetActiveEventsInArea, UserModel.CurrentUserData.CurrentAreaSceneName); }); Messenger.AddListener <string, bool, bool>(NotifyTypes.CheckTaskDialog, (taskId, auto, selectedNo) => { DbManager.Instance.CheckTaskDialog(taskId, auto, selectedNo); }); Messenger.AddListener <JArray>(NotifyTypes.CheckTaskDialogEcho, (data) => { TaskDetailInfoPanelCtrl.PopDialogToList(data); }); Messenger.AddListener(NotifyTypes.RefreshTaskInfos, () => { //时辰更新时需要检测城镇场景中的任务列表是否有更新 if (UserModel.CurrentUserData != null) { Messenger.Broadcast <string>(NotifyTypes.GetTaskListDataInCityScene, UserModel.CurrentUserData.CurrentCitySceneId); //当任务列表打开的时候每个时辰切换都要再刷新下任务列表,更新任务状态 if (TaskListPanelCtrl.Ctrl != null) { Messenger.Broadcast(NotifyTypes.GetTaskListData); } if (TaskBtnPanelCtrl.Ctrl != null) { Messenger.Broadcast(NotifyTypes.ShowTaskBtnPanel); } } }); Messenger.AddListener <string>(NotifyTypes.AddANewTask, (taskId) => { DbManager.Instance.AddNewTask(taskId); Messenger.Broadcast(NotifyTypes.RefreshTaskInfos); }); }
/// <summary> /// Scenes the notify init. /// </summary> public static void RoleNotifyInit() { Messenger.AddListener <bool>(NotifyTypes.CallRoleInfoPanelData, (isfighting) => { DbManager.Instance.CallRoleInfoPanelData(isfighting); }); Messenger.AddListener <JObject, bool>(NotifyTypes.CallRoleInfoPanelDataEcho, (obj, isfighting) => { // RoleInfoPanelCtrl.Show((JArray)obj["data"], isfighting); RolesInfoPanelCtrl.Show((JArray)obj["data"]); if (!isfighting) { Messenger.Broadcast(NotifyTypes.ShowTaskBtnPanel); } }); Messenger.AddListener(NotifyTypes.HideRoleInfoPanel, () => { // RoleInfoPanelCtrl.MoveDown(); RolesInfoPanelCtrl.MoveDown(); Messenger.Broadcast(NotifyTypes.HideTaskBtnPanel); }); Messenger.AddListener(NotifyTypes.MakeRoleInfoPanelRedPointRefresh, () => { RolesInfoPanelCtrl.MakeRefreshRedPoint(); }); Messenger.AddListener(NotifyTypes.MakeReviewRole, () => { RolesInfoPanelCtrl.MakeReviewRole(); }); Messenger.AddListener <bool>(NotifyTypes.MakeChangeRoleEnable, (enable) => { RoleInfoPanelCtrl.MakeChangeRoleEnable(enable); }); Messenger.AddListener <bool>(NotifyTypes.MakeChangeBookEnable, (enable) => { RoleInfoPanelCtrl.MakeChangeBookEnable(enable); }); Messenger.AddListener <bool>(NotifyTypes.MakeRoleInfoPanelDisable, (dis) => { RoleInfoPanelCtrl.MakeDisable(dis); }); Messenger.AddListener <string>(NotifyTypes.GetRolesOfWinShopPanelData, (cityId) => { DbManager.Instance.GetRolesOfWinShopPanelData(cityId); }); Messenger.AddListener <List <RoleData> >(NotifyTypes.GetRolesOfWinShopPanelDataEcho, (roles) => { roles.Sort((a, b) => b.Id.CompareTo(a.Id)); RolesOfWinShopPanelCtrl.Show(roles); }); Messenger.AddListener(NotifyTypes.GetWeaponsListPanelData, () => { DbManager.Instance.GetWeaponsListPanelData(); }); Messenger.AddListener <List <WeaponData>, RoleData>(NotifyTypes.GetWeaponsListPanelDataEcho, (weapons, host) => { WeaponListPanelCtrl.Show(weapons, host); }); Messenger.AddListener <int, string>(NotifyTypes.ReplaceWeapon, (id, beUsingByRoleId) => { DbManager.Instance.ReplaceWeapon(id, beUsingByRoleId); }); Messenger.AddListener <int>(NotifyTypes.TakeOffWeapon, (id => { DbManager.Instance.TakeOffWeapon(id); SoundManager.GetInstance().PushSound("ui0008"); })); Messenger.AddListener(NotifyTypes.GetBooksListPanelData, () => { DbManager.Instance.GetBooksListPanelData(); }); Messenger.AddListener <List <BookData> >(NotifyTypes.GetBooksListPanelDataEcho, (books) => { BookListPanelCtrl.Show(books); }); Messenger.AddListener <int>(NotifyTypes.UseBook, (id => { DbManager.Instance.UseBook(id); })); Messenger.AddListener <int>(NotifyTypes.UnuseBook, (id => { DbManager.Instance.UnuseBook(id); SoundManager.GetInstance().PushSound("ui0008"); })); Messenger.AddListener <string>(NotifyTypes.GetBooksOfForbiddenAreaPanelData, (cityId) => { DbManager.Instance.GetBooksOfForbiddenAreaPanelData(cityId); }); Messenger.AddListener <List <BookData>, RoleData>(NotifyTypes.GetBooksOfForbiddenAreaPanelDataEcho, (books, host) => { BooksOfForbiddenAreaPanelCtrl.Show(books, host); }); Messenger.AddListener <int>(NotifyTypes.InviteRole, (id) => { // DbManager.Instance.InviteRole(id); DbManager.Instance.InviteRoleWithResources(id); }); Messenger.AddListener <int>(NotifyTypes.ReadBook, (id => { DbManager.Instance.ReadBook(id); })); Messenger.AddListener(NotifyTypes.GetReadyToTravelPanelData, () => { DbManager.Instance.GetReadyToTravelPanelData(); }); Messenger.AddListener <List <RoleData>, UserData>(NotifyTypes.GetReadyToTravelPanelDataEcho, (roles, user) => { Messenger.Broadcast(NotifyTypes.HideRoleInfoPanel); roles.Sort(sortReadyToTravelRoles); ReadyToTravelPanelCtrl.Show(roles, user); }); Messenger.AddListener <RoleData>(NotifyTypes.MakeSelectRoleInTeam, (role) => { ReadyToTravelPanelCtrl.MakeSelectRole(role); }); Messenger.AddListener <RoleData>(NotifyTypes.MakeUnSelectRoleInTeam, (role) => { ReadyToTravelPanelCtrl.MakeUnSelectRole(role); }); Messenger.AddListener <JArray>(NotifyTypes.ChangeRolesSeatNo, (ids) => { DbManager.Instance.ChangeRolesSeatNo(ids); }); Messenger.AddListener(NotifyTypes.EnterAreaFromCity, () => { Messenger.Broadcast(NotifyTypes.HideCityScenePanel); Messenger.Broadcast(NotifyTypes.FromCitySceneBackToArea); Messenger.Broadcast(NotifyTypes.CallAreaMainPanelData); ReadyToTravelPanelCtrl.Hide(); }); Messenger.AddListener(NotifyTypes.GetHospitalPanelData, () => { DbManager.Instance.GetHospitalPanelData(); }); Messenger.AddListener <List <RoleData> >(NotifyTypes.GetHospitalPanelDataEcho, (roles) => { roles.Sort((a, b) => b.Injury.CompareTo(a.Injury)); HospitalPanelCtrl.Show(roles); }); Messenger.AddListener <int>(NotifyTypes.CureRole, (id => { DbManager.Instance.CureRole(id); })); Messenger.AddListener(NotifyTypes.RelieveRoles, () => { DbManager.Instance.RelieveRoles(); }); Messenger.AddListener(NotifyTypes.GetBagPanelData, () => { DbManager.Instance.GetBagPanelData(); }); Messenger.AddListener <List <ItemData>, double>(NotifyTypes.GetBagPanelDataEcho, (items, silver) => { BagPanelCtrl.Show(items, silver); }); Messenger.AddListener <ItemData, bool>(NotifyTypes.ShowItemDetailPanel, (item, fromBag) => { ItemDetailPanelCtrl.Show(item, fromBag); }); Messenger.AddListener(NotifyTypes.GetSellItemsPanelData, () => { DbManager.Instance.GetSellItemsPanelData(); }); Messenger.AddListener <List <ItemData> >(NotifyTypes.GetSellItemsPanelDataEcho, (items) => { SellItemsPanelCtrl.Show(items); }); Messenger.AddListener(NotifyTypes.MakeSelectedItemOfSellItemsPanel, () => { SellItemsPanelCtrl.MakeSelectedItem(); }); Messenger.AddListener <JArray>(NotifyTypes.SellItems, (ids) => { DbManager.Instance.SellItems(ids); }); Messenger.AddListener <double>(NotifyTypes.SellItemsEcho, (silver) => { SellItemsPanelCtrl.Hide(); StorePanelCtrl.MakeChangeSilverNum(silver); SoundManager.GetInstance().PushSound("ui0005"); }); Messenger.AddListener <int>(NotifyTypes.DiscardItem, (id) => { DbManager.Instance.DiscardItem(id); SoundManager.GetInstance().PushSound("ui0008"); }); Messenger.AddListener <BookData>(NotifyTypes.ShowBookDetailPanel, (book) => { BookDetailPanelCtrl.Show(book, DbManager.Instance.GetBookExpAndSecrets(book.Id)); }); Messenger.AddListener <WeaponData>(NotifyTypes.ShowWeaponDetailPanel, (weapon) => { WeaponDetailPanelCtrl.Show(weapon, DbManager.Instance.GetWeaponLV(weapon.Id)); }); Messenger.AddListener <WeaponData>(NotifyTypes.WeaponLVUpgrade, (weapon) => { DbManager.Instance.WeaponLVUpgrade(weapon); }); Messenger.AddListener <WeaponLVData>(NotifyTypes.WeaponLVUpgradeEcho, (lvData) => { WeaponDetailPanelCtrl.WeaponLVUpgrade(lvData); }); Messenger.AddListener <RoleData>(NotifyTypes.ShowRoleDetailPanel, (role) => { RoleDetailPanelCtrl.Show(role, DbManager.Instance.GetSecretsBelongBooks(role.ResourceBookDataIds)); }); Messenger.AddListener <List <DropData> >(NotifyTypes.ShowDropsListPanel, (drops) => { DropsListPanelCtrl.Show(drops); SoundManager.GetInstance().PushSound("ui0004"); }); Messenger.AddListener <int>(NotifyTypes.UseItem, (id => { DbManager.Instance.UseItem(id); })); Messenger.AddListener <string>(NotifyTypes.GetInnInCityData, (cityId) => { DbManager.Instance.GetInnInCityData(cityId); }); Messenger.AddListener <List <FloydResult> >(NotifyTypes.GetInnInCityDataEcho, (results) => { InnPanelCtrl.Show(results); }); Messenger.AddListener <int, int>(NotifyTypes.GoToCity, (fromIndex, toIndex) => { DbManager.Instance.GoToCity(fromIndex, toIndex); }); Messenger.AddListener <SceneData>(NotifyTypes.GoToCityEcho, (scene) => { string eventId = JsonManager.GetInstance().GetMapping <string>("AreaCityPosDatas", scene.Id); string[] fen = eventId.Split(new char[] { '_' }); if (fen.Length >= 3) { string areaName = fen[0]; int x = int.Parse(fen[1]); int y = int.Parse(fen[2]); if (UserModel.CurrentUserData != null) { CityScenePanelCtrl.MakeClose(); InnPanelCtrl.Hide(); UserModel.CurrentUserData.PositionStatu = UserPositionStatusType.InCity; UserModel.CurrentUserData.CurrentCitySceneId = scene.Id; UserModel.CurrentUserData.CurrentAreaSceneName = areaName; UserModel.CurrentUserData.CurrentAreaX = x; UserModel.CurrentUserData.CurrentAreaY = y; //清空临时事件 Messenger.Broadcast <List <SceneEventType> >(NotifyTypes.ClearDisableEventIdMapping, new List <SceneEventType>() { SceneEventType.DisablePagoda }); Messenger.Broadcast <System.Action <UserData> >(NotifyTypes.UpdateUserData, null); Messenger.Broadcast <string>(NotifyTypes.GoToScene, areaName); } } }); Messenger.AddListener <string>(NotifyTypes.NpcsEventHandler, (npcId) => { switch (npcId) { case "05002001": if (DbManager.Instance.HostData.Occupation == OccupationType.None) { if (!DbManager.Instance.HasAnyTask((new List <string>() { "task_occupation0", "task_occupation1", "task_occupation2", "task_occupation3", "task_occupation4", "task_occupation5" }).ToArray())) { OccupationPanelCtrl.Show(); } else { AlertCtrl.Show("去吧去吧,老夫已为你做了引荐"); } } else { AlertCtrl.Show(string.Format("你已是{0},可喜可贺啊,哦哈哈哈哈", Statics.GetOccupationDesc(DbManager.Instance.HostData.Occupation))); } break; default: break; } }); Messenger.AddListener <int>(NotifyTypes.HostRoleUpgrade, (toLv) => { DbManager.Instance.HostRoleUpgrade(toLv); }); Messenger.AddListener <RoleData, RoleData>(NotifyTypes.HostRoleUpgradeEcho, (roleData, toData) => { RoleUpgradeLvPanelCtrl.Show(roleData, toData); SoundManager.GetInstance().PushSound("ui0002"); }); Messenger.AddListener(NotifyTypes.OpenRepairBugPanel, () => { RepairBugPanelCtrl.Show(); }); Messenger.AddListener <BookData, List <SecretData> >(NotifyTypes.GetSecretListPanelData, (book, hasSecrets) => { SecretListPanelCtrl.Show(DbManager.Instance.GetEffectiveSecrets(), book, hasSecrets); }); Messenger.AddListener <BookData, List <SecretData> >(NotifyTypes.DealSecretEcho, (book, hasSecrets) => { if (RolesInfoPanelCtrl.Ctrl != null) { Messenger.Broadcast <bool>(NotifyTypes.CallRoleInfoPanelData, false); Messenger.Broadcast(NotifyTypes.MakeReviewRole); } Messenger.Broadcast <BookData>(NotifyTypes.ShowBookDetailPanel, book); Messenger.Broadcast <BookData, List <SecretData> >(NotifyTypes.GetSecretListPanelData, book, hasSecrets); }); Messenger.AddListener(NotifyTypes.OpenTowerGuiderPanel, () => { TowerGuiderPanelCtrl.Show(); AreaMainPanelCtrl.MakeRefreshDifficultyView(); }); }
/// <summary> /// 用户相关消息 /// </summary> public static void UserNotifyInit() { Messenger.AddListener <System.Action <UserData> >(NotifyTypes.CallUserData, (callback) => { callUserDataCallback = callback; DbManager.Instance.CallUserData(); }); Messenger.AddListener <System.Action <UserData> >(NotifyTypes.UpdateUserData, (callback) => { if (UserModel.CurrentUserData != null) { callUserDataCallback = callback; DbManager.Instance.UpdateUserData(JsonManager.GetInstance().SerializeObjectDealVector(UserModel.CurrentUserData)); } }); Messenger.AddListener <JObject>(NotifyTypes.CallUserDataEcho, (obj) => { if (callUserDataCallback != null) { JArray data = (JArray)obj["data"]; UserModel.CurrentUserData = JsonManager.GetInstance().DeserializeObject <UserData>(data[1].ToString()); UserModel.CurrentUserData.Id = data[0].ToString(); UserModel.CurrentUserData.AreaFood.Num = (int)data[2]; UserModel.CurrentUserData.TimeAngle = (float)data[3]; UserModel.CurrentUserData.TimeTicks = (long)data[4]; FramePanelCtrl.TimePlay(UserModel.CurrentUserData.TimeAngle, UserModel.CurrentUserData.TimeTicks); //初始化时辰时间戳 callUserDataCallback(UserModel.CurrentUserData); callUserDataCallback = null; } }); Messenger.AddListener <string, Vector2, System.Action <UserData> >(NotifyTypes.UpdateUserDataAreaInfo, (areaName, pos, callback) => { if (UserModel.CurrentUserData != null) { UserModel.CurrentUserData.PositionStatu = UserPositionStatusType.InArea; UserModel.CurrentUserData.CurrentAreaSceneName = areaName; UserModel.CurrentUserData.CurrentAreaX = (int)pos.x; UserModel.CurrentUserData.CurrentAreaY = (int)pos.y; Messenger.Broadcast <System.Action <UserData> >(NotifyTypes.UpdateUserData, callback); } }); Messenger.AddListener <string>(NotifyTypes.UpdateUserDataCityInfo, (cityId) => { if (UserModel.CurrentUserData != null) { SceneData scene = JsonManager.GetInstance().GetMapping <SceneData>("Scenes", cityId); //战斗据点场景不缓存 if (!scene.IsJustFightScene) { UserModel.CurrentUserData.PositionStatu = UserPositionStatusType.InCity; UserModel.CurrentUserData.CurrentCitySceneId = cityId; } } }); Messenger.AddListener <string, Vector2, System.Action <UserData> >(NotifyTypes.UpdateUserDataAreaPos, (areaName, pos, callback) => { if (UserModel.CurrentUserData != null) { UserModel.CurrentUserData.CurrentAreaSceneName = areaName; UserModel.CurrentUserData.CurrentAreaX = (int)pos.x; UserModel.CurrentUserData.CurrentAreaY = (int)pos.y; Messenger.Broadcast <System.Action <UserData> >(NotifyTypes.UpdateUserData, callback); } }); Messenger.AddListener(NotifyTypes.PlayBgm, () => { if (UserModel.CurrentUserData != null) { switch (UserModel.CurrentUserData.PositionStatu) { case UserPositionStatusType.InArea: if (AreaModel.AreaMainScript) { AreaModel.AreaMainScript.PlayBgm(); } break; case UserPositionStatusType.InCity: CityScenePanelCtrl.MakePlayBgm(); break; default: break; } } }); Messenger.AddListener(NotifyTypes.EnterGame, () => { DbManager.Instance.ResetTasks(); //初始化任务 if (DbManager.Instance.GetRecordNum() > 0) { // MainPanelCtrl.Hide(); // RecordListPanelCtrl.Hide(); // SettingPanelCtrl.Hide(); UIModel.CloseAllWindows(); Messenger.Broadcast <bool>(NotifyTypes.CallRoleInfoPanelData, false); Messenger.Broadcast <System.Action <UserData> >(NotifyTypes.CallUserData, (userData) => { Messenger.Broadcast <string>(NotifyTypes.GoToScene, userData.CurrentAreaSceneName); }); } else { Messenger.Broadcast <string>(NotifyTypes.ShowCreateHostRolePanel, "role_0"); //第一个角色创建 } }); Messenger.AddListener <string>(NotifyTypes.ShowCreateHostRolePanel, (id) => { // MainPanelCtrl.Hide(); // RecordListPanelCtrl.Hide(); // SettingPanelCtrl.Hide(); UIModel.CloseAllWindows(); CreateHostRolePanelCtrl.Show(id); }); Messenger.AddListener <RoleData>(NotifyTypes.CreateHostRole, (role) => { PlayerPrefs.SetString("CurrentRoleId", role.Id); //记录当前角色存档id DbManager.Instance.SetCurrentRoleId(role.Id); DbManager.Instance.AddNewRecord(role.Id, role.Name, "{}", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); //创建用户数据 UserData userData = new UserData(); userData.AreaFood = new ItemData(); userData.AreaFood.Num = 0; userData.AreaFood.MaxNum = 30; userData.PositionStatu = UserPositionStatusType.InCity; userData.CurrentAreaSceneName = "Area00"; userData.CurrentCitySceneId = "00001"; userData.CurrentAreaX = 15; userData.CurrentAreaY = 15; DbManager.Instance.AddNewUserData(JsonManager.GetInstance().SerializeObjectDealVector(userData), userData.AreaFood.Num, role.Id, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); //创建角色数据 role.ResourceBookDataIds.Clear(); if (DbManager.Instance.AddNewRole(role.Id, JsonManager.GetInstance().SerializeObjectDealVector(role), (int)RoleStateType.InTeam, 0, role.HometownCityId, role.Id, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))) { // DbManager.Instance.AddNewWeapon(role.ResourceWeaponDataId, role.Id); // DbManager.Instance.AddNewWeapon("1"); // DbManager.Instance.AddNewWeapon("2"); // DbManager.Instance.AddNewWeapon("3"); CreateHostRolePanelCtrl.MakeStoryContinue(role.Name); } }); Messenger.AddListener(NotifyTypes.GetRecordListData, () => { DbManager.Instance.GetRecordListData(); }); Messenger.AddListener <List <JArray> >(NotifyTypes.GetRecordListDataEcho, (data) => { RecordListPanelCtrl.Show(data); }); Messenger.AddListener(NotifyTypes.ShowMainPanel, () => { // MainPanelCtrl.Hide(); // RecordListPanelCtrl.Hide(); // SettingPanelCtrl.Hide(); UIModel.CloseAllWindows(); MainPanelCtrl.Show(); }); Messenger.AddListener <bool>(NotifyTypes.ShowSettingPanel, (flag) => { //战斗时不能打开设置界面 if (BattleMainPanelCtrl.Ctrl != null) { return; } SettingPanelCtrl.Show(flag); }); }
/// <summary> /// Scenes the notify init. /// </summary> public static void SceneNotifyInit() { Messenger.AddListener <string>(NotifyTypes.GoToScene, (sceneName) => { SceneManagerController.GetInstance().ChangeScene(sceneName); }); Messenger.AddListener <string>(NotifyTypes.DealSceneEvent, (eventId) => { // EventData eventData = JsonManager.GetInstance().GetMapping<EventData>("AreaEventDatas", eventId); EventData eventData = null; if (AreaMain.StaticAreaEventsMapping.ContainsKey(eventId)) { //判断静态事件是否禁用 if (!AreaMain.DisableEventIdMapping.ContainsKey(eventId)) { eventData = AreaMain.StaticAreaEventsMapping[eventId]; } } else if (AreaMain.ActiveAreaEventsMapping.ContainsKey(eventId)) { eventData = AreaMain.ActiveAreaEventsMapping[eventId]; } if (eventData != null) { string[] fen; switch (eventData.Type) { case SceneEventType.EnterArea: fen = eventData.EventId.Split(new char[] { '_' }); if (fen.Length >= 3) { string areaName = fen[0]; int x = int.Parse(fen[1]); int y = int.Parse(fen[2]); Messenger.Broadcast <string, Vector2, System.Action <UserData> >(NotifyTypes.UpdateUserDataAreaInfo, areaName, new Vector2(x, y), (userData) => { Messenger.Broadcast <string>(NotifyTypes.GoToScene, userData.CurrentAreaSceneName); //清空临时事件 Messenger.Broadcast <List <SceneEventType> >(NotifyTypes.ClearDisableEventIdMapping, new List <SceneEventType>() { SceneEventType.DisablePagoda }); }); } break; case SceneEventType.Battle: case SceneEventType.Pagoda: Messenger.Broadcast <string>(NotifyTypes.CreateBattle, eventData.EventId); break; case SceneEventType.EnterCity: Messenger.Broadcast <string>(NotifyTypes.UpdateUserDataCityInfo, eventData.EventId); Messenger.Broadcast <System.Action <UserData> >(NotifyTypes.UpdateUserData, (userData) => { // Messenger.Broadcast<string>(NotifyTypes.EnterCityScene, userData.CurrentCitySceneId); Messenger.Broadcast <string>(NotifyTypes.EnterCityScene, eventData.EventId); }); break; case SceneEventType.Task: Messenger.Broadcast <string>(NotifyTypes.GetTaslDetailInfoData, eventData.EventId); break; case SceneEventType.EatFood: Messenger.Broadcast <int>(NotifyTypes.EatFood, eventData.IntValue); fen = eventData.Id.Split(new char[] { '_' }); if (fen.Length >= 3) { string areaName = fen[0]; int x = int.Parse(fen[1]); int y = int.Parse(fen[2]); //处理静态事件的预禁用操作 EventData disableEvent = new EventData(); disableEvent.Id = eventData.Id; disableEvent.Type = SceneEventType.DisableEvent; disableEvent.X = x; disableEvent.Y = y; Messenger.Broadcast <string, EventData>(NotifyTypes.PushDisableEvent, disableEvent.Id, disableEvent); } break; case SceneEventType.Dialog: switch (eventData.EventId) { case "dialog0001": Messenger.Broadcast(NotifyTypes.OpenTowerGuiderPanel); break; default: break; } break; case SceneEventType.Store: DbManager.Instance.GetStoreData(eventData.EventId); break; default: break; } } }); Messenger.AddListener(NotifyTypes.FromCitySceneBackToArea, () => { if (UserModel.CurrentUserData != null) { Messenger.Broadcast <string, Vector2, System.Action <UserData> >(NotifyTypes.UpdateUserDataAreaInfo, UserModel.CurrentUserData.CurrentAreaSceneName, new Vector2(UserModel.CurrentUserData.CurrentAreaX, UserModel.CurrentUserData.CurrentAreaY), (userData) => { UserModel.CurrentFoodNums = userData.AreaFood.MaxNum; UserModel.CurrentRebornTimes = 0; //播放大地图背景音乐 Messenger.Broadcast(NotifyTypes.PlayBgm); } ); } //清空临时事件 Messenger.Broadcast <List <SceneEventType> >(NotifyTypes.ClearDisableEventIdMapping, new List <SceneEventType>() { SceneEventType.DisablePagoda }); }); Messenger.AddListener <string>(NotifyTypes.EnterCityScene, (cityId) => { DbManager.Instance.CheckEnterCity(cityId); DbManager.Instance.GetCitySceneMenuData(cityId); Messenger.Broadcast(NotifyTypes.GetTasksInCityScene); Messenger.Broadcast(NotifyTypes.MakeTaskListHide); }); Messenger.AddListener(NotifyTypes.GetTasksInCityScene, () => { CityScenePanelCtrl.GetTasksInCityScene(); }); Messenger.AddListener(NotifyTypes.HideCityScenePanel, () => { CityScenePanelCtrl.MakeFadeOut(); }); Messenger.AddListener <string>(NotifyTypes.GetStorePanelData, (cityId) => { DbManager.Instance.GetStorePanelData(cityId); }); Messenger.AddListener <List <ItemData>, double>(NotifyTypes.GetStorePanelDataEcho, (items, silver) => { StorePanelCtrl.Show(items, silver); }); Messenger.AddListener <string>(NotifyTypes.BuyItem, (itemId) => { DbManager.Instance.BuyItem(itemId); }); Messenger.AddListener <string, double>(NotifyTypes.BuyItemEcho, (msg, silver) => { StorePanelCtrl.MakeBuyItemEcho(msg, silver); SoundManager.GetInstance().PushSound("ui0006"); }); Messenger.AddListener(NotifyTypes.MakeCheckNewFlags, () => { CityScenePanelCtrl.MakeCheckNewFlags(); }); }
/// <summary> /// Scenes the notify init. /// </summary> public static void RoleNotifyInit() { Messenger.AddListener <bool>(NotifyTypes.CallRoleInfoPanelData, (isfighting) => { DbManager.Instance.CallRoleInfoPanelData(isfighting); }); Messenger.AddListener <JObject, bool>(NotifyTypes.CallRoleInfoPanelDataEcho, (obj, isfighting) => { RoleInfoPanelCtrl.Show((JArray)obj["data"], isfighting); if (!isfighting) { Messenger.Broadcast(NotifyTypes.ShowTaskBtnPanel); } }); Messenger.AddListener(NotifyTypes.HideRoleInfoPanel, () => { RoleInfoPanelCtrl.MoveDown(); Messenger.Broadcast(NotifyTypes.HideTaskBtnPanel); }); Messenger.AddListener <bool>(NotifyTypes.MakeChangeRoleEnable, (enable) => { RoleInfoPanelCtrl.MakeChangeRoleEnable(enable); }); Messenger.AddListener <bool>(NotifyTypes.MakeChangeBookEnable, (enable) => { RoleInfoPanelCtrl.MakeChangeBookEnable(enable); }); Messenger.AddListener <bool>(NotifyTypes.MakeRoleInfoPanelDisable, (dis) => { RoleInfoPanelCtrl.MakeDisable(dis); }); Messenger.AddListener <string>(NotifyTypes.GetRolesOfWinShopPanelData, (cityId) => { DbManager.Instance.GetRolesOfWinShopPanelData(cityId); }); Messenger.AddListener <List <RoleData> >(NotifyTypes.GetRolesOfWinShopPanelDataEcho, (roles) => { RolesOfWinShopPanelCtrl.Show(roles); }); Messenger.AddListener(NotifyTypes.GetWeaponsListPanelData, () => { DbManager.Instance.GetWeaponsListPanelData(); }); Messenger.AddListener <List <WeaponData>, RoleData>(NotifyTypes.GetWeaponsListPanelDataEcho, (weapons, host) => { WeaponListPanelCtrl.Show(weapons, host); }); Messenger.AddListener <int, string>(NotifyTypes.ReplaceWeapon, (id, beUsingByRoleId) => { DbManager.Instance.ReplaceWeapon(id, beUsingByRoleId); }); Messenger.AddListener <int>(NotifyTypes.TakeOffWeapon, (id => { DbManager.Instance.TakeOffWeapon(id); })); Messenger.AddListener(NotifyTypes.GetBooksListPanelData, () => { DbManager.Instance.GetBooksListPanelData(); }); Messenger.AddListener <List <BookData> >(NotifyTypes.GetBooksListPanelDataEcho, (books) => { BookListPanelCtrl.Show(books); }); Messenger.AddListener <int>(NotifyTypes.UseBook, (id => { DbManager.Instance.UseBook(id); })); Messenger.AddListener <int>(NotifyTypes.UnuseBook, (id => { DbManager.Instance.UnuseBook(id); })); Messenger.AddListener <string>(NotifyTypes.GetBooksOfForbiddenAreaPanelData, (cityId) => { DbManager.Instance.GetBooksOfForbiddenAreaPanelData(cityId); }); Messenger.AddListener <List <BookData>, RoleData>(NotifyTypes.GetBooksOfForbiddenAreaPanelDataEcho, (books, host) => { BooksOfForbiddenAreaPanelCtrl.Show(books, host); }); Messenger.AddListener <int>(NotifyTypes.InviteRole, (id) => { // DbManager.Instance.InviteRole(id); DbManager.Instance.InviteRoleWithResources(id); }); Messenger.AddListener <int>(NotifyTypes.ReadBook, (id => { DbManager.Instance.ReadBook(id); })); Messenger.AddListener(NotifyTypes.GetReadyToTravelPanelData, () => { DbManager.Instance.GetReadyToTravelPanelData(); }); Messenger.AddListener <List <RoleData>, ItemData>(NotifyTypes.GetReadyToTravelPanelDataEcho, (roles, food) => { Messenger.Broadcast(NotifyTypes.HideRoleInfoPanel); ReadyToTravelPanelCtrl.Show(roles, food); }); Messenger.AddListener <RoleData>(NotifyTypes.MakeSelectRoleInTeam, (role) => { ReadyToTravelPanelCtrl.MakeSelectRole(role); }); Messenger.AddListener <RoleData>(NotifyTypes.MakeUnSelectRoleInTeam, (role) => { ReadyToTravelPanelCtrl.MakeUnSelectRole(role); }); Messenger.AddListener <JArray>(NotifyTypes.ChangeRolesSeatNo, (ids) => { DbManager.Instance.ChangeRolesSeatNo(ids); }); Messenger.AddListener(NotifyTypes.ChangeRolesSeatNoEcho, () => { Messenger.Broadcast(NotifyTypes.HideCityScenePanel); Messenger.Broadcast(NotifyTypes.FromCitySceneBackToArea); Messenger.Broadcast(NotifyTypes.CallAreaMainPanelData); ReadyToTravelPanelCtrl.Hide(); }); Messenger.AddListener(NotifyTypes.GetHospitalPanelData, () => { DbManager.Instance.GetHospitalPanelData(); }); Messenger.AddListener <List <RoleData> >(NotifyTypes.GetHospitalPanelDataEcho, (roles) => { HospitalPanelCtrl.Show(roles); }); Messenger.AddListener <int>(NotifyTypes.CureRole, (id => { DbManager.Instance.CureRole(id); })); Messenger.AddListener(NotifyTypes.GetBagPanelData, () => { DbManager.Instance.GetBagPanelData(); }); Messenger.AddListener <List <ItemData>, double>(NotifyTypes.GetBagPanelDataEcho, (items, silver) => { BagPanelCtrl.Show(items, silver); }); Messenger.AddListener <ItemData, bool>(NotifyTypes.ShowItemDetailPanel, (item, fromBag) => { ItemDetailPanelCtrl.Show(item, fromBag); }); Messenger.AddListener(NotifyTypes.GetSellItemsPanelData, () => { DbManager.Instance.GetSellItemsPanelData(); }); Messenger.AddListener <List <ItemData> >(NotifyTypes.GetSellItemsPanelDataEcho, (items) => { SellItemsPanelCtrl.Show(items); }); Messenger.AddListener(NotifyTypes.MakeSelectedItemOfSellItemsPanel, () => { SellItemsPanelCtrl.MakeSelectedItem(); }); Messenger.AddListener <JArray>(NotifyTypes.SellItems, (ids) => { DbManager.Instance.SellItems(ids); }); Messenger.AddListener <double>(NotifyTypes.SellItemsEcho, (silver) => { SellItemsPanelCtrl.Hide(); StorePanelCtrl.MakeChangeSilverNum(silver); }); Messenger.AddListener <int>(NotifyTypes.DiscardItem, (id) => { DbManager.Instance.DiscardItem(id); }); Messenger.AddListener <BookData>(NotifyTypes.ShowBookDetailPanel, (book) => { BookDetailPanelCtrl.Show(book); }); Messenger.AddListener <WeaponData>(NotifyTypes.ShowWeaponDetailPanel, (weapon) => { WeaponDetailPanelCtrl.Show(weapon); }); Messenger.AddListener <RoleData>(NotifyTypes.ShowRoleDetailPanel, (role) => { RoleDetailPanelCtrl.Show(role); }); Messenger.AddListener <List <DropData> >(NotifyTypes.ShowDropsListPanel, (drops) => { DropsListPanelCtrl.Show(drops); }); Messenger.AddListener <int>(NotifyTypes.UseItem, (id => { DbManager.Instance.UseItem(id); })); Messenger.AddListener <string>(NotifyTypes.GetInnInCityData, (cityId) => { DbManager.Instance.GetInnInCityData(cityId); }); Messenger.AddListener <List <FloydResult> >(NotifyTypes.GetInnInCityDataEcho, (results) => { InnPanelCtrl.Show(results); }); Messenger.AddListener <int, int>(NotifyTypes.GoToCity, (fromIndex, toIndex) => { DbManager.Instance.GoToCity(fromIndex, toIndex); }); Messenger.AddListener <SceneData>(NotifyTypes.GoToCityEcho, (scene) => { string eventId = JsonManager.GetInstance().GetMapping <string>("AreaCityPosDatas", scene.Id); string[] fen = eventId.Split(new char[] { '_' }); if (fen.Length >= 3) { string areaName = fen[0]; int x = int.Parse(fen[1]); int y = int.Parse(fen[2]); if (UserModel.CurrentUserData != null) { CityScenePanelCtrl.MakeClose(); InnPanelCtrl.Hide(); UserModel.CurrentUserData.PositionStatu = UserPositionStatusType.InCity; UserModel.CurrentUserData.CurrentCitySceneId = scene.Id; UserModel.CurrentUserData.CurrentAreaSceneName = areaName; UserModel.CurrentUserData.CurrentAreaX = x; UserModel.CurrentUserData.CurrentAreaY = y; //清空临时事件 Messenger.Broadcast(NotifyTypes.ClearDisableEventIdMapping); Messenger.Broadcast <System.Action <UserData> >(NotifyTypes.UpdateUserData, null); Messenger.Broadcast <string>(NotifyTypes.GoToScene, areaName); } } }); Messenger.AddListener <string>(NotifyTypes.NpcsEventHandler, (npcId) => { switch (npcId) { case "05002001": if (DbManager.Instance.HostData.Occupation == OccupationType.None) { if (!DbManager.Instance.HasAnyTask((new List <string>() { "task_occupation0", "task_occupation1", "task_occupation2", "task_occupation3", "task_occupation4", "task_occupation5" }).ToArray())) { OccupationPanelCtrl.Show(); } else { AlertCtrl.Show("去吧去吧,老夫已为你做了引荐"); } } else { AlertCtrl.Show(string.Format("你已是{0}{1},可喜可贺啊,哦哈哈哈哈", Statics.GetOccupationName(DbManager.Instance.HostData.Occupation), Statics.GetOccupationDesc(DbManager.Instance.HostData.Occupation))); } break; default: break; } }); }