protected override void Init() { canGo = false; sunAndMoonImage = GetChildImage("sunAndMoonImage"); timeText = GetChildText("timeText"); settingBtn = GetChildButton("SettingBtn"); EventTriggerListener.Get(settingBtn.gameObject).onClick = onClick; viewTimesButton = GetChildButton("viewTimesButton"); EventTriggerListener.Get(viewTimesButton.gameObject).onClick = onClick; enemyInfoBtn = GetChildButton("EnemyInfoBtn"); EventTriggerListener.Get(enemyInfoBtn.gameObject).onClick = onClick; backToCityBtn = GetChildButton("BackToCityBtn"); EventTriggerListener.Get(backToCityBtn.gameObject).onClick = onClick; enemyInfoRedPointImage = GetChildImage("EnemyInfoRedPointImage"); timeNames = Statics.GetTimeNames(); _currentTimeIndex = -1; lastTimeIndex = _currentTimeIndex; currentAngle = 0; oldAngle = -1; angleRotateDate = DateTime.Now; angleRotateTimeout = 1f; //20秒旋转1度 // resetTimeIndex(); instance = this; refreshRedPointView(); }
/// <summary> /// 记录进入的区域大地图 /// </summary> /// <param name="areaName">Area name.</param> public void CheckEnterArea(string areaName) { db = OpenDb(); SqliteDataReader sqReader = db.ExecuteQuery("select Id from EnterAreaTable where AreaName = '" + areaName + "' and BelongToRoleId = '" + currentRoleId + "'"); if (!sqReader.HasRows) { db.ExecuteQuery("insert into EnterAreaTable (AreaName, BelongToRoleId) values('" + areaName + "', '" + currentRoleId + "')"); FramePanelCtrl.MakeSetEnemyInfoRedPointFlag(true); } db.CloseSqlConnection(); }
/// <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); }); }