void onClick(GameObject e) { if (npcData.Type == NpcType.Fight) { if (Time.fixedTime - date >= timeout) { date = Time.fixedTime; if (npcData.DefaultDialogMsg != "") { Statics.CreateDialogMsgPop(new Vector3(transform.position.x - 0.2f, transform.position.y, transform.position.z), npcData.DefaultDialogMsg, Color.black); } Invoke("doFight", 1); } } else if (npcData.CurrentTask != null) { Messenger.Broadcast <string>(NotifyTypes.GetTaslDetailInfoData, npcData.CurrentTask.Id); } else if (npcData.Type == NpcType.AfterTask) { switch (npcData.Id) { case "05002001": //江湖百晓生 Messenger.Broadcast <string>(NotifyTypes.NpcsEventHandler, npcData.Id); break; default: break; } } else { if (npcData.DefaultDialogMsg != "") { Statics.CreateDialogMsgPop(new Vector3(transform.position.x - 0.2f, transform.position.y, transform.position.z), npcData.DefaultDialogMsg, Color.black); } } }
public void RefreshView() { Icon.sprite = Statics.GetResourceSprite(resourceData.Type); Name.text = Statics.GetResourceName(resourceData.Type); Num.text = resourceData.Num.ToString(); WorkerNum.text = resourceData.WorkersNum.ToString(); ResourceRelationshipData relationship = WorkshopModel.Relationships.Find(item => item.Type == resourceData.Type); if (relationship != null) { Output.text = string.Format("{0}+{1}", Statics.GetResourceName(relationship.Type), relationship.YieldNum); string costStr = relationship.Needs.Count > 0 ? "" : "无"; ResourceData need; for (int i = 0; i < relationship.Needs.Count; i++) { need = relationship.Needs[i]; costStr += string.Format("{0}-{1}\n", Statics.GetResourceName(need.Type), need.Num); } Cost.text = costStr; } //判断是否为新增资源,控制新增标记显示隐藏 NewFlag.gameObject.SetActive(string.IsNullOrEmpty(PlayerPrefs.GetString(PlayerPrefs.GetString("CurrentRoleId") + "_" + "ResourceTypeStrOfWorkShopNewFlagIsHide_" + resourceData.Type.ToString()))); }
void onClick(GameObject e) { if (weaponData == null) { return; } switch (e.name) { case "CreateBtn": ConfirmCtrl.Show(string.Format("开始打造<color=\"{0}\">{1}</color>?", Statics.GetQualityColorString(weaponData.Quality), weaponData.Name), () => { Messenger.Broadcast <string>(NotifyTypes.CreateNewWeaponOfWorkshop, weaponData.Id); }, null, "打造", "放弃"); break; case "ViewBtn": Messenger.Broadcast <WeaponData>(NotifyTypes.ShowWeaponDetailPanel, weaponData); break; default: break; } viewedNewFlag(); }
public void RefreshView() { if (weaponData == null) { return; } BreakBtn.gameObject.SetActive(weaponData.BeUsingByRoleId == ""); Icon.sprite = Statics.GetIconSprite(weaponData.IconId); Name.text = string.Format("<color=\"{0}\">{1}</color>", Statics.GetQualityColorString(weaponData.Quality), weaponData.Name); string gotStr = ""; ResourceData need; for (int i = 0; i < weaponData.Needs.Count; i++) { need = weaponData.Needs[i]; if (need.Num > 0) { gotStr += string.Format("{0}+{1}\n", Statics.GetResourceName(need.Type), need.Num); } } gotStr = gotStr == "" ? "无" : gotStr; Got.text = gotStr; }
/// <summary> /// 刷新角色 /// </summary> public void RefreshSelectedRolesView() { int totalHP = 0; for (int i = 0; i < selectedIcons.Count; i++) { if (selectedRolesData.Count > i) { selectedIcons[i].gameObject.SetActive(true); selectedIcons[i].sprite = Statics.GetIconSprite(selectedRolesData[i].IconId); totalHP += selectedRolesData[i].MaxHP; } else { selectedIcons[i].gameObject.SetActive(false); } } totalText.text = string.Format("总气血:{0}\n干粮:{1}/{2}", totalHP, foodData.Num, foodData.MaxNum); for (int i = 1; i < rolesData.Count; i++) { roleContainers[i - 1].EnableSelectBtn(selectedRolesData.Count < 4); } }
public override void RefreshView() { if (prefabObj == null) { prefabObj = Statics.GetPrefab("Prefabs/UI/GridItems/BagItemContainer"); } for (int i = 0; i < itemContainers.Count; i++) { if (itemContainers[i].gameObject != null) { Destroy(itemContainers[i].gameObject); } } itemContainers.Clear(); GameObject itemPrefab; ItemData item; BagItemContainer container; for (int i = 0; i < itemsData.Count; i++) { item = itemsData[i]; itemPrefab = Statics.GetPrefabClone(prefabObj); MakeToParent(grid.transform, itemPrefab.transform); container = itemPrefab.GetComponent <BagItemContainer>(); itemContainers.Add(container); container.UpdateData(item); container.RefreshView(); } RectTransform trans = grid.GetComponent <RectTransform>(); float y = (grid.cellSize.y + grid.spacing.y) * Mathf.Ceil(itemContainers.Count / 2) - grid.spacing.y; y = y < 0 ? 0 : y; trans.sizeDelta = new Vector2(trans.sizeDelta.x, y); silverText.text = silverNum.ToString(); totalText.text = string.Format("{0}/{1}", itemsData.Count, DbManager.Instance.MaxItemNumOfBag); }
void createLoading() { if (queuePushDialogData.Count == 0 || loadingContainerClone != null) { canSrollToBottom = false; return; } if (loadingContainerObj == null) { loadingContainerObj = Statics.GetPrefab("Prefabs/UI/GridItems/TaskDetailDialogs/TaskDetailDialogLoadingContainer"); } if (loadingContainerClone != null) { Destroy(loadingContainerClone); loadingContainerClone = null; } loadingContainerClone = Statics.GetPrefabClone(loadingContainerObj); loadingContainerClone.name = "loadingContainer"; pushItemToGrid(loadingContainerClone.transform); loadingContainerClone.GetComponent <TaskDetailDialogLoadingContainer>().UpdateData(() => { canPushDialog = true; loadingContainerClone = null; }); }
/// <summary> /// 设置buff属性 /// </summary> /// <param name="buffs">Buffs.</param> public void SetBuffDatas(List <BuffData> buffs) { if (BuffIconImages == null) { return; } buffDatas = buffs; BuffData buff; for (int i = 0; i < BuffIconImages.Length; i++) { if (buffDatas.Count > i) { buff = buffDatas[i]; BuffIconImages[i].gameObject.SetActive(true); BuffIconImages[i].sprite = Statics.GetBuffSprite(((int)buff.Type).ToString()); BuffIconImages[i].GetComponentInChildren <Text>().text = buff.RoundNumber.ToString();; } else { BuffIconImages[i].gameObject.SetActive(false); } } }
void onClick(GameObject e) { if (!e.GetComponent <Button>().enabled) { return; } switch (e.name) { case "MakeBtn": if (roleData.State == RoleStateType.NotRecruited) { // ConfirmCtrl.Show(string.Format("是否将<color=\"{0}\">{1}</color>赠给{2}与其结交?", Statics.GetQualityColorString(weapon.Quality), weapon.Name, roleData.Name), () => { // Messenger.Broadcast<int>(NotifyTypes.InviteRole, roleData.PrimaryKeyId); // }); string needMsg = ""; for (int i = 0, len = weapon.Needs.Count; i < len; i++) { needMsg += string.Format("{0}个{1}", weapon.Needs[i].Num, Statics.GetEnmuDesc <ResourceType>(weapon.Needs[i].Type)) + (i < len - 1 ? "," : ""); } if (needMsg != "") { ConfirmCtrl.Show(string.Format("要将<color=\"{0}\">{1}</color>赠送给{2}\n需要{3}\n是否立即锻造兵器?", Statics.GetQualityColorString(weapon.Quality), weapon.Name, roleData.Name, needMsg), () => { Messenger.Broadcast <int>(NotifyTypes.InviteRole, roleData.PrimaryKeyId); }); } else { AlertCtrl.Show("兵器没有原材料无法打造", null); } } else { AlertCtrl.Show(string.Format("{0}已经和你结交", roleData.Name), null); } break; case "Btn": Messenger.Broadcast <RoleData>(NotifyTypes.ShowRoleDetailPanel, roleData); break; default: break; } viewedNewFlag(); }
public override void RefreshView() { iconImage.sprite = Statics.GetIconSprite(bookData.IconId); nameText.text = string.Format("<color=\"{0}\">{1}</color>", Statics.GetQualityColorString(bookData.Quality), bookData.Name); descText.text = string.Format("{0}{1}描述:\n{2}", bookData.LimitWeaponType != WeaponType.None ? string.Format("兵器限制:{0}\n", Statics.GetEnmuDesc <WeaponType>(bookData.LimitWeaponType)) : "", info != "" ? string.Format("附加属性:\n<color=\"#00FF00\">{0}</color>", info) : "", bookData.Desc); if (prefabObj == null) { prefabObj = Statics.GetPrefab("Prefabs/UI/GridItems/SkillItemContainer"); } if (bookData.Skills.Count > 0) { emptyImage.gameObject.SetActive(false); SkillData skill; GameObject itemPrefab; SkillItemContainer container; for (int i = 0; i < bookData.Skills.Count; i++) { skill = bookData.Skills[i]; if (containers.Count <= i) { itemPrefab = Statics.GetPrefabClone(prefabObj); MakeToParent(gridTrans.transform, itemPrefab.transform); container = itemPrefab.GetComponent <SkillItemContainer>(); containers.Add(container); } else { container = containers[i]; } container.UpdateData(skill, i != bookData.Skills.Count - 1); container.RefreshView(); } } else { emptyImage.gameObject.SetActive(true); } }
public override void RefreshView() { icon.sprite = Statics.GetIconSprite(weaponData.IconId); nameText.text = string.Format("<color=\"{0}\">{1}</color>", Statics.GetQualityColorString(weaponData.Quality), weaponData.Name); weaponWidthScript.UpdateData(weaponData); weaponWidthScript.RefreshView(); infoText.text = info; if (weaponData.BelongToRoleId == "") { occupationText.text = string.Format("门派限制:{0}", weaponData.Occupation != OccupationType.None ? Statics.GetOccupationName(weaponData.Occupation) : "无限制"); } else { occupationText.text = string.Format("仅限 {0} 使用", JsonManager.GetInstance().GetMapping <RoleData>("RoleDatas", weaponData.BelongToRoleId).Name); } }
public void StartTimer() { if (IsFree) { PlayerPrefs.SetString("PropFreeTimeStamp_For" + propData.Type.ToString(), Statics.GetNowTimeStamp().ToString()); date = Statics.ConvertStringToDateTime(PlayerPrefs.GetString("PropFreeTimeStamp_For" + propData.Type.ToString())); double remain = remainSeconds(); timing = remain > 0; skipDate = Time.fixedTime; if (timing) { TimerText.text = Statics.GetTime((int)remain); } TimerText.gameObject.SetActive(timing); PayBtn.gameObject.SetActive(!timing); } }
public override void RefreshView() { icon.sprite = Statics.GetIconSprite(weaponData.IconId); flashImage.gameObject.SetActive(((int)weaponData.Quality) >= ((int)QualityType.FlashGold)); nameText.text = string.Format("<color=\"{0}\">{1}</color> {2}", Statics.GetQualityColorString(weaponData.Quality), weaponData.Name, weaponLVData.LV > 0 ? ("+" + weaponLVData.LV) : ""); // weaponWidthScript.UpdateData(weaponData); // weaponWidthScript.RefreshView(); infoText.text = info; if (weaponData.BelongToRoleId == "") { occupationText.text = string.Format("门派限制:{0}", weaponData.Occupation != OccupationType.None ? Statics.GetOccupationName(weaponData.Occupation) : "无限制"); } else { occupationText.text = string.Format("仅限 {0} 使用", JsonManager.GetInstance().GetMapping <RoleData>("RoleDatas", weaponData.BelongToRoleId).Name); } lvFullNoticeText.gameObject.SetActive(weaponData.Quality >= QualityType.FlashGold && weaponLVData.LV >= weaponLVData.MaxLV); lvUpgradeBtn.gameObject.SetActive(weaponData.Quality >= QualityType.FlashGold && weaponLVData.LV < weaponLVData.MaxLV); StartCoroutine(refreshHeight()); }
public override void RefreshView() { foodIcon.sprite = Statics.GetIconSprite(foodIcondId); refreshFoodProcess(false); areaNameText.text = areaName; }
public void UpdateData(string id, JArray data, bool willDuring) { taskId = id; msgStr = data[2].ToString(); msgStr = msgStr.Replace("<n>", DbManager.Instance.HostData.Name); msgStr = msgStr.Replace("<o>", Statics.GetOccupationName(DbManager.Instance.HostData.Occupation)); msgStr = msgStr.Replace("<s>", Statics.GetGenderDesc(DbManager.Instance.HostData.Gender)); msgStr = msgStr.Replace("<ss>", DbManager.Instance.HostData.Gender == GenderType.Male ? "哥哥" : "姐姐"); msgStr = msgStr.Replace("<sss>", DbManager.Instance.HostData.Gender == GenderType.Male ? "公子" : "小姐"); msgStr = msgStr.Replace("<ssss>", DbManager.Instance.HostData.Gender == GenderType.Male ? "他" : "她"); dialogStatus = (TaskDialogStatusType)((short)data[3]); if (willDuring) { alphaGroup = gameObject.AddComponent <CanvasGroup>(); alphaGroup.alpha = 0; alphaGroup.DOFade(1, 0.5f).OnComplete(() => { if (alphaGroup != null) { Destroy(alphaGroup); } }); } }
void onClick(GameObject e) { switch (e.name) { case "moveBtn": if (!moveBtn.enabled) { return; } float newDate = Time.fixedTime; if (newDate - date < moveTimeout) { return; } date = newDate; float centerX = Screen.width * 0.5f; float centerY = Screen.height * 0.5f; float angle = Statics.GetAngle(Input.mousePosition.x, Input.mousePosition.y, centerX, centerY); if (angle < 45 || angle >= 315) { Messenger.Broadcast <string, bool>(NotifyTypes.MoveOnArea, AreaTarget.Down, true); } else if (angle >= 45 && angle < 135) { Messenger.Broadcast <string, bool>(NotifyTypes.MoveOnArea, AreaTarget.Left, true); } else if (angle >= 135 && angle < 225) { Messenger.Broadcast <string, bool>(NotifyTypes.MoveOnArea, AreaTarget.Up, true); } else if (angle >= 225 && angle < 315) { Messenger.Broadcast <string, bool>(NotifyTypes.MoveOnArea, AreaTarget.Right, true); } break; case "prop1BlockImage": // ConfirmCtrl.Show("一件夜行衣能避免一场野外战斗\n(观看一段视频可以获得1-2件)", () => { // if (propsData[0].Num >= propsData[0].Max) // { // AlertCtrl.Show(string.Format("最多只能携带{0}件夜行衣", propsData[0].Max)); // return;; // } // int randomNum = UnityEngine.Random.Range(1, 3); // Messenger.Broadcast<PropType, int>(NotifyTypes.AddProp, PropType.NocturnalClothing, randomNum); // AlertCtrl.Show(string.Format("获得了{0}件夜行衣", randomNum)); // }, null, "观看", "不了"); PropsMallPanelCtrl.Show(propsData[0]); break; case "prop2BlockImage": // ConfirmCtrl.Show("一位镖师能够抵消一位侠客受伤\n(观看一段视频可以雇佣1-2位)", () => { // if (propsData[1].Num >= propsData[1].Max) // { // AlertCtrl.Show(string.Format("最多只能雇佣{0}个镖师", propsData[1].Max)); // return; // } // int randomNum = UnityEngine.Random.Range(1, 3); // Messenger.Broadcast<PropType, int>(NotifyTypes.AddProp, PropType.Bodyguard, randomNum); // AlertCtrl.Show(string.Format("雇佣了{0}个镖师", randomNum)); // }, null, "观看", "不了"); PropsMallPanelCtrl.Show(propsData[1]); break; case "prop3BlockImage": // ConfirmCtrl.Show("石灰粉有50%概率能脱离战斗\n(观看一段视频可以获得1-2包)", () => { // if (propsData[2].Num >= propsData[2].Max) // { // AlertCtrl.Show(string.Format("最多只能携带{0}包石灰粉", propsData[2].Max)); // return; // } // int randomNum = UnityEngine.Random.Range(1, 3); // Messenger.Broadcast<PropType, int>(NotifyTypes.AddProp, PropType.LimePowder, randomNum); // AlertCtrl.Show(string.Format("获得了{0}包石灰粉", randomNum)); // }, null, "观看", "不了"); PropsMallPanelCtrl.Show(propsData[2]); break; case "prop4BlockImage": // ConfirmCtrl.Show("探子可以追踪未知的任务目标\n(观看一段视频可以获得1-2个)", () => { // if (propsData[3].Num >= propsData[3].Max) // { // AlertCtrl.Show(string.Format("最多只能拥有{0}个探子", propsData[3].Max)); // return; // } // int randomNum = UnityEngine.Random.Range(1, 3); // Messenger.Broadcast<PropType, int>(NotifyTypes.AddProp, PropType.Scout, randomNum); // AlertCtrl.Show(string.Format("获得了{0}个探子", randomNum)); // }, null, "观看", "不了"); PropsMallPanelCtrl.Show(propsData[3]); break; default: break; } }
public void RefreshView() { IconImage.sprite = Statics.GetIconSprite(dropData.Item.IconId); NameText.text = string.Format("<color=\"#1ABDE6\">{0}</color>", dropData.Item.Name); NumText.text = string.Format("<color=\"#00FF00\">+ {0}</color>", dropData.Item.Num); }
/// <summary> /// Scenes the notify init. /// </summary> public static void AreaNotifyInit() { Messenger.AddListener <AreaTarget, AreaMain>(NotifyTypes.AreaInit, (target, main) => { AreaModel.CurrentTarget = target; AreaModel.AreaMainScript = main; //加载动态事件列表 Messenger.Broadcast <string>(NotifyTypes.GetActiveEventsInArea, UserModel.CurrentUserData.CurrentAreaSceneName); //打开大地图UI交互界面 Messenger.Broadcast(NotifyTypes.CallAreaMainPanelData); //如果当前所处的位置是城镇,则进入城镇 if (UserModel.CurrentUserData.PositionStatu == UserPositionStatusType.InCity) { Messenger.Broadcast <string>(NotifyTypes.EnterCityScene, UserModel.CurrentUserData.CurrentCitySceneId); } }); Messenger.AddListener(NotifyTypes.AreaDestroyed, () => { if (AreaModel.CurrentTarget != null && AreaModel.CurrentTarget.gameObject != null) { MonoBehaviour.Destroy(AreaModel.CurrentTarget.gameObject); AreaModel.CurrentTarget = null; } Messenger.Broadcast(NotifyTypes.HideAreaMainPanel); }); Messenger.AddListener(NotifyTypes.CallAreaMainPanelData, () => { Messenger.Broadcast <System.Action <UserData> >(NotifyTypes.CallUserData, (userData) => { Messenger.Broadcast <JArray>(NotifyTypes.CallAreaMainPanelDataEcho, new JArray(userData.AreaFood.IconId, userData.AreaFood.Num, userData.AreaFood.MaxNum, userData.CurrentAreaSceneName)); Vector2 pos = new Vector2(userData.CurrentAreaX, userData.CurrentAreaY); Messenger.Broadcast <Vector2, bool>(NotifyTypes.SetAreaPosition, pos, false); }); }); Messenger.AddListener <JArray>(NotifyTypes.CallAreaMainPanelDataEcho, (data) => { AreaMainPanelCtrl.Show(data); Messenger.Broadcast(NotifyTypes.MakeUpdateProps); }); Messenger.AddListener(NotifyTypes.MakeUpdateProps, () => { AreaMainPanelCtrl.MakeUpdateProps(DbManager.Instance.GetAllProps()); }); Messenger.AddListener <PropType, int>(NotifyTypes.AddProp, (type, num) => { DbManager.Instance.AddProp(type, num); Messenger.Broadcast(NotifyTypes.MakeUpdateProps); }); Messenger.AddListener <PropType, int>(NotifyTypes.UseProp, (type, num) => { DbManager.Instance.UseProp(type, num); }); Messenger.AddListener(NotifyTypes.HideAreaMainPanel, () => { AreaMainPanelCtrl.Hide(); }); Messenger.AddListener <string, bool>(NotifyTypes.MoveOnArea, (direction, duringMove) => { //如果触发战斗则禁止移动 if (BattleFightPanelCtrl.Ctrl != null || !AreaModel.CurrentTarget.CanTriggerEvent()) { return; } //移动前先判断移动目的地是否有战斗 Vector2 nextMovePosition = AreaModel.CurrentTarget.GetNextMovePosition(direction); //判断前方是否是障碍 tk2dRuntime.TileMap.TileInfo groundTile = AreaModel.CurrentTarget.GetTileInfo((int)nextMovePosition.x, (int)nextMovePosition.y, 0); //判断禁止通过的碰撞区域 if (groundTile == null || groundTile.stringVal == "obstacle") { Statics.CreatePopMsg(Vector3.zero, "撞到墙上了,请绕行", Color.white, 30); return; } string fightEventId = string.Format("{0}_{1}_{2}", UserModel.CurrentUserData.CurrentAreaSceneName, (int)nextMovePosition.x, (int)nextMovePosition.y); EventData data; if (AreaMain.ActiveAreaEventsMapping.ContainsKey(fightEventId)) { data = AreaMain.ActiveAreaEventsMapping[fightEventId]; if (data.Type == SceneEventType.Battle) { ConfirmCtrl.Show("前方将有恶战,是否继续?", () => { Messenger.Broadcast <string>(NotifyTypes.CreateBattle, data.EventId); }, null, "动手", "撤退"); return; } } else if (AreaMain.StaticAreaEventsMapping.ContainsKey(fightEventId)) { //判断静态事件是否禁用 if (!AreaMain.DisableEventIdMapping.ContainsKey(fightEventId)) { data = AreaMain.StaticAreaEventsMapping[fightEventId]; if (data.Type == SceneEventType.Battle) { ConfirmCtrl.Show("前方将有恶战,是否继续?", () => { Messenger.Broadcast <string>(NotifyTypes.CreateBattle, data.EventId); //处理静态事件的预禁用操作 EventData disableEvent = new EventData(); disableEvent.Id = fightEventId; disableEvent.Type = SceneEventType.DisableEvent; disableEvent.X = (int)nextMovePosition.x; disableEvent.Y = (int)nextMovePosition.y; Messenger.Broadcast <EventData>(NotifyTypes.HandleDisableEvent, disableEvent); }, null, "动手", "撤退"); return; } if (data.Type == SceneEventType.Pagoda) { ConfirmCtrl.Show("前方有守卫,是否继续?", () => { string eventId = data.EventId; if (eventId == "10310020") { //处理金兀术难度选择后战斗id的变化 int difficulty = PlayerPrefs.GetInt("TowerDifficulty"); switch (difficulty) { case 1: eventId = "10310021"; break; case 2: eventId = "10310022"; break; default: break; } } Messenger.Broadcast <string>(NotifyTypes.CreateBattle, eventId); //处理静态事件的预禁用操作 EventData disableEvent = new EventData(); disableEvent.Id = fightEventId; disableEvent.EventId = eventId; disableEvent.Type = SceneEventType.DisablePagoda; disableEvent.X = (int)nextMovePosition.x; disableEvent.Y = (int)nextMovePosition.y; Messenger.Broadcast <EventData>(NotifyTypes.HandleDisableEvent, disableEvent); }, null, "动手", "撤退"); return; } else if (data.OpenType != SceneEventOpenType.None) { //静态事件有一个开启判定类型 switch (data.OpenType) { case SceneEventOpenType.FightWined: if (!DbManager.Instance.IsFightWined(data.OpenKey)) { ConfirmCtrl.Show(string.Format("前方有强敌守卫,是否硬闯?{0}", data.Notice), () => { Messenger.Broadcast <string>(NotifyTypes.CreateBattle, data.OpenKey); }, null, "动手", "撤退"); return; } break; case SceneEventOpenType.NeedItem: if (DbManager.Instance.GetUsedItemNumByItemId(data.OpenKey) <= 0) { ItemData item = JsonManager.GetInstance().GetMapping <ItemData>("ItemDatas", data.OpenKey); if (DbManager.Instance.GetItemNumByItemId(data.OpenKey) > 0) { ConfirmCtrl.Show(string.Format("需要交出 <color=\"#1ABDE6\">{0}</color> 才能通过", item.Name), () => { if (DbManager.Instance.CostItemFromBag(data.OpenKey, 1)) { DbManager.Instance.UpdateUsedItemRecords(data.OpenKey, 1); AlertCtrl.Show(string.Format("交出了 <color=\"#1ABDE6\">{0}</color>", item.Name)); } }, null, "给", "不给"); } else { AlertCtrl.Show(string.Format("行囊里没有<color=\"#1ABDE6\">{0}</color>,不能过去!{1}", item.Name, data.Notice)); } return; } break; case SceneEventOpenType.NeedTasks: if (!string.IsNullOrEmpty(data.StringValue)) { string[] taskIds = data.StringValue.Split(new char[] { '|' }); if (!DbManager.Instance.HasAnyTask(taskIds)) { AlertCtrl.Show(string.Format("前方暂时无法通过!\n<color=\"#00FF00\">{0}</color>", data.Notice)); return; } } break; default: break; } } } } //判定体力是否足够移动 DbManager.Instance.MoveOnArea(direction, duringMove); // Messenger.Broadcast<string, int, bool>(NotifyTypes.MoveOnAreaEcho, direction, 666, duringMove); }); Messenger.AddListener <string, int, bool>(NotifyTypes.MoveOnAreaEcho, (direction, foodsNum, duringMove) => { if (foodsNum > 0) { AreaMainPanelCtrl.MakeArrowShow(direction, foodsNum); Vector2 pos = AreaModel.CurrentTarget.Move(direction, foodsNum > 0, duringMove); AreaMainPanelCtrl.MakeSetPosition(pos); } else { if (UserModel.CurrentRebornTimes >= UserModel.MaxRebornTimes) { AlertCtrl.Show("干粮耗尽, 先回城镇休整", () => { Messenger.Broadcast(NotifyTypes.BackToCity); }); } else { // ConfirmCtrl.Show(string.Format("干粮耗尽,您愿意观看一段视频获得{0}点体力吗?\n(复活次数:{1}/{2})", UserModel.CurrentFoodNums / 2, UserModel.MaxRebornTimes - UserModel.CurrentRebornTimes, UserModel.MaxRebornTimes), () => { // MaiHandler.StartRewardedVideo(() => { // UserModel.CurrentFoodNums = UserModel.CurrentFoodNums / 2; // UserModel.CurrentRebornTimes++; // Messenger.Broadcast<int>(NotifyTypes.EatFood, UserModel.CurrentFoodNums); // }); // MaiHandler.SendEvent("StartRewardedVideoForFoods", DbManager.Instance.HostData.Lv.ToString()); // }, () => { // Messenger.Broadcast(NotifyTypes.BackToCity); // }, "观看", "不了"); ConfirmCtrl.Show(string.Format("干粮耗尽,您愿意花费5000两银子获得{0}点体力吗?\n(复活次数:{1}/{2})", UserModel.CurrentFoodNums / 2, UserModel.MaxRebornTimes - UserModel.CurrentRebornTimes, UserModel.MaxRebornTimes), () => { if (DbManager.Instance.CostSilver(5000)) { UserModel.CurrentFoodNums = UserModel.CurrentFoodNums / 2; UserModel.CurrentRebornTimes++; Messenger.Broadcast <int>(NotifyTypes.EatFood, UserModel.CurrentFoodNums); } else { AlertCtrl.Show("银两不足, 先回城镇休整", () => { Messenger.Broadcast(NotifyTypes.BackToCity); }); } MaiHandler.SendEvent("StartRewardedVideoForFoods", DbManager.Instance.HostData.Lv.ToString()); }, () => { Messenger.Broadcast(NotifyTypes.BackToCity); }, "花钱", "不了"); } BattleFightPanelCtrl.Hide(); //强制退出战斗 } }); Messenger.AddListener <Vector2, bool>(NotifyTypes.SetAreaPosition, (pos, doEvent) => { AreaMainPanelCtrl.MakeSetPosition(pos); if (AreaModel.AreaMainScript != null) { AreaModel.AreaMainScript.SetPosition(pos, doEvent); } }); Messenger.AddListener <string>(NotifyTypes.GetActiveEventsInArea, (sceneId) => { DbManager.Instance.GetActiveEventsInArea(sceneId); }); Messenger.AddListener <List <EventData> >(NotifyTypes.GetActiveEventsInAreaEcho, (events) => { if (AreaModel.AreaMainScript != null) { AreaModel.AreaMainScript.UpdateActiveAreaEventsData(events); AreaModel.AreaMainScript.RefreshActiveAreaEventsView(); } }); Messenger.AddListener <EventData>(NotifyTypes.HandleDisableEvent, (ev) => { if (AreaModel.AreaMainScript != null) { AreaModel.AreaMainScript.HandleDisableEvent(ev); } }); Messenger.AddListener <bool>(NotifyTypes.ReleaseDisableEvent, (win) => { if (AreaModel.AreaMainScript != null) { AreaModel.AreaMainScript.ReleaseDisableEvent(win); } }); Messenger.AddListener <string, EventData>(NotifyTypes.PushDisableEvent, (eventId, eventData) => { if (AreaModel.AreaMainScript != null) { AreaModel.AreaMainScript.PushDisableEvent(eventId, eventData); } }); Messenger.AddListener <List <SceneEventType> >(NotifyTypes.ClearDisableEventIdMapping, (excepts) => { if (AreaModel.AreaMainScript != null) { AreaModel.AreaMainScript.ClearDisableEventIdMapping(excepts); } }); Messenger.AddListener <int>(NotifyTypes.EatFood, (num) => { int eatNum = DbManager.Instance.EatFood(num); AlertCtrl.Show(string.Format("打开包袱发现<color=\"#00FF00\">{0}个干粮</color>{1}", num, eatNum != num ? "\n你的行囊只装得下<color=\"#FF0000\">" + eatNum + "个</color>" : "")); }); }
/// <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> /// 将Image变灰 /// </summary> /// <param name="img">Image.</param> public void MakeImageGrey(Image img) { img.material = Statics.GetMaterial("UIDefaultGreyMaterialImage"); }
void onClick(GameObject e) { if (!e.GetComponent <Button>().enabled) { return; } switch (e.name) { case "MakeBtn": if (bookData.Occupation == OccupationType.None || bookData.Occupation == hostRoleData.Occupation) { if (bookData.State == BookStateType.Unread) { ConfirmCtrl.Show(string.Format("是否将{0}拼合成<color=\"{1}\">{2}</color>进行研读?", costStr, Statics.GetQualityColorString(bookData.Quality), bookData.Name), () => { Messenger.Broadcast <int>(NotifyTypes.ReadBook, bookData.PrimaryKeyId); }); } else { AlertCtrl.Show(string.Format("<color=\"{0}\">{1}</color>已经研读过", Statics.GetQualityColorString(bookData.Quality), bookData.Name), null); } } else { AlertCtrl.Show(string.Format("非{0}弟子不得研习<color=\"{1}\">{2}</color>!", Statics.GetOccupationName(bookData.Occupation), Statics.GetQualityColorString(bookData.Quality), bookData.Name)); } break; case "Btn": Messenger.Broadcast <BookData>(NotifyTypes.ShowBookDetailPanel, bookData); break; default: break; } viewedNewFlag(); }
/// <summary> /// 检测任务对话状态(任务对话的进度在这里来更新, 每次验证任务对话类型,然后判断是否可以完成,如果可以完成则CurrentDialogIndex+1) /// </summary> /// <param name="taskId">Task identifier.</param> /// <param name="auto">If set to <c>true</c> auto.</param> /// <param name="selectedNo">If set to <c>true</c> selected no.</param> public void CheckTaskDialog(string taskId, bool auto = false, bool selectedNo = false) { TaskData data = getTask(taskId); if (data != null) { if (data.State == TaskStateType.Completed) { // db.CloseSqlConnection(); return; } string triggerNewBackTaskDataId = ""; TaskDialogType dialogType = data.GetCurrentDialog().Type; bool canModify = false; JArray pushData = new JArray(); TaskDialogData dialog = data.GetCurrentDialog(); data.State = TaskStateType.Accepted; if (data.GetCurrentDialogStatus() == TaskDialogStatusType.Initial) { if (dialogType == TaskDialogType.JustTalk || dialogType == TaskDialogType.Notice) { //交谈步骤和信息显示步骤直接变为已读状态 data.SetCurrentDialogStatus(TaskDialogStatusType.ReadYes); } else { //其他状态的话需要等待下一个步骤提交时检测是否可以完成,所以先HoldOn data.SetCurrentDialogStatus(TaskDialogStatusType.HoldOn); bool loadEvents = false; //如果是动态战斗事件步骤需要在这里创建动态战斗事件 if (dialogType == TaskDialogType.EventFightWined) { // Debug.LogWarning("如果是动态战斗事件步骤需要在这里创建动态战斗事件"); //创建一个区域大地图的战斗事件 CreateNewEvent(SceneEventType.Battle, dialog.StringValue, UserModel.CurrentUserData.CurrentAreaSceneName); loadEvents = true; } //如果是区域大地图野外任务事件步骤需要在这里创建动态任务事件 if (dialogType == TaskDialogType.CreateTaskIsBindedWithEvent) { // Debug.LogWarning("如果是区域大地图野外任务事件步骤需要在这里创建动态任务事件"); //创建一个区域大地图的战斗事件 AddNewTask(dialog.StringValue); CreateNewEvent(SceneEventType.Task, dialog.StringValue, UserModel.CurrentUserData.CurrentAreaSceneName); loadEvents = true; } if (loadEvents) { //加载动态事件列表 Messenger.Broadcast <string>(NotifyTypes.GetActiveEventsInArea, UserModel.CurrentUserData.CurrentAreaSceneName); } } dialog = data.GetCurrentDialog(); pushData.Add(new JArray(dialog.Index.ToString(), dialog.Type, dialog.TalkMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue)); canModify = true; } else { RoleData hostRole; switch (dialogType) { case TaskDialogType.Choice: if (!auto) { triggerNewBackTaskDataId = selectedNo ? data.GetCurrentDialog().BackNoTaskDataId : data.GetCurrentDialog().BackYesTaskDataId; data.SetCurrentDialogStatus(selectedNo ? TaskDialogStatusType.ReadNo : TaskDialogStatusType.ReadYes); //输出步骤执行结果信息 pushData.Add(new JArray(dialog.Index.ToString() + "_0", TaskDialogType.Notice, data.GetCurrentDialogStatus() == TaskDialogStatusType.ReadYes ? dialog.YesMsg : dialog.NoMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue)); canModify = true; } break; case TaskDialogType.ConvoyNpc: //暂时没考虑好怎么做护送npc任务 data.SetCurrentDialogStatus(TaskDialogStatusType.ReadYes); pushData.Add(new JArray(dialog.Index.ToString() + "_0", TaskDialogType.Notice, dialog.YesMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue)); canModify = true; break; case TaskDialogType.FightWined: case TaskDialogType.EventFightWined: if (IsFightWined(dialog.StringValue)) { data.SetCurrentDialogStatus(TaskDialogStatusType.ReadYes); pushData.Add(new JArray(dialog.Index.ToString() + "_0", TaskDialogType.Notice, dialog.YesMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue)); canModify = true; } break; case TaskDialogType.JustTalk: case TaskDialogType.Notice: canModify = true; break; case TaskDialogType.RecruitedThePartner: if (GetRoleDataByRoleId(dialog.StringValue) != null) { data.SetCurrentDialogStatus(TaskDialogStatusType.ReadYes); pushData.Add(new JArray(dialog.Index.ToString() + "_0", TaskDialogType.Notice, dialog.YesMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue)); canModify = true; } break; case TaskDialogType.SendItem: if (CostItemFromBag(dialog.StringValue, dialog.IntValue)) { DbManager.Instance.UpdateUsedItemRecords(dialog.StringValue, dialog.IntValue); data.SetCurrentDialogStatus(TaskDialogStatusType.ReadYes); pushData.Add(new JArray(dialog.Index.ToString() + "_0", TaskDialogType.Notice, dialog.YesMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue)); canModify = true; } break; case TaskDialogType.UsedTheBook: hostRole = GetHostRoleData(); if (hostRole != null) { for (int i = 0; i < hostRole.ResourceBookDataIds.Count; i++) { if (hostRole.ResourceBookDataIds[i] == dialog.StringValue) { data.SetCurrentDialogStatus(TaskDialogStatusType.ReadYes); pushData.Add(new JArray(dialog.Index.ToString() + "_0", TaskDialogType.Notice, dialog.YesMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue)); canModify = true; break; } } } break; case TaskDialogType.UsedTheSkillOneTime: if (GetUsedTheSkillTimes(dialog.StringValue) > 0) { data.SetCurrentDialogStatus(TaskDialogStatusType.ReadYes); pushData.Add(new JArray(dialog.Index.ToString() + "_0", TaskDialogType.Notice, dialog.YesMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue)); canModify = true; } break; case TaskDialogType.UsedTheWeapon: hostRole = GetHostRoleData(); if (hostRole.ResourceWeaponDataId == dialog.StringValue) { data.SetCurrentDialogStatus(TaskDialogStatusType.ReadYes); pushData.Add(new JArray(dialog.Index.ToString() + "_0", TaskDialogType.Notice, dialog.YesMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue)); canModify = true; } break; case TaskDialogType.WeaponPowerPlusSuccessed: if (GetWeaponPowerPlusSuccessedTimes(dialog.IntValue) > 0) { data.SetCurrentDialogStatus(TaskDialogStatusType.ReadYes); pushData.Add(new JArray(dialog.Index.ToString() + "_0", TaskDialogType.Notice, dialog.YesMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue)); canModify = true; } break; case TaskDialogType.SendResource: // if (CostResource((ResourceType)Enum.Parse(typeof(ResourceType), dialog.StringValue), dialog.IntValue)) { if (GetResourceNum((ResourceType)Enum.Parse(typeof(ResourceType), dialog.StringValue)) >= dialog.IntValue) { data.SetCurrentDialogStatus(TaskDialogStatusType.ReadYes); pushData.Add(new JArray(dialog.Index.ToString() + "_0", TaskDialogType.Notice, dialog.YesMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue)); canModify = true; } break; case TaskDialogType.TheHour: if (FramePanelCtrl.CurrentTimeIndex == dialog.IntValue) { data.SetCurrentDialogStatus(TaskDialogStatusType.ReadYes); pushData.Add(new JArray(dialog.Index.ToString() + "_0", TaskDialogType.Notice, dialog.YesMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue)); canModify = true; } break; case TaskDialogType.PushRoleToWinshop: PushNewRoleToWinShop(dialog.StringValue); data.SetCurrentDialogStatus(TaskDialogStatusType.ReadYes); pushData.Add(new JArray(dialog.Index.ToString() + "_0", TaskDialogType.Notice, dialog.YesMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue)); canModify = true; break; case TaskDialogType.CreateTaskIsBindedWithEvent: if (IsTaskCompleted(dialog.StringValue)) { data.SetCurrentDialogStatus(TaskDialogStatusType.ReadYes); pushData.Add(new JArray(dialog.Index.ToString() + "_0", TaskDialogType.Notice, dialog.YesMsg, (short)data.GetCurrentDialogStatus(), dialog.IconId, dialog.StringValue)); canModify = true; } break; default: break; } if (canModify && data.CheckCompleted()) { data.State = TaskStateType.Completed; } } TaskStateType currentState = data.State; if (canModify) { db = OpenDb(); //如果是可循环的任务这里需要置为可接受,否则置为已完成 if (data.State == TaskStateType.Completed && data.CanRepeat) { data.State = TaskStateType.CanAccept; for (int a = 0; a < data.ProgressData.Count; a++) { data.ProgressData[a] = (short)TaskDialogStatusType.Initial; } data.SetCurrentDialogIndex(0); } //update data db.ExecuteQuery("update TasksTable set ProgressData = '" + data.ProgressData.ToString() + "', CurrentDialogIndex = " + data.CurrentDialogIndex + ", State = " + ((int)data.State) + " where TaskId ='" + taskId + "' and BelongToRoleId = '" + currentRoleId + "'"); db.CloseSqlConnection(); int index = taskListData.FindIndex(item => item.Id == taskId); //update cache if (taskListData.Count > index) { taskListData[index] = data; } } //触发新任务 if (triggerNewBackTaskDataId != "" && triggerNewBackTaskDataId != "0") { AddNewTaskExceptType(triggerNewBackTaskDataId, TaskType.IsBindedWithEvent); //检测任务状态 checkAddedTasksStatus(); } if (currentState == TaskStateType.Completed) { //添加任务奖励物品 //查询背包是否已满 bool enoughBagSeat = false; // int hasNum = GetItemNumLeftInBag(); //还剩余的背包位子 // if (hasNum > 0) { // enoughBagSeat = true; // } //任务掉落的物品没有背包限制 List <DropData> drops = PushItemToBag(data.Rewards, true); if (drops.Count > 0) { Messenger.Broadcast <List <DropData> >(NotifyTypes.ShowDropsListPanel, drops); } //如果是就职任务则提示就职成功 if (data.IsInaugurationTask) { HostData = GetHostRoleData(); if (HostData.Occupation == OccupationType.None) { //加入门派 HostData.Occupation = data.InaugurationOccupation; HostData.Disposed(); db = OpenDb(); db.ExecuteQuery("update RolesTable set RoleData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(HostData)) + "' where Id = " + HostData.PrimaryKeyId); //判断兵器是否属于本门派 WeaponData currentWeapon = JsonManager.GetInstance().GetMapping <WeaponData>("Weapons", HostData.ResourceWeaponDataId); if (currentWeapon.Occupation != OccupationType.None && currentWeapon.Occupation != HostData.Occupation) { SqliteDataReader sqReader = db.ExecuteQuery("select * from WeaponsTable where BeUsingByRoleId = '" + currentRoleId + "' and BelongToRoleId ='" + currentRoleId + "'"); while (sqReader.Read()) { //将兵器先卸下 int dataId = sqReader.GetInt32(sqReader.GetOrdinal("Id")); db.ExecuteQuery("update WeaponsTable set BeUsingByRoleId = '' where Id = " + dataId); } } db.CloseSqlConnection(); //检查下是否有新兵器需要 CheckNewWeaponIdsOfWorkshop(UserModel.CurrentUserData.CurrentCitySceneId); Messenger.Broadcast(NotifyTypes.MakeCheckNewFlags); //判断城镇界面的新增提示 AlertCtrl.Show(string.Format("你已成功加入{0}!", Statics.GetOccupationName(HostData.Occupation))); } else { AlertCtrl.Show("你已是有门有派之人, 不可在此另行拜师!"); } } //任务完成后出发后续任务 addChildrenTasks(data.Id); //任务完成后移除区域大地图上的任务事件 RemoveTaskEvent(data.Id); } Messenger.Broadcast <JArray>(NotifyTypes.CheckTaskDialogEcho, pushData); if (data.GetCurrentDialogStatus() == TaskDialogStatusType.ReadNo || data.GetCurrentDialogStatus() == TaskDialogStatusType.ReadYes) { data.NextDialogIndex(); } } }
void onClick(GameObject e) { if (Time.fixedTime - date <= timeout) { return; } switch (e.name) { case "SureBtn": case "Block": Back(); break; case "ResetBtn": ConfirmCtrl.Show("是否打开塔内重置机关?\n<color=\"#ff0000\">[重置后塔内守卫将会重生]</color>", () => { Messenger.Broadcast <List <SceneEventType> >(NotifyTypes.ClearDisableEventIdMapping, null); Statics.CreatePopMsg(Vector3.zero, "通天塔内守卫全部重生!", Color.red, 30); }); break; case "difficultyBtn0": if (difficultyBtns[0].enabled) { ConfirmCtrl.Show("是否激活普通强度?", () => { if (DbManager.Instance.CostSilver(10000)) { PlayerPrefs.SetInt("TowerDifficulty", 0); Messenger.Broadcast(NotifyTypes.OpenTowerGuiderPanel); Statics.CreatePopMsg(Vector3.zero, "普通的量子强度被激活", Color.white, 30); } else { AlertCtrl.Show("银子不足!"); } }); } break; case "difficultyBtn1": if (difficultyBtns[1].enabled) { ConfirmCtrl.Show("是否激活噩梦强度?\n(4倍修为)", () => { if (DbManager.Instance.CostSilver(180000)) { PlayerPrefs.SetInt("TowerDifficulty", 1); Messenger.Broadcast(NotifyTypes.OpenTowerGuiderPanel); Statics.CreatePopMsg(Vector3.zero, "噩梦的量子强度被激活", new Color(0.93f, 1, 0.33f), 30); } else { AlertCtrl.Show("银子不足!"); } }); } break; case "difficultyBtn2": if (difficultyBtns[2].enabled) { ConfirmCtrl.Show("是否激活绝望强度?\n(8倍修为)", () => { if (DbManager.Instance.CostSilver(980000)) { PlayerPrefs.SetInt("TowerDifficulty", 2); Messenger.Broadcast(NotifyTypes.OpenTowerGuiderPanel); Statics.CreatePopMsg(Vector3.zero, "绝望的量子强度被激活", new Color(0.98f, 0.26f, 0.26f), 30); } else { AlertCtrl.Show("银子不足!"); } }); } break; default: break; } }
/// <summary> /// 获取任务详情数据 /// </summary> /// <param name="taskId">Task identifier.</param> public void GetTaskDetailInfoData(string taskId) { validTaskListData(); TaskData data = getTask(taskId); if (data != null && (data.State != TaskStateType.CanNotAccept && data.State != TaskStateType.Completed)) { //就职任务执行之前判断性别 if (data.IsInaugurationTask) { RoleData hostRoleData = GetHostRoleData(); if (hostRoleData.Occupation != OccupationType.None) { AlertCtrl.Show("你已是有门有派之人, 不可在此另行拜师!"); return; } if (hostRoleData.Gender == GenderType.Male) { if (data.InaugurationOccupation == OccupationType.EMei) { AlertCtrl.Show(string.Format("{0}派向来只收女弟子,这位公子请自重", Statics.GetOccupationName(OccupationType.EMei))); return; } } else { if (data.InaugurationOccupation == OccupationType.ShaoLin) { AlertCtrl.Show("阿弥陀佛,佛门乃清净之地,这位女施主请回"); return; } } } //将任务数据转化成步骤信息发送给前端 JArray dialogDataList = new JArray(); TaskDialogData dialog; TaskDialogStatusType dialogStatus; for (int i = 0; i < data.Dialogs.Count; i++) { dialog = data.Dialogs[i]; dialogStatus = data.GetDialogStatus(i); switch (dialogStatus) { case TaskDialogStatusType.HoldOn: dialogDataList.Add(new JArray(i.ToString(), dialog.Type, dialog.TalkMsg, (short)dialogStatus, dialog.IconId, dialog.StringValue)); break; case TaskDialogStatusType.ReadYes: case TaskDialogStatusType.ReadNo: dialogDataList.Add(new JArray(i.ToString(), dialog.Type, dialog.TalkMsg, (short)dialogStatus, dialog.IconId, dialog.StringValue)); //除了谈话和提示信息类的步骤外,将完成结果返回给前端 if (dialog.Type != TaskDialogType.JustTalk && dialog.Type != TaskDialogType.Notice) { dialogDataList.Add(new JArray(i.ToString() + "_0", TaskDialogType.Notice, dialogStatus == TaskDialogStatusType.ReadYes ? dialog.YesMsg : dialog.NoMsg, (short)dialogStatus, dialog.IconId, dialog.StringValue)); } break; default: break; } } Messenger.Broadcast <JArray>(NotifyTypes.ShowTaskDetailInfoPanel, new JArray(data.Id, dialogDataList, data.HostUpgradeLv)); } }
/// <summary> /// 打造兵器 /// </summary> /// <param name="weaponId">Weapon identifier.</param> public void CreateNewWeaponOfWorkshop(string weaponId) { db = OpenDb(); WeaponData weapon = JsonManager.GetInstance().GetMapping <WeaponData>("Weapons", weaponId); List <ResourceData> needs = new List <ResourceData>(); ResourceData need; ResourceData find; for (int i = 0; i < weapon.Needs.Count; i++) { need = weapon.Needs[i]; find = needs.Find(item => item.Type == need.Type); if (find == null) { needs.Add(new ResourceData(need.Type, need.Num)); } else { find.Num += need.Num; } } SqliteDataReader sqReader = db.ExecuteQuery("select Id, ResourcesData from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'"); List <ResourceData> resources = null; int id = 0; if (sqReader.Read()) { id = sqReader.GetInt32(sqReader.GetOrdinal("Id")); string resourcesStr = sqReader.GetString(sqReader.GetOrdinal("ResourcesData")); resourcesStr = resourcesStr.IndexOf("[") == 0 ? resourcesStr : DESStatics.StringDecder(resourcesStr); resources = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(resourcesStr); } db.CloseSqlConnection(); if (resources != null) { bool canAdd = true; string msg = ""; for (int i = 0; i < needs.Count; i++) { need = needs[i]; find = resources.Find(item => item.Type == need.Type); if (find != null && find.Num >= need.Num) { find.Num -= need.Num; } else { canAdd = false; msg = string.Format("{0}不足!", Statics.GetResourceName(need.Type)); break; } } if (canAdd) { //检测添加武器 if (AddNewWeapon(weapon.Id)) { db = OpenDb(); db.ExecuteQuery("update WorkshopResourceTable set ResourcesData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(resources)) + "' where Id = " + id); db.CloseSqlConnection(); Statics.CreatePopMsg(Vector3.zero, string.Format("<color=\"{0}\">{1}</color>+1", Statics.GetQualityColorString(weapon.Quality), weapon.Name), Color.white, 30); SoundManager.GetInstance().PushSound("ui0007"); } else { AlertCtrl.Show("兵器匣已满!", null); } } else { AlertCtrl.Show(msg, null); } } }
/// <summary> /// 出售背包中的物品 /// </summary> /// <param name="ids">Identifiers.</param> public void SellItems(JArray ids) { List <ItemData> items = new List <ItemData>(); db = OpenDb(); SqliteDataReader sqReader = db.ExecuteQuery("select Id, ItemId, Num from BagTable where BelongToRoleId = '" + currentRoleId + "'"); ItemData item; //查询出背包中所有的可出售物品 while (sqReader.Read()) { item = JsonManager.GetInstance().GetMapping <ItemData>("ItemDatas", sqReader.GetString(sqReader.GetOrdinal("ItemId"))); if (item.SellPrice >= 0) { item.PrimaryKeyId = sqReader.GetInt32(sqReader.GetOrdinal("Id")); item.Num = sqReader.GetInt32(sqReader.GetOrdinal("Num")); items.Add(item); } } //检查前端传递过来的选中的物品id是否合法 int id; ItemData findItem; double addSilverNum = 0; double silverNum = 0; string queryStr = ""; for (int i = 0; i < ids.Count; i++) { id = (int)ids[i]; findItem = items.Find(find => find.PrimaryKeyId == id); if (findItem != null) { addSilverNum += findItem.SellPrice * findItem.Num; queryStr += (i > 0 ? "or " : "" + ("Id = " + id)); } } //删除选中的物品 if (queryStr != "") { db.ExecuteQuery("delete from BagTable where " + queryStr); } //添加银子到资源 sqReader = db.ExecuteQuery("select Id, ResourcesData from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'"); List <ResourceData> resources = null; if (sqReader.Read()) { resources = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(sqReader.GetString(sqReader.GetOrdinal("ResourcesData"))); //查询目前的银子余额 ResourceData resource = resources.Find(re => re.Type == ResourceType.Silver); if (resource != null) { resource.Num += addSilverNum; silverNum = resource.Num; //加钱 db.ExecuteQuery("update WorkshopResourceTable set ResourcesData = '" + JsonManager.GetInstance().SerializeObject(resources) + "' where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id"))); } } db.CloseSqlConnection(); Messenger.Broadcast <double>(NotifyTypes.SellItemsEcho, silverNum); Statics.CreatePopMsg(Vector3.zero, string.Format("{0} {1}", Statics.GetResourceName(ResourceType.Silver), "+" + addSilverNum.ToString()), Color.green, 30); }
void onClick(GameObject e) { switch (e.name) { case "RandomBtn": randomName(); break; case "CreateBtn": if (NameInputField.text.Length == 0) { AlertCtrl.Show("称谓不能为空!"); return; } if (NameInputField.text.Length > 6) { AlertCtrl.Show("称谓不能超过6个字!"); return; } ConfirmCtrl.Show(string.Format("<color=\"{0}\">{1}</color>以后就是你的称谓,确定后不可更改", Statics.GetGenderColor(genderType), NameInputField.text), () => { RoleData role = new RoleData(); role.Id = hostRoleId; role.Name = NameInputField.text; role.Gender = genderType; role.IsHost = true; // role.ResourceWeaponDataId = "1"; //默认武器是布缠手 role.Occupation = OccupationType.None; role.IconId = IconImages[iconIndex].sprite.name; role.DeadSoundId = role.Gender == GenderType.Male ? "die0003" : "die0002"; Messenger.Broadcast <RoleData>(NotifyTypes.CreateHostRole, role); }, null, "确定", "取消"); break; default: break; } }
/// <summary> /// 将背包里的辎重箱放入工坊资源中 /// </summary> public void BringResourcesToWorkshop() { db = OpenDb(); //查询背包 SqliteDataReader sqReader = db.ExecuteQuery("select * from BagTable where BelongToRoleId = '" + currentRoleId + "' and Type >= " + (int)ItemType.Wheat + " and Type <= " + (int)ItemType.DarksteelIngot); if (sqReader.HasRows) { List <ResourceType> types = new List <ResourceType>(); List <int> nums = new List <int>(); ResourceType type; while (sqReader.Read()) { type = Statics.ChangeItemTypeToResourctType((ItemType)sqReader.GetInt32(sqReader.GetOrdinal("Type"))); types.Add(type); nums.Add(sqReader.GetInt32(sqReader.GetOrdinal("Num"))); } if (types.Count > 0) { //查询出资源 sqReader = db.ExecuteQuery("select Id, ResourcesData from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'"); if (sqReader.Read()) { int resourceId = sqReader.GetInt32(sqReader.GetOrdinal("Id")); List <ResourceData> resources = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(sqReader.GetString(sqReader.GetOrdinal("ResourcesData"))); ResourceData findResource; int num; string msg = ""; for (int i = 0; i < types.Count; i++) { findResource = resources.Find(re => re.Type == types[i]); if (findResource != null) { num = nums[i]; findResource.Num += num; msg += string.Format("\n{0}+{1}", Statics.GetResourceName(types[i]), num); } else { msg += string.Format("\n<color=\"#FF0000\">工坊产力不够无力储存{0}只好丢弃</color>", Statics.GetResourceName(types[i])); } } //清空背包里的辎重箱 db.ExecuteQuery("delete from BagTable where BelongToRoleId = '" + currentRoleId + "' and Type >= " + (int)ItemType.Wheat + " and Type <= " + (int)ItemType.DarksteelIngot); //更新资源数据 db.ExecuteQuery("update WorkshopResourceTable set ResourcesData = '" + JsonManager.GetInstance().SerializeObject(resources) + "' where Id = " + resourceId); if (msg != "") { msg = "这次游历江湖带回了" + msg; Statics.CreatePopMsg(Vector3.zero, msg, Color.green, 30); } } } } db.CloseSqlConnection(); }
void onClick(GameObject e) { switch (e.name) { case "Block": Back(); break; case "lvUpgradeBtn": if (weaponData.LV >= weaponLVData.MaxLV) { AlertCtrl.Show(string.Format("<color=\"{0}\">{1}</color>强化度已到满级", Statics.GetQualityColorString(weaponData.Quality), weaponData.Name)); break; } string needMsg = ""; double needRate = DbManager.Instance.GetWeaponNeedRate(weaponData.LV + 1); for (int i = 0, len = weaponData.Needs.Count; i < len; i++) { needMsg += string.Format("{0}个{1}", weaponData.Needs[i].Num * needRate, Statics.GetEnmuDesc <ResourceType>(weaponData.Needs[i].Type)) + (i < len - 1 ? "," : ""); } ConfirmCtrl.Show(string.Format("将<color=\"{0}\">{1}</color>强化到{2}\n需要{3}\n是否立即强化兵器?", Statics.GetQualityColorString(weaponData.Quality), weaponData.Name, weaponData.LV + 1, needMsg), () => { Messenger.Broadcast <WeaponData>(NotifyTypes.WeaponLVUpgrade, weaponData); }); break; default: break; } }
/// <summary> /// 使用物品 /// </summary> /// <param name="Id">Identifier.</param> public void UseItem(int id) { db = OpenDb(); string itemId = ""; ItemType type = ItemType.None; int num = 0; SqliteDataReader sqReader = db.ExecuteQuery("select ItemId, Type, Num from BagTable where Id = " + id); if (sqReader.Read()) { itemId = sqReader.GetString(sqReader.GetOrdinal("ItemId")); type = (ItemType)sqReader.GetInt32(sqReader.GetOrdinal("Type")); num = sqReader.GetInt32(sqReader.GetOrdinal("Num")); } db.CloseSqlConnection(); if (type != ItemType.None && num > 0) { ItemData item; switch (type) { case ItemType.Food: Eat(id, num); break; case ItemType.Weapon: item = JsonManager.GetInstance().GetMapping <ItemData>("ItemDatas", itemId); if (AddNewWeapon(item.StringValue, "")) { WeaponData weapon = JsonManager.GetInstance().GetMapping <WeaponData>("Weapons", item.StringValue); Statics.CreatePopMsg(Vector3.zero, string.Format("<color=\"{0}\">{1}</color>+1", Statics.GetQualityColorString(weapon.Quality), weapon.Name), Color.white, 30); //删除兵器盒 db = OpenDb(); db.ExecuteQuery("delete from BagTable where Id = " + id); db.CloseSqlConnection(); //重新加载背包数据 GetBagPanelData(); } else { AlertCtrl.Show("兵器匣已满,请先整理兵器匣"); } break; case ItemType.Book: item = JsonManager.GetInstance().GetMapping <ItemData>("ItemDatas", itemId); BookData book = JsonManager.GetInstance().GetMapping <BookData>("Books", item.StringValue); if (AddNewBook(item.StringValue, "")) { Statics.CreatePopMsg(Vector3.zero, string.Format("<color=\"{0}\">{1}</color>+1", Statics.GetQualityColorString(book.Quality), book.Name), Color.white, 30); //删除秘籍盒 db = OpenDb(); db.ExecuteQuery("delete from BagTable where Id = " + id); db.CloseSqlConnection(); //重新加载背包数据 GetBagPanelData(); } else { AlertCtrl.Show(string.Format("你已经习得<color=\"{0}\">{1}</color>, 无需再研读", Statics.GetQualityColorString(book.Quality), book.Name)); } break; default: AlertCtrl.Show("该物品不可使用!"); break; } } }