//-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Sunday, December 24, 2017 //-------------------------------------------------------- using UnityEngine; using System.Collections; using UnityEngine.UI; using System.Collections.Generic; using vnxbqy.UI; using System.Text.RegularExpressions; using System; //关于飞鞋任务 namespace vnxbqy.UI { public class FlyingShoesTask : MonoBehaviour { [SerializeField] GameObject m_ImgSelected;//选中条 [SerializeField] Button m_DeliveryButton;//传送符按钮 [SerializeField] RichText m_TitleText;//标题 [SerializeField] RichText m_ContentText;//内容 [SerializeField] Button m_FlyingShoesTaskButton; [SerializeField] UIEffect m_Uieffect; [SerializeField] Transform m_parent; [SerializeField] UIEffect m_ProgressEffect; private List MainlineTaskType = new List();//主线类型 private List MainlineTaskTypekey = new List();//主线任务类型key private List SideQuestsType = new List();//支线类型 private List SideQuestsTypeKey = new List();//支线任务类型Key private List BountyMissionsType = new List();//赏金 private List BountyMissionsTypeKey = new List();//赏金任务类型key private List FairyAuMissionType = new List();//仙盟任务 private List FairyAuMissionTypeKey = new List();//仙盟任务Key private List TranscriptTask = new List();//赏金副本 private List DemonMissionTypeList = new List();//魔族 private List DemonMissionTypeListKey = new List();//魔族 private List TransportTask = new List();//在PK状态下或打Boss状态下依旧可以传送的任务id TaskModel m_TaskModel; TaskModel taskmodel { get { return m_TaskModel ?? (m_TaskModel = ModelCenter.Instance.GetModel()); } } PackModel _playerPack; PackModel playerPack { get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel()); } } PlayerMainDate m_MainModel; PlayerMainDate mainModel { get { return m_MainModel ?? (m_MainModel = ModelCenter.Instance.GetModel()); } } TreasureModel m_treasureModel; TreasureModel treasureModel { get { return m_treasureModel ?? (m_treasureModel = ModelCenter.Instance.GetModel()); } } CoinTaskTipModel m_CoinTaskTip; CoinTaskTipModel coinTaskTip { get { return m_CoinTaskTip ?? (m_CoinTaskTip = ModelCenter.Instance.GetModel()); } } private Dictionary RunTaskCnt1 = new Dictionary();//关于跑环环数的记录1 private Dictionary RunTaskCnt2 = new Dictionary();//关于跑环环数的记录2 private bool IsKaJiBool = false;//是否为卡级任务 private int Task_ID = 0;//获取任务ID private int progressRef = -1; private void Awake() { m_DeliveryButton.RemoveAllListeners(); m_DeliveryButton.AddListener(OnClickDeliveryButton); } private void OnEnable() { } private void OnDisable() { } int updateFrame = 0; private void Update() { if (updateFrame < 0) return; updateFrame++; if (updateFrame == 2) { LayoutRebuilder.ForceRebuildLayoutImmediate(m_FlyingShoesTaskButton.GetComponent()); updateFrame = -1; } } private void Start() { m_FlyingShoesTaskButton.AddListener(OnClickTaskButton); } public GameObject ImgSelected { get { return m_ImgSelected; } set { m_ImgSelected = value; } } public Button DeliveryButton { get { return m_DeliveryButton; } set { m_DeliveryButton = value; } } public RichText TitleText { get { return m_TitleText; } set { m_TitleText = value; } } public RichText ContentText { get { return m_ContentText; } set { m_ContentText = value; } } public UIEffect UIEffect { get { return m_Uieffect; } set { m_Uieffect = value; } } public Button FlyingShoesTaskButton1 { get { return m_FlyingShoesTaskButton; } set { m_FlyingShoesTaskButton = value; } } private void OnClickTaskButton() { mainModel.IsSelfMotionTask = false; for (int i = 0; i < m_parent.childCount; i++) { m_parent.GetChild(i).GetComponent().ImgSelected.SetActive(false); } m_ImgSelected.SetActive(true); taskmodel.GetNowTaskID = Task_ID; if (mainModel.WingTask == Task_ID && ((int)taskmodel.GetTaskStatus(Task_ID) == 0 || (int)taskmodel.GetTaskStatus(Task_ID) == -5))//关于特殊翅膀任务 { if (playerPack.GetSinglePack(PackType.Item) == null) { WindowCenter.Instance.Open(); return; } Dictionary BackpackDic = playerPack.GetSinglePack(PackType.Item).GetAllItems(); if (BackpackDic == null) { WindowCenter.Instance.Open(); return; } else { foreach (var key in BackpackDic.Keys) { var item = BackpackDic[key]; if (item.config.Type == 111 && item.config.ExpireTime == 0 && ItemLogicUtility.Instance.IsJobCompatibleItem(item.itemId)) { WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.KnapSackFunc1Type2);//跳到背包 return; } } } WindowCenter.Instance.Open(); return; } switch ((int)taskmodel.GetTaskStatus(Task_ID)) { case -5: case 0: if (TransportTask.Contains(Task_ID)) { } else { bool Bool = StateDetermination(); if (Bool) { ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("ZLMapQuit"), (bool isOk) => { //不传送 if (!isOk) { return; } else { if (mainModel.TaskId_Skill.Contains(Task_ID)) { mainModel.TaskSkillID = Task_ID; WindowCenter.Instance.Open(); } else { HeroAIRecorder.ClearRecord(); var rect = transform as RectTransform; var worldpos = rect.TransformPoint(Vector3.zero + Vector3.up * rect.rect.height / 2); TaskFeedbackModel.s_ClickPosition = worldpos; ContentText.ExcuteHref(); TaskAllocation.Instance.TaskTime = TimeUtility.ServerNow; OpenPanel(Task_ID); } } }); return; } } if (mainModel.TaskId_Skill.Contains(Task_ID)) { mainModel.TaskSkillID = Task_ID; WindowCenter.Instance.Open(); } else { HeroAIRecorder.ClearRecord(); var rect = transform as RectTransform; var worldpos = rect.TransformPoint(Vector3.zero + Vector3.up * rect.rect.height / 2); TaskFeedbackModel.s_ClickPosition = worldpos; ContentText.ExcuteHref(); TaskAllocation.Instance.TaskTime = TimeUtility.ServerNow; OpenPanel(Task_ID); } break; case 1: var taskPower = TaskPowerConfig.Get(Task_ID); if (taskPower != null && taskPower.FabaoID != 0) { var _treasureId = taskPower.FabaoID; var treasureConfig = TreasureConfig.Get(_treasureId); treasureModel.currentCategory = (TreasureCategory)treasureConfig.Category; WindowCenter.Instance.Close(); var _unlockTreasure = treasureModel.IsRequireUnlockAnim(treasureModel.currentCategory); if (_unlockTreasure != 0) { treasureModel.treasureGotoId = _unlockTreasure; WindowCenter.Instance.Open(true); } else { treasureModel.selectedTreasure = _treasureId; WindowCenter.Instance.Open(true); } return; } var tasklistconfig = TaskListConfig.Get(Task_ID); if (tasklistconfig != null) { var _treasureId = tasklistconfig.FabaoID; var treasureConfig = TreasureConfig.Get(_treasureId); treasureModel.currentCategory = (TreasureCategory)treasureConfig.Category; WindowCenter.Instance.Close(); var _unlockTreasure = treasureModel.IsRequireUnlockAnim(treasureModel.currentCategory); if (_unlockTreasure != 0) { treasureModel.treasureGotoId = _unlockTreasure; WindowCenter.Instance.Open(true); } else { treasureModel.selectedTreasure = _treasureId; WindowCenter.Instance.Open(true); } } break; case 2: WindowCenter.Instance.Open(); break; case 3: taskmodel.CompletionOfTask(Task_ID); if (mainModel.TaskId_Skill.Contains(Task_ID)) { WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.SkillFunc2); } break; default: break; } } List npcConfig = new List(); private bool StateDetermination()//状态判定 { bool _bool = false; DropItemManager.StopMissionPickup = true;//主动停止拾取物品 if (PlayerDatas.Instance.extersion.bossState == 1) { string strNpc = string.Empty; strNpc = ContentText.GetHrefMessage("movenpc"); int npcId = 0; int mapID = PlayerDatas.Instance.baseData.MapID; if (int.TryParse(strNpc, out npcId)) { if (npcConfig.Count <= 0) { npcConfig = mapnpcConfig.GetValues(); } // var npcConfig = mapnpcConfig.GetValues(); foreach (var value in npcConfig) { if (value.NPCID == npcId && value.MapID != mapID) { _bool = true; return _bool; } } var MonsterConfig = MonsterRefreshPointConfig.Get(npcId); if (MonsterConfig != null && MonsterConfig.MapId != mapID) { _bool = true; return _bool; } } } return _bool; } private void OnClickDeliveryButton()//传送符 { if (GA_Hero.s_Flying) { return; } //--------------特殊任务的传送逻辑 mainModel.FlyShoseTaskID = Task_ID; string _FlyID = FuncConfigConfig.Get("TransportPay").Numerical1; int itemNumber = playerPack.GetItemCountByID(PackType.Item, int.Parse(_FlyID));//获取飞鞋的数量 mainModel.IsSelfMotionTask = false; if (ModelCenter.Instance.GetModel().GetVipPrivilegeCnt(VipPrivilegeType.FreeTransfer) > 0) { HeroAIRecorder.ClearRecord(); TaskAllocation.Instance.TaskTime = TimeUtility.ServerNow; m_ContentText.ExcuteHref(1); MapTransferUtility.Instance.StopMovetoNpc(); return; } if (itemNumber > 0) { HeroAIRecorder.ClearRecord(); TaskAllocation.Instance.TaskTime = TimeUtility.ServerNow; m_ContentText.ExcuteHref(1); MapTransferUtility.Instance.StopMovetoNpc(); } else { if (mainModel.IsFlyShoseBool) { int NeedMoney = (int)UIHelper.GetMoneyCnt(2); if (NeedMoney >= GeneralDefine.flyBootItemMoney) { HeroAIRecorder.ClearRecord(); TaskAllocation.Instance.TaskTime = TimeUtility.ServerNow; m_ContentText.ExcuteHref(1); MapTransferUtility.Instance.StopMovetoNpc(); } else { SysNotifyMgr.Instance.ShowTip("GoldPaperErr"); //WindowCenter.Instance.Open(); } } else { FlyShoseConfirmwin.useEnvironment = FlyShoseConfirmwin.UseEnvironment.Task; WindowCenter.Instance.Open(); } } } public void FlyingShoes_Task(int TaskID) { Task_ID = TaskID; TypeAssignment(); for (int i = 0; i < m_parent.childCount; i++) { int taskID1 = m_parent.GetChild(i).GetComponent().TaskID; m_parent.GetChild(i).GetComponent().ImgSelected.SetActive(false); if (taskID1 == taskmodel.GetNowTaskID) { m_parent.GetChild(i).GetComponent().ImgSelected.SetActive(true); } } m_DeliveryButton.SetActive(false); if (!taskmodel.allMissionDict.ContainsKey(TaskID)) { return; } var satisfyFly = true; if (!FuncOpen.Instance.IsFuncOpen(176) || taskmodel.GetTaskStatus(TaskID) > 0) { satisfyFly = false; } if (taskmodel.allMissionDict[TaskID].MissionState == 2) { m_TitleText.text = "" + TaskTitle(TaskID) + ""; } else { m_TitleText.text = "" + TaskTitle(TaskID) + ""; } if (TranscriptTask.Contains(TaskID)) { m_TitleText.text = "" + TaskTitle(TaskID) + ""; } string str = taskmodel.allMissionDict[TaskID].InforList; var taskinfo = TASKINFOConfig.Get(str); if (taskinfo != null) { var taskPower = TaskPowerConfig.Get(TaskID); string StrText = taskinfo.show_writing; if (taskPower != null && taskPower.ISJUMP != 0) { if (PlayerDatas.Instance.baseData.FightPoint >= (ulong)taskPower.Power) { StrText = StrText.Replace("", ""); } else { StrText = StrText.Replace("", ""); } m_ContentText.text = StrText; } else { m_ContentText.text = StrText; } } else { DebugEx.LogError("任务表格PyTaskInfo配置缺失"); return; } bool isOPenTransferButton = HrefAnalysis.Inst.ContainsKey(taskinfo.show_writing, "flynpc"); if (satisfyFly && !isOPenTransferButton) { satisfyFly = false; } m_DeliveryButton.SetActive(satisfyFly); m_ContentText.raycastTarget = false; if (taskmodel._DicTaskInformation.ContainsKey(TaskID)) { Dictionary SkillDic = new Dictionary(); SkillDic = taskmodel._DicTaskInformation[TaskID]; string strA = "on_kill_" + TaskID.ToString(); string strB = "get_byid_" + TaskID.ToString(); if (SkillDic.ContainsKey(strA)) { var progress = 0; int.TryParse(SkillDic[strA], out progress); if (progressRef != -1 && progress != 0 && progressRef != progress) { m_ProgressEffect.Play(); } progressRef = progress; m_ContentText.SetReplaceInfo(SkillDic); } else if (SkillDic.ContainsKey(strB)) { var progress = 0; int.TryParse(SkillDic[strB], out progress); if (progressRef != -1 && progress != 0 && progressRef != progress) { m_ProgressEffect.Play(); } progressRef = progress; m_ContentText.SetReplaceInfo(SkillDic); } } if (taskmodel.BountyDic.ContainsKey(TaskID) || taskmodel.FairyAuDic.ContainsKey(TaskID)) { var config = TASKINFOConfig.Get(str); if (config != null) { var progress = 0; if (taskmodel.ReplaceDic.ContainsKey(TaskID) && taskmodel.ReplaceDic[TaskID].ContainsKey("kill_npc_id_cur_count")) { progress = taskmodel.ReplaceDic[TaskID]["kill_npc_id_cur_count"]; if (progressRef != -1 && progress != 0 && progressRef != progress) { m_ProgressEffect.Play(); } progressRef = progress; } string strRichA = TaskAllocation.Instance.GetTaskInfo(config.show_writing, TaskID); m_ContentText.text = strRichA; } else { DebugEx.LogError("任务表格PyTaskInfo配置缺失"); } } updateFrame = 0; } private string TaskTitle(int taskID) { var config = TASKINFOConfig.Get(taskmodel.allMissionDict[taskID].Name); if (config == null) { DebugEx.LogError("任务表格PyTaskInfo配置缺失"); return null; } string taskName = config.show_writing; if (taskmodel.allMissionDict[taskID].Type == 15) { string str = string.Format(Language.Get("Z1800"), taskName); return str; } else if (MainlineTaskType.Contains(taskmodel.allMissionDict[taskID].Type)) { int Index = MainlineTaskType.IndexOf(taskmodel.allMissionDict[taskID].Type); string str = string.Format(Language.Get(MainlineTaskTypekey[Index]), taskName); return str; } else if (taskmodel.allMissionDict[taskID].Type == 3) { string str = string.Format(Language.Get("Demon_Text"), taskName); return str; } else if (SideQuestsType.Contains(taskmodel.allMissionDict[taskID].Type)) { int Index = SideQuestsType.IndexOf(taskmodel.allMissionDict[taskID].Type); string str = string.Format(Language.Get(SideQuestsTypeKey[Index]), taskName); return str; } else if (BountyMissionsType.Contains(taskmodel.allMissionDict[taskID].Type)) { int Index = BountyMissionsType.IndexOf(taskmodel.allMissionDict[taskID].Type); int cylinderNumber = TaskAllocation.Instance.ForRingNumber() + 1; string str = string.Empty; if (cylinderNumber > RunTaskCnt2[7]) { str = string.Format(Language.Get(BountyMissionsTypeKey[Index]), taskName); } else { str = string.Format(Language.Get(BountyMissionsTypeKey[Index]), taskName) + cylinderNumber + "/" + RunTaskCnt2[7]; } return str; } else if (FairyAuMissionType.Contains(taskmodel.allMissionDict[taskID].Type)) { int Index = FairyAuMissionType.IndexOf(taskmodel.allMissionDict[taskID].Type); int cylinderNumber = TaskAllocation.Instance.FairyAuNumber() + 1; string str = string.Empty; if (cylinderNumber > RunTaskCnt2[12]) { str = string.Format(Language.Get(FairyAuMissionTypeKey[Index]), taskName); } else { str = string.Format(Language.Get(FairyAuMissionTypeKey[Index]), taskName) + cylinderNumber + "/" + RunTaskCnt2[12]; } return str; } return null; } void TypeAssignment() { if (MainlineTaskType.Count == 0) { var RunTaskCntStr = FuncConfigConfig.Get("RunTaskCnt"); RunTaskCnt1 = ConfigParse.GetDic(RunTaskCntStr.Numerical1); RunTaskCnt2 = ConfigParse.GetDic(RunTaskCntStr.Numerical2); var MainlineTaskTypeList = FuncConfigConfig.Get("MainlineTaskType"); int[] strMainlineTaskType = ConfigParse.GetMultipleStr(MainlineTaskTypeList.Numerical1);//主线 string[] strMainlineTaskType1 = ConfigParse.GetMultipleStr(MainlineTaskTypeList.Numerical2);//主线 for (int i = 0; i < strMainlineTaskType.Length; i++) { MainlineTaskType.Add(strMainlineTaskType[i]); MainlineTaskTypekey.Add(strMainlineTaskType1[i]); } var SideQuestsTypeList = FuncConfigConfig.Get("SideQuestsType"); int[] strSideQuestsType = ConfigParse.GetMultipleStr(SideQuestsTypeList.Numerical1);//支线 string[] strSideQuestsType1 = ConfigParse.GetMultipleStr(SideQuestsTypeList.Numerical2);//支线 for (int i = 0; i < strSideQuestsType.Length; i++) { SideQuestsType.Add(strSideQuestsType[i]); SideQuestsTypeKey.Add(strSideQuestsType1[i]); } var BountyMissionsTypeList = FuncConfigConfig.Get("BountyMissionsType"); int[] strBountyMissionsType = ConfigParse.GetMultipleStr(BountyMissionsTypeList.Numerical1);//赏金 string[] strBountyMissionsType1 = ConfigParse.GetMultipleStr(BountyMissionsTypeList.Numerical2);//赏金 for (int i = 0; i < strBountyMissionsType.Length; i++) { BountyMissionsType.Add(strBountyMissionsType[i]); BountyMissionsTypeKey.Add(strBountyMissionsType1[i]); } var FairyAuMissionTypeList = FuncConfigConfig.Get("FairyAuMissionType"); int[] strFairyAuMissionType = ConfigParse.GetMultipleStr(FairyAuMissionTypeList.Numerical1);//仙盟 string[] strFairyAuMissionType1 = ConfigParse.GetMultipleStr(FairyAuMissionTypeList.Numerical2);//仙盟 for (int i = 0; i < strFairyAuMissionType.Length; i++) { FairyAuMissionType.Add(strFairyAuMissionType[i]); FairyAuMissionTypeKey.Add(strFairyAuMissionType1[i]); } int[] strTranscript = ConfigParse.GetMultipleStr(FuncConfigConfig.Get("FBTaskColor").Numerical1);//赏金副本 for (int i = 0; i < strTranscript.Length; i++) { TranscriptTask.Add(strTranscript[i]); } var DemonMissionTypeList1 = FuncConfigConfig.Get("DemonMissionType"); int[] DemonMissionType = ConfigParse.GetMultipleStr(DemonMissionTypeList1.Numerical1);//魔族法宝 string[] DemonMissionType1 = ConfigParse.GetMultipleStr(DemonMissionTypeList1.Numerical2);//魔族法宝 for (int i = 0; i < DemonMissionType.Length; i++) { DemonMissionTypeList.Add(DemonMissionType[i]); DemonMissionTypeListKey.Add(DemonMissionType1[i]); } var TransportTaskConfig = FuncConfigConfig.Get("TransportTask").Numerical1; int[] TransportTaskList = ConfigParse.GetMultipleStr(TransportTaskConfig); TransportTask.Clear(); for (int i = 0; i < TransportTaskList.Length; i++) { TransportTask.Add(TransportTaskList[i]); } } } void OpenPanel(int _taskID)//赏金面板 { if (taskmodel.BountyDic.ContainsKey(_taskID)) { int bountyNumber = TaskAllocation.Instance.ForRingNumber(); if (bountyNumber == 10 && !WindowCenter.Instance.IsOpen()) { if (coinTaskTip.IsPopup) { coinTaskTip.IsPopup = false; } WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.BountyInterface); } } if (taskmodel.FairyAuDic.ContainsKey(_taskID)) { int FairyNumber = TaskAllocation.Instance.FairyAuNumber(); if (FairyNumber == 10) { WindowCenter.Instance.Close(); WindowCenter.Instance.Open(); } } } } }