| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: 第二世界 |
| | | // [ Date ]: Tuesday, October 31, 2017 |
| | | //-------------------------------------------------------- |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | using UnityEngine.UI; |
| | | using TableConfig; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | using System.Text.RegularExpressions; |
| | | using Snxxz.UI; |
| | | //赏金任务面板 |
| | | namespace Snxxz.UI |
| | | { |
| | | |
| | | public class CoinTaskWin : MonoBehaviour |
| | | { |
| | | |
| | | [SerializeField] Text m_AwardNumbertext; |
| | | [SerializeField] Image m_Btn_Receive;//领取按钮 |
| | | [SerializeField] UIEffect m_uiEffct1;//特效播放 |
| | | [Header("滚动速度")] |
| | | public double RollingSpeed = 0.1f; |
| | | [SerializeField] Text _Text_TaskCount;//任务次数 |
| | | [SerializeField] RichText _Text_TaskTarget;//任务目标 |
| | | [SerializeField] Transform _Grid;//任务奖励 |
| | | [SerializeField] Button _Btn_Finish;//立即完成按钮 |
| | | |
| | | [SerializeField] Button _Btn_Forward;//立即前往按钮 |
| | | |
| | | [SerializeField] Button _Btn_Receive;//领取奖励按钮 |
| | | |
| | | [SerializeField] Text Text_TaskCount2;//当前总环数 |
| | | |
| | | [SerializeField] Text m_Text_Forward; |
| | | |
| | | [Header("等待时间(秒)")] |
| | | public int Second = 20; |
| | | private float timeType = 0f; |
| | | |
| | | |
| | | private List<RewardAnalysis.RewardInfo> rewardList = new List<RewardAnalysis.RewardInfo>(); |
| | | private Dictionary<int, MissionDetailDates> _BountyDic;//赏金任务 |
| | | |
| | | private Dictionary<int, int> RunTaskCnt1 = new Dictionary<int, int>();//关于跑环环数的记录1 |
| | | private Dictionary<int, int> RunTaskCnt2 = new Dictionary<int, int>();//关于跑环环数的记录2 |
| | | |
| | | private int TaskID = 0;//获取任务ID |
| | | |
| | | int Value = -1; |
| | | int Default = 0; |
| | | private float lastTime1 = 0; |
| | | private int Length = 7;//所需长度 |
| | | private int _requireNumber = 0;//直接完成所需仙玉数量 |
| | | StringBuilder theTarget = new StringBuilder();//目标值 |
| | | StringBuilder variation = new StringBuilder();//变化值 |
| | | |
| | | private int RewardForNumber = 0;//奖励数值 |
| | | PlayerTaskDatas m_TaskModel; |
| | | PlayerTaskDatas taskmodel { get { return m_TaskModel ?? (m_TaskModel = ModelCenter.Instance.GetModel<PlayerTaskDatas>()); } } |
| | | |
| | | PackModelInterface _modelInterface; |
| | | PackModelInterface modelInterface { get { return _modelInterface ?? (_modelInterface = ModelCenter.Instance.GetModel<PackModelInterface>()); } } |
| | | |
| | | ItemTipsModel _itemTipsModel; |
| | | ItemTipsModel itemTipsModel { get { return _itemTipsModel ?? (_itemTipsModel = ModelCenter.Instance.GetModel<ItemTipsModel>()); } } |
| | | |
| | | PlayerPackModel _playerPack; |
| | | PlayerPackModel playerPack { get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PlayerPackModel>()); } } |
| | | |
| | | PlayerMainDate m_MainModel; |
| | | PlayerMainDate mainModel { get { return m_MainModel ?? (m_MainModel = ModelCenter.Instance.GetModel<PlayerMainDate>()); } } |
| | | |
| | | CoinTaskTipModel m_CoinTaskTip; |
| | | CoinTaskTipModel coinTaskTip { get { return m_CoinTaskTip ?? (m_CoinTaskTip = ModelCenter.Instance.GetModel<CoinTaskTipModel>()); } } |
| | | private void Awake() |
| | | { |
| | | string _requireNumberStr = ConfigManager.Instance.GetTemplate<FuncConfigConfig>("TaskExpend").Numerical1; |
| | | var RunTaskCntStr = ConfigManager.Instance.GetTemplate<FuncConfigConfig>("RunTaskCnt"); |
| | | RunTaskCnt1 = ConfigParse.GetDic<int, int>(RunTaskCntStr.Numerical1); |
| | | RunTaskCnt2 = ConfigParse.GetDic<int, int>(RunTaskCntStr.Numerical2); |
| | | _requireNumber = int.Parse(_requireNumberStr); |
| | | } |
| | | private void Start() |
| | | { |
| | | _Btn_Finish.AddListener(Finish); |
| | | _Btn_Forward.AddListener(Forward); |
| | | _Btn_Receive.AddListener(Receive); |
| | | } |
| | | private void OnEnable() |
| | | { |
| | | lastTime1 = 0; |
| | | timeType = 0; |
| | | RewardForNumber = taskmodel.BountyRewardsNumber; |
| | | RewardFor(); |
| | | PlayerTaskDatas.Event_nBounty += OnBounty;//赏金任务添加 |
| | | PlayerTaskDatas.Event_BountyRewards += BountyRewards;//获取赏金奖励 |
| | | _BountyDic = taskmodel.BountyDic; |
| | | RewardsToOpen(); |
| | | ContentAssignment(); |
| | | int GetCylinderNumber = TaskAllocation.Instance.ForRingAllNumber();//获取赏金总环数 |
| | | if (coinTaskTip.IsPopup && GetCylinderNumber == 10) |
| | | { |
| | | m_Text_Forward.text = string.Format(Language.Get("TaskContinueCount_1"), Second); |
| | | } |
| | | else |
| | | { |
| | | m_Text_Forward.text = Language.Get("TaskBoxWin_BtnGetReward_Text_1"); |
| | | } |
| | | } |
| | | |
| | | private void OnDisable() |
| | | { |
| | | PlayerTaskDatas.Event_nBounty -= OnBounty; |
| | | PlayerTaskDatas.Event_BountyRewards -= BountyRewards; |
| | | taskmodel.BountyMotionBool = false; |
| | | if (coinTaskTip.IsPopup) |
| | | { |
| | | coinTaskTip.IsPopup = false; |
| | | } |
| | | } |
| | | |
| | | void RewardFor()//奖励默认金 |
| | | { |
| | | if (RewardForNumber != 0) |
| | | { |
| | | theTarget.Length = 0; |
| | | theTarget.Append('0', 7 - RewardForNumber.ToString().Length); |
| | | theTarget.Append(RewardForNumber); |
| | | m_AwardNumbertext.text = theTarget.ToString(); |
| | | } |
| | | else |
| | | { |
| | | m_AwardNumbertext.text = "0000000"; |
| | | } |
| | | } |
| | | |
| | | void Finish() |
| | | { |
| | | if (mainModel.IsBoolCoinTask) |
| | | { |
| | | AccomplishTask(); |
| | | } |
| | | else |
| | | { |
| | | ConfirmCancel.ToggleConfirmCancel(Language.Get("MoneyReward_Task"), Language.Get("Accomplish_Task"), Language.Get("ConfirmCancel101"), (bool isOk, bool IsToggle) => |
| | | { |
| | | if (isOk) |
| | | |
| | | { |
| | | AccomplishTask(); |
| | | } |
| | | if (IsToggle) |
| | | { |
| | | mainModel.IsBoolCoinTask = true; |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | void AccomplishTask() |
| | | { |
| | | |
| | | if ((int)UIHelper.GetMoneyCnt(1) >= _requireNumber || (int)UIHelper.GetMoneyCnt(2) >= _requireNumber) |
| | | { |
| | | taskmodel.CompletionOfTask(TaskID); |
| | | taskmodel.BountyMotionBool = true; |
| | | } |
| | | else |
| | | { |
| | | if (VersionConfig.Get().isBanShu) |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("GoldErr"); |
| | | return; |
| | | } |
| | | WindowCenter.Instance.Open<RechargeTipWin>(); |
| | | } |
| | | } |
| | | |
| | | void RewardsToOpen()//奖励按钮打开 |
| | | { |
| | | if (TaskAllocation.Instance.ForRingNumber() == RunTaskCnt2[7]) |
| | | { |
| | | |
| | | m_Btn_Receive.SetSprite("ReceiveBG_a"); |
| | | _Btn_Receive.gameObject.SetActive(true); |
| | | |
| | | } |
| | | else |
| | | { |
| | | m_Btn_Receive.SetSprite("UnReceiveBG"); |
| | | _Btn_Receive.gameObject.SetActive(false); |
| | | |
| | | } |
| | | } |
| | | void Receive()//领取奖励 |
| | | { |
| | | CA221_tagCMGetRunTaskEndAward _CA221 = new CA221_tagCMGetRunTaskEndAward(); |
| | | _CA221.Type = 7; |
| | | GameNetSystem.Instance.SendInfo(_CA221); |
| | | if (coinTaskTip.IsPopup) |
| | | { |
| | | coinTaskTip.IsPopup = false; |
| | | } |
| | | } |
| | | |
| | | |
| | | void BountyRewards(int Number, int _AwardState) |
| | | { |
| | | if (Number == 0) |
| | | { |
| | | m_AwardNumbertext.text = "0000000"; |
| | | } |
| | | else |
| | | { |
| | | if (!m_uiEffct1.IsPlaying) |
| | | { |
| | | m_uiEffct1.Play(); |
| | | } |
| | | |
| | | RewardForNumber = Number; |
| | | Value = Length - 1; |
| | | Default = 0; |
| | | int length = 0; |
| | | length = RewardForNumber.ToString().Length; |
| | | theTarget.Length = 0; |
| | | theTarget.Append('0', Length - length); |
| | | theTarget.Append(RewardForNumber); |
| | | theTarget.ToString(); |
| | | variation.Length = 0; |
| | | variation.Append('0', Length); |
| | | } |
| | | } |
| | | |
| | | private void LateUpdate() |
| | | { |
| | | if (coinTaskTip.IsPopup) |
| | | { |
| | | int GetCylinderNumber = TaskAllocation.Instance.ForRingAllNumber();//获取赏金总环数 |
| | | timeType += Time.deltaTime; |
| | | if (Second >= timeType) |
| | | { |
| | | m_Text_Forward.text = string.Format(Language.Get("TaskContinueCount_1"), Second - (int)timeType); |
| | | } |
| | | else |
| | | { |
| | | m_Text_Forward.text = string.Format(Language.Get("TaskContinueCount_1"), 0); |
| | | } |
| | | if (timeType >= Second && GetCylinderNumber == 10) |
| | | { |
| | | Receive(); |
| | | WindowCenter.Instance.Close<TaskWin>(); |
| | | WindowCenter.Instance.Open<MainInterfaceWin>(); |
| | | } |
| | | |
| | | } |
| | | |
| | | if (Value < 0) |
| | | { |
| | | return; |
| | | } |
| | | lastTime1 += Time.deltaTime; |
| | | if (lastTime1 >= RollingSpeed) |
| | | { |
| | | if (theTarget[Value] != variation[Value]) |
| | | { |
| | | Default += (int)Mathf.Pow(10, Length - 1 - Value); |
| | | variation.Length = 0; |
| | | int length = Default.ToString().Length; |
| | | variation.Append('0', Length - length); |
| | | variation.Append(Default); |
| | | variation.ToString(); |
| | | m_AwardNumbertext.text = variation.ToString(); |
| | | } |
| | | else Value--; |
| | | lastTime1 = 0; |
| | | } |
| | | } |
| | | |
| | | void Forward() |
| | | { |
| | | _Text_TaskTarget.ExcuteHref(); |
| | | WindowCenter.Instance.CloseImmediately<TaskWin>(); |
| | | WindowCenter.Instance.Open<MainInterfaceWin>(); |
| | | } |
| | | |
| | | void CompleteTaskDeletion()//删除完成的任务 |
| | | { |
| | | List<int> _ListArray = new List<int>(); |
| | | foreach (int key in _BountyDic.Keys) |
| | | { |
| | | if (_BountyDic[key].MissionState == 3 || _BountyDic[key].MissionState == 0) |
| | | _ListArray.Add(key); |
| | | } |
| | | for (int i = 0; i < _ListArray.Count; i++) |
| | | { |
| | | _BountyDic.Remove(_ListArray[i]); |
| | | } |
| | | } |
| | | |
| | | void ContentAssignment()//内容赋值 |
| | | { |
| | | int _TaskID = 2000; |
| | | CompleteTaskDeletion(); |
| | | if (taskmodel.SpecialTask.Count != 0) |
| | | { |
| | | foreach (int key in taskmodel.SpecialTask.Keys) |
| | | { |
| | | if (taskmodel.SpecialTask[key].Type == 13 && taskmodel.SpecialTask[key].MissionState != 3)//未接任务 |
| | | { |
| | | _TaskID = key; |
| | | TheDefaultTask(_TaskID); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | if (_BountyDic.Count != 0)//可接,正在进行中 |
| | | { |
| | | foreach (int key in _BountyDic.Keys) |
| | | { |
| | | _TaskID = key; |
| | | BountyMission(_TaskID); |
| | | return; |
| | | } |
| | | } |
| | | else//全部完成 |
| | | { |
| | | EndOfTheTask(); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | void BountyMission(int _TaskID)//赏金任务接取 |
| | | { |
| | | _Btn_Forward.gameObject.SetActive(true); |
| | | if (TaskAllocation.Instance.ForRingNumber() >= RunTaskCnt2[7]) |
| | | { |
| | | _Btn_Finish.gameObject.SetActive(false); |
| | | _Text_TaskCount.text = string.Format(Language.Get("NumberOfRings_Z2"), TaskAllocation.Instance.ForRingNumber(), RunTaskCnt2[7]); |
| | | _Btn_Forward.gameObject.SetActive(false); |
| | | } |
| | | else |
| | | { |
| | | _Btn_Finish.gameObject.SetActive(true); |
| | | _Text_TaskCount.text = (TaskAllocation.Instance.ForRingNumber() + 1) + "/" + RunTaskCnt2[7]; |
| | | } |
| | | Text_TaskCount2.text = TaskAllocation.Instance.ForRingAllNumber() + "/" + RunTaskCnt1[7]; |
| | | |
| | | string strINfor = _BountyDic[_TaskID].InforList; |
| | | TaskID = _TaskID; |
| | | |
| | | var taskTargetConfig = ConfigManager.Instance.GetTemplate<TASKINFOConfig>(strINfor); |
| | | string _str = TaskAllocation.Instance.GetTaskInfo(taskTargetConfig.show_writing, _TaskID); |
| | | _Text_TaskTarget.text = _str; |
| | | |
| | | var taskRewardConfig = ConfigManager.Instance.GetTemplate<TASKINFOConfig>(_BountyDic[_TaskID].RewardList); |
| | | string _RewardStr = TaskAllocation.Instance.GetTaskInfo(taskRewardConfig.show_writing, _TaskID); |
| | | |
| | | RewardAnalysis.Inst.GetReward(_RewardStr, ref rewardList); |
| | | RewardInformationDisplay(rewardList); |
| | | } |
| | | |
| | | void TheDefaultTask(int _TaskID)//赏金任务未接取特殊状态 |
| | | { |
| | | m_Btn_Receive.SetSprite("UnReceiveBG"); |
| | | _Btn_Finish.gameObject.SetActive(false); |
| | | _Btn_Forward.gameObject.SetActive(true); |
| | | _Text_TaskCount.text = Language.Get("TaskFinish"); |
| | | |
| | | Text_TaskCount2.text = TaskAllocation.Instance.ForRingAllNumber() + "/" + RunTaskCnt1[7]; |
| | | string strINfor = taskmodel.SpecialTask[_TaskID].InforList; |
| | | TaskID = _TaskID; |
| | | |
| | | var taskTargetConfig = ConfigManager.Instance.GetTemplate<TASKINFOConfig>(strINfor); |
| | | string _str = TaskAllocation.Instance.GetTaskInfo(taskTargetConfig.show_writing, _TaskID); |
| | | _Text_TaskTarget.text = _str; |
| | | |
| | | var taskRewardConfig = ConfigManager.Instance.GetTemplate<TASKINFOConfig>(taskmodel.SpecialTask[_TaskID].RewardList); |
| | | string _RewardStr = TaskAllocation.Instance.GetTaskInfo(taskRewardConfig.show_writing, _TaskID); |
| | | |
| | | RewardAnalysis.Inst.GetReward(_RewardStr, ref rewardList); |
| | | RewardInformationDisplay(rewardList); |
| | | } |
| | | |
| | | void EndOfTheTask()//任务结束状态 |
| | | { |
| | | m_Btn_Receive.SetSprite("UnReceiveBG"); |
| | | _Btn_Finish.gameObject.SetActive(false); |
| | | _Btn_Forward.gameObject.SetActive(false); |
| | | _Btn_Receive.gameObject.SetActive(false); |
| | | _Text_TaskCount.text = TaskAllocation.Instance.ForRingNumber() + "/" + RunTaskCnt2[7]; |
| | | |
| | | Text_TaskCount2.text = TaskAllocation.Instance.ForRingAllNumber() + "/" + RunTaskCnt1[7]; |
| | | |
| | | _Text_TaskTarget.text = Language.Get("CoinTaskText_1");//已完成本日所有师门悬赏任务 |
| | | |
| | | if (_Grid.childCount != 0) |
| | | { |
| | | for (int i = 0; i < _Grid.childCount; i++) |
| | | { |
| | | DestroyObject(_Grid.GetChild(i).gameObject); |
| | | } |
| | | } |
| | | } |
| | | |
| | | void OnBounty() |
| | | { |
| | | _BountyDic = taskmodel.BountyDic; |
| | | RewardsToOpen(); |
| | | ContentAssignment(); |
| | | } |
| | | |
| | | void RewardInformationDisplay(List<RewardAnalysis.RewardInfo> rewardList)//奖励信息 |
| | | { |
| | | if (_Grid.childCount != 0) |
| | | { |
| | | for (int i = 0; i < _Grid.childCount; i++) |
| | | { |
| | | DestroyObject(_Grid.GetChild(i).gameObject); |
| | | } |
| | | } |
| | | if (rewardList.Count == 0) |
| | | return; |
| | | for (int i = 0; i < rewardList.Count; i++) |
| | | { |
| | | GameObject go = GameObject.Instantiate(UILoader.LoadPrefab("ItemCell")); |
| | | ItemCell itemcell = go.GetComponent<ItemCell>(); |
| | | go.transform.SetParent(_Grid); |
| | | go.transform.localScale = Vector3.one; |
| | | Vector3 pos = go.transform.localPosition; |
| | | go.transform.localPosition = pos.SetZ(0); |
| | | Button _button = go.transform.GetComponent<Button>(); |
| | | ulong number = 0; |
| | | if (rewardList[i].expPoint != 0) |
| | | { |
| | | number = (ulong)rewardList[i].expPoint * 100000000; |
| | | number += (ulong)rewardList[i].num; |
| | | } |
| | | else |
| | | { |
| | | number = (ulong)rewardList[i].num; |
| | | } |
| | | ItemCellModel cellModel = new ItemCellModel(rewardList[i].itemCfg.ID, true, (ulong)number); |
| | | itemcell.Init(cellModel); |
| | | itemcell.cellBtn.RemoveAllListeners(); |
| | | int tab = i; |
| | | itemcell.cellBtn.AddListener(() => |
| | | { |
| | | ItemAttrData attrData = new ItemAttrData(rewardList[tab].itemCfg.ID, false, (ulong)number); |
| | | itemTipsModel.SetItemTipsModel(attrData); |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | //--------------------------------------------------------
|
| | | // [Author]: 第二世界
|
| | | // [ Date ]: Tuesday, October 31, 2017
|
| | | //--------------------------------------------------------
|
| | | using UnityEngine;
|
| | | using System.Collections;
|
| | | using UnityEngine.UI;
|
| | | using TableConfig;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | | using System.Text.RegularExpressions;
|
| | | using Snxxz.UI;
|
| | | //赏金任务面板
|
| | | namespace Snxxz.UI
|
| | | {
|
| | |
|
| | | public class CoinTaskWin : MonoBehaviour
|
| | | {
|
| | |
|
| | | [SerializeField] Text m_AwardNumbertext;
|
| | | [SerializeField] Image m_Btn_Receive;//领取按钮
|
| | | [SerializeField] UIEffect m_uiEffct1;//特效播放
|
| | | [Header("滚动速度")]
|
| | | public double RollingSpeed = 0.1f;
|
| | | [SerializeField] Text _Text_TaskCount;//任务次数
|
| | | [SerializeField] RichText _Text_TaskTarget;//任务目标
|
| | | [SerializeField] Transform _Grid;//任务奖励
|
| | | [SerializeField] Button _Btn_Finish;//立即完成按钮
|
| | |
|
| | | [SerializeField] Button _Btn_Forward;//立即前往按钮
|
| | |
|
| | | [SerializeField] Button _Btn_Receive;//领取奖励按钮
|
| | |
|
| | | [SerializeField] Text Text_TaskCount2;//当前总环数
|
| | |
|
| | | [SerializeField] Text m_Text_Forward;
|
| | |
|
| | | [Header("等待时间(秒)")]
|
| | | public int Second = 20;
|
| | | private float timeType = 0f;
|
| | |
|
| | |
|
| | | private List<RewardAnalysis.RewardInfo> rewardList = new List<RewardAnalysis.RewardInfo>();
|
| | | private Dictionary<int, MissionDetailDates> _BountyDic;//赏金任务
|
| | |
|
| | | private Dictionary<int, int> RunTaskCnt1 = new Dictionary<int, int>();//关于跑环环数的记录1
|
| | | private Dictionary<int, int> RunTaskCnt2 = new Dictionary<int, int>();//关于跑环环数的记录2
|
| | |
|
| | | private int TaskID = 0;//获取任务ID
|
| | |
|
| | | int Value = -1;
|
| | | int Default = 0;
|
| | | private float lastTime1 = 0;
|
| | | private int Length = 7;//所需长度
|
| | | private int _requireNumber = 0;//直接完成所需仙玉数量
|
| | | StringBuilder theTarget = new StringBuilder();//目标值
|
| | | StringBuilder variation = new StringBuilder();//变化值
|
| | |
|
| | | private int RewardForNumber = 0;//奖励数值
|
| | | PlayerTaskDatas m_TaskModel;
|
| | | PlayerTaskDatas taskmodel { get { return m_TaskModel ?? (m_TaskModel = ModelCenter.Instance.GetModel<PlayerTaskDatas>()); } }
|
| | |
|
| | | PackModelInterface _modelInterface;
|
| | | PackModelInterface modelInterface { get { return _modelInterface ?? (_modelInterface = ModelCenter.Instance.GetModel<PackModelInterface>()); } }
|
| | |
|
| | | ItemTipsModel _itemTipsModel;
|
| | | ItemTipsModel itemTipsModel { get { return _itemTipsModel ?? (_itemTipsModel = ModelCenter.Instance.GetModel<ItemTipsModel>()); } }
|
| | |
|
| | | PlayerPackModel _playerPack;
|
| | | PlayerPackModel playerPack { get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PlayerPackModel>()); } }
|
| | |
|
| | | PlayerMainDate m_MainModel;
|
| | | PlayerMainDate mainModel { get { return m_MainModel ?? (m_MainModel = ModelCenter.Instance.GetModel<PlayerMainDate>()); } }
|
| | |
|
| | | CoinTaskTipModel m_CoinTaskTip;
|
| | | CoinTaskTipModel coinTaskTip { get { return m_CoinTaskTip ?? (m_CoinTaskTip = ModelCenter.Instance.GetModel<CoinTaskTipModel>()); } }
|
| | | private void Awake()
|
| | | {
|
| | | string _requireNumberStr = ConfigManager.Instance.GetTemplate<FuncConfigConfig>("TaskExpend").Numerical1;
|
| | | var RunTaskCntStr = ConfigManager.Instance.GetTemplate<FuncConfigConfig>("RunTaskCnt");
|
| | | RunTaskCnt1 = ConfigParse.GetDic<int, int>(RunTaskCntStr.Numerical1);
|
| | | RunTaskCnt2 = ConfigParse.GetDic<int, int>(RunTaskCntStr.Numerical2);
|
| | | _requireNumber = int.Parse(_requireNumberStr);
|
| | | }
|
| | | private void Start()
|
| | | {
|
| | | _Btn_Finish.AddListener(Finish);
|
| | | _Btn_Forward.AddListener(Forward);
|
| | | _Btn_Receive.AddListener(Receive);
|
| | | }
|
| | | private void OnEnable()
|
| | | {
|
| | | lastTime1 = 0;
|
| | | timeType = 0;
|
| | | RewardForNumber = taskmodel.BountyRewardsNumber;
|
| | | RewardFor();
|
| | | PlayerTaskDatas.Event_nBounty += OnBounty;//赏金任务添加
|
| | | PlayerTaskDatas.Event_BountyRewards += BountyRewards;//获取赏金奖励
|
| | | _BountyDic = taskmodel.BountyDic;
|
| | | RewardsToOpen();
|
| | | ContentAssignment();
|
| | | int GetCylinderNumber = TaskAllocation.Instance.ForRingAllNumber();//获取赏金总环数
|
| | | if (coinTaskTip.IsPopup && GetCylinderNumber == 10)
|
| | | {
|
| | | m_Text_Forward.text = string.Format(Language.Get("TaskContinueCount_1"), Second);
|
| | | }
|
| | | else
|
| | | {
|
| | | m_Text_Forward.text = Language.Get("TaskBoxWin_BtnGetReward_Text_1");
|
| | | }
|
| | | }
|
| | |
|
| | | private void OnDisable()
|
| | | {
|
| | | PlayerTaskDatas.Event_nBounty -= OnBounty;
|
| | | PlayerTaskDatas.Event_BountyRewards -= BountyRewards;
|
| | | taskmodel.BountyMotionBool = false;
|
| | | if (coinTaskTip.IsPopup)
|
| | | {
|
| | | coinTaskTip.IsPopup = false;
|
| | | }
|
| | | }
|
| | |
|
| | | void RewardFor()//奖励默认金
|
| | | {
|
| | | if (RewardForNumber != 0)
|
| | | {
|
| | | theTarget.Length = 0;
|
| | | theTarget.Append('0', 7 - RewardForNumber.ToString().Length);
|
| | | theTarget.Append(RewardForNumber);
|
| | | m_AwardNumbertext.text = theTarget.ToString();
|
| | | }
|
| | | else
|
| | | {
|
| | | m_AwardNumbertext.text = "0000000";
|
| | | }
|
| | | }
|
| | |
|
| | | void Finish()
|
| | | {
|
| | | if (mainModel.IsBoolCoinTask)
|
| | | {
|
| | | AccomplishTask();
|
| | | }
|
| | | else
|
| | | {
|
| | | ConfirmCancel.ToggleConfirmCancel(Language.Get("MoneyReward_Task"), Language.Get("Accomplish_Task"), Language.Get("ConfirmCancel101"), (bool isOk, bool IsToggle) =>
|
| | | {
|
| | | if (isOk)
|
| | |
|
| | | {
|
| | | AccomplishTask();
|
| | | }
|
| | | if (IsToggle)
|
| | | {
|
| | | mainModel.IsBoolCoinTask = true;
|
| | | }
|
| | | });
|
| | | }
|
| | | }
|
| | |
|
| | | void AccomplishTask()
|
| | | {
|
| | |
|
| | | if ((int)UIHelper.GetMoneyCnt(1) >= _requireNumber || (int)UIHelper.GetMoneyCnt(2) >= _requireNumber)
|
| | | {
|
| | | taskmodel.CompletionOfTask(TaskID);
|
| | | taskmodel.BountyMotionBool = true;
|
| | | }
|
| | | else
|
| | | {
|
| | | if (VersionConfig.Get().isBanShu)
|
| | | {
|
| | | SysNotifyMgr.Instance.ShowTip("GoldErr");
|
| | | return;
|
| | | }
|
| | | WindowCenter.Instance.Open<RechargeTipWin>();
|
| | | }
|
| | | }
|
| | |
|
| | | void RewardsToOpen()//奖励按钮打开
|
| | | {
|
| | | if (TaskAllocation.Instance.ForRingNumber() == RunTaskCnt2[7])
|
| | | {
|
| | |
|
| | | m_Btn_Receive.SetSprite("ReceiveBG_a");
|
| | | _Btn_Receive.gameObject.SetActive(true);
|
| | |
|
| | | }
|
| | | else
|
| | | {
|
| | | m_Btn_Receive.SetSprite("UnReceiveBG");
|
| | | _Btn_Receive.gameObject.SetActive(false);
|
| | |
|
| | | }
|
| | | }
|
| | | void Receive()//领取奖励
|
| | | {
|
| | | CA221_tagCMGetRunTaskEndAward _CA221 = new CA221_tagCMGetRunTaskEndAward();
|
| | | _CA221.Type = 7;
|
| | | GameNetSystem.Instance.SendInfo(_CA221);
|
| | | if (coinTaskTip.IsPopup)
|
| | | {
|
| | | coinTaskTip.IsPopup = false;
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | void BountyRewards(int Number, int _AwardState)
|
| | | {
|
| | | if (Number == 0)
|
| | | {
|
| | | m_AwardNumbertext.text = "0000000";
|
| | | }
|
| | | else
|
| | | {
|
| | | if (!m_uiEffct1.IsPlaying)
|
| | | {
|
| | | m_uiEffct1.Play();
|
| | | }
|
| | |
|
| | | RewardForNumber = Number;
|
| | | Value = Length - 1;
|
| | | Default = 0;
|
| | | int length = 0;
|
| | | length = RewardForNumber.ToString().Length;
|
| | | theTarget.Length = 0;
|
| | | theTarget.Append('0', Length - length);
|
| | | theTarget.Append(RewardForNumber);
|
| | | theTarget.ToString();
|
| | | variation.Length = 0;
|
| | | variation.Append('0', Length);
|
| | | }
|
| | | }
|
| | |
|
| | | private void LateUpdate()
|
| | | {
|
| | | if (coinTaskTip.IsPopup)
|
| | | {
|
| | | int GetCylinderNumber = TaskAllocation.Instance.ForRingAllNumber();//获取赏金总环数
|
| | | timeType += Time.deltaTime;
|
| | | if (Second >= timeType)
|
| | | {
|
| | | m_Text_Forward.text = string.Format(Language.Get("TaskContinueCount_1"), Second - (int)timeType);
|
| | | }
|
| | | else
|
| | | {
|
| | | m_Text_Forward.text = string.Format(Language.Get("TaskContinueCount_1"), 0);
|
| | | }
|
| | | if (timeType >= Second && GetCylinderNumber == 10)
|
| | | {
|
| | | Receive();
|
| | | WindowCenter.Instance.Close<TaskWin>();
|
| | | WindowCenter.Instance.Open<MainInterfaceWin>();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | if (Value < 0)
|
| | | {
|
| | | return;
|
| | | }
|
| | | lastTime1 += Time.deltaTime;
|
| | | if (lastTime1 >= RollingSpeed)
|
| | | {
|
| | | if (theTarget[Value] != variation[Value])
|
| | | {
|
| | | Default += (int)Mathf.Pow(10, Length - 1 - Value);
|
| | | variation.Length = 0;
|
| | | int length = Default.ToString().Length;
|
| | | variation.Append('0', Length - length);
|
| | | variation.Append(Default);
|
| | | variation.ToString();
|
| | | m_AwardNumbertext.text = variation.ToString();
|
| | | }
|
| | | else Value--;
|
| | | lastTime1 = 0;
|
| | | }
|
| | | }
|
| | |
|
| | | void Forward()
|
| | | {
|
| | | _Text_TaskTarget.ExcuteHref();
|
| | | WindowCenter.Instance.CloseImmediately<TaskWin>();
|
| | | WindowCenter.Instance.Open<MainInterfaceWin>();
|
| | | }
|
| | |
|
| | | void CompleteTaskDeletion()//删除完成的任务
|
| | | {
|
| | | List<int> _ListArray = new List<int>();
|
| | | foreach (int key in _BountyDic.Keys)
|
| | | {
|
| | | if (_BountyDic[key].MissionState == 3 || _BountyDic[key].MissionState == 0)
|
| | | _ListArray.Add(key);
|
| | | }
|
| | | for (int i = 0; i < _ListArray.Count; i++)
|
| | | {
|
| | | _BountyDic.Remove(_ListArray[i]);
|
| | | }
|
| | | }
|
| | |
|
| | | void ContentAssignment()//内容赋值
|
| | | {
|
| | | int _TaskID = 2000;
|
| | | CompleteTaskDeletion();
|
| | | if (taskmodel.SpecialTask.Count != 0)
|
| | | {
|
| | | foreach (int key in taskmodel.SpecialTask.Keys)
|
| | | {
|
| | | if (taskmodel.SpecialTask[key].Type == 13 && taskmodel.SpecialTask[key].MissionState != 3)//未接任务
|
| | | {
|
| | | _TaskID = key;
|
| | | TheDefaultTask(_TaskID);
|
| | | return;
|
| | | }
|
| | | }
|
| | | }
|
| | | if (_BountyDic.Count != 0)//可接,正在进行中
|
| | | {
|
| | | foreach (int key in _BountyDic.Keys)
|
| | | {
|
| | | _TaskID = key;
|
| | | BountyMission(_TaskID);
|
| | | return;
|
| | | }
|
| | | }
|
| | | else//全部完成
|
| | | {
|
| | | EndOfTheTask();
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | void BountyMission(int _TaskID)//赏金任务接取
|
| | | {
|
| | | _Btn_Forward.gameObject.SetActive(true);
|
| | | if (TaskAllocation.Instance.ForRingNumber() >= RunTaskCnt2[7])
|
| | | {
|
| | | _Btn_Finish.gameObject.SetActive(false);
|
| | | _Text_TaskCount.text = string.Format(Language.Get("NumberOfRings_Z2"), TaskAllocation.Instance.ForRingNumber(), RunTaskCnt2[7]);
|
| | | _Btn_Forward.gameObject.SetActive(false);
|
| | | }
|
| | | else
|
| | | {
|
| | | _Btn_Finish.gameObject.SetActive(true);
|
| | | _Text_TaskCount.text = (TaskAllocation.Instance.ForRingNumber() + 1) + "/" + RunTaskCnt2[7];
|
| | | }
|
| | | Text_TaskCount2.text = TaskAllocation.Instance.ForRingAllNumber() + "/" + RunTaskCnt1[7];
|
| | |
|
| | | string strINfor = _BountyDic[_TaskID].InforList;
|
| | | TaskID = _TaskID;
|
| | |
|
| | | var taskTargetConfig = ConfigManager.Instance.GetTemplate<TASKINFOConfig>(strINfor);
|
| | | string _str = TaskAllocation.Instance.GetTaskInfo(taskTargetConfig.show_writing, _TaskID);
|
| | | _Text_TaskTarget.text = _str;
|
| | |
|
| | | var taskRewardConfig = ConfigManager.Instance.GetTemplate<TASKINFOConfig>(_BountyDic[_TaskID].RewardList);
|
| | | string _RewardStr = TaskAllocation.Instance.GetTaskInfo(taskRewardConfig.show_writing, _TaskID);
|
| | |
|
| | | RewardAnalysis.Inst.GetReward(_RewardStr, ref rewardList);
|
| | | RewardInformationDisplay(rewardList);
|
| | | }
|
| | |
|
| | | void TheDefaultTask(int _TaskID)//赏金任务未接取特殊状态
|
| | | {
|
| | | m_Btn_Receive.SetSprite("UnReceiveBG");
|
| | | _Btn_Finish.gameObject.SetActive(false);
|
| | | _Btn_Forward.gameObject.SetActive(true);
|
| | | _Text_TaskCount.text = Language.Get("TaskFinish");
|
| | |
|
| | | Text_TaskCount2.text = TaskAllocation.Instance.ForRingAllNumber() + "/" + RunTaskCnt1[7];
|
| | | string strINfor = taskmodel.SpecialTask[_TaskID].InforList;
|
| | | TaskID = _TaskID;
|
| | |
|
| | | var taskTargetConfig = ConfigManager.Instance.GetTemplate<TASKINFOConfig>(strINfor);
|
| | | string _str = TaskAllocation.Instance.GetTaskInfo(taskTargetConfig.show_writing, _TaskID);
|
| | | _Text_TaskTarget.text = _str;
|
| | |
|
| | | var taskRewardConfig = ConfigManager.Instance.GetTemplate<TASKINFOConfig>(taskmodel.SpecialTask[_TaskID].RewardList);
|
| | | string _RewardStr = TaskAllocation.Instance.GetTaskInfo(taskRewardConfig.show_writing, _TaskID);
|
| | |
|
| | | RewardAnalysis.Inst.GetReward(_RewardStr, ref rewardList);
|
| | | RewardInformationDisplay(rewardList);
|
| | | }
|
| | |
|
| | | void EndOfTheTask()//任务结束状态
|
| | | {
|
| | | m_Btn_Receive.SetSprite("UnReceiveBG");
|
| | | _Btn_Finish.gameObject.SetActive(false);
|
| | | _Btn_Forward.gameObject.SetActive(false);
|
| | | _Btn_Receive.gameObject.SetActive(false);
|
| | | _Text_TaskCount.text = TaskAllocation.Instance.ForRingNumber() + "/" + RunTaskCnt2[7];
|
| | |
|
| | | Text_TaskCount2.text = TaskAllocation.Instance.ForRingAllNumber() + "/" + RunTaskCnt1[7];
|
| | |
|
| | | _Text_TaskTarget.text = Language.Get("CoinTaskText_1");//已完成本日所有师门悬赏任务
|
| | |
|
| | | if (_Grid.childCount != 0)
|
| | | {
|
| | | for (int i = 0; i < _Grid.childCount; i++)
|
| | | {
|
| | | DestroyObject(_Grid.GetChild(i).gameObject);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | void OnBounty()
|
| | | {
|
| | | _BountyDic = taskmodel.BountyDic;
|
| | | RewardsToOpen();
|
| | | ContentAssignment();
|
| | | }
|
| | |
|
| | | void RewardInformationDisplay(List<RewardAnalysis.RewardInfo> rewardList)//奖励信息
|
| | | {
|
| | | if (_Grid.childCount != 0)
|
| | | {
|
| | | for (int i = 0; i < _Grid.childCount; i++)
|
| | | {
|
| | | DestroyObject(_Grid.GetChild(i).gameObject);
|
| | | }
|
| | | }
|
| | | if (rewardList.Count == 0)
|
| | | return;
|
| | | for (int i = 0; i < rewardList.Count; i++)
|
| | | {
|
| | | GameObject go = GameObject.Instantiate(UILoader.LoadPrefab("ItemCell"));
|
| | | ItemCell itemcell = go.GetComponent<ItemCell>();
|
| | | go.transform.SetParent(_Grid);
|
| | | go.transform.localScale = Vector3.one;
|
| | | Vector3 pos = go.transform.localPosition;
|
| | | go.transform.localPosition = pos.SetZ(0);
|
| | | Button _button = go.transform.GetComponent<Button>();
|
| | | ulong number = 0;
|
| | | if (rewardList[i].expPoint != 0)
|
| | | {
|
| | | number = (ulong)rewardList[i].expPoint * 100000000;
|
| | | number += (ulong)rewardList[i].num;
|
| | | }
|
| | | else
|
| | | {
|
| | | number = (ulong)rewardList[i].num;
|
| | | }
|
| | | ItemCellModel cellModel = new ItemCellModel(rewardList[i].itemCfg.ID, true, (ulong)number);
|
| | | itemcell.Init(cellModel);
|
| | | itemcell.cellBtn.RemoveAllListeners();
|
| | | int tab = i;
|
| | | itemcell.cellBtn.AddListener(() =>
|
| | | {
|
| | | ItemAttrData attrData = new ItemAttrData(rewardList[tab].itemCfg.ID, false, (ulong)number);
|
| | | itemTipsModel.SetItemTipsModel(attrData);
|
| | | });
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | |
|