| | |
| | | {
|
| | | public class TreasureFindHostWin : Window
|
| | | {
|
| | | [SerializeField] RectTransform m_Content;
|
| | | [SerializeField] ScrollerController reciveConditionCtrl;
|
| | | [SerializeField] Button closeBtn;
|
| | |
|
| | | [SerializeField] Button gotoBtn;
|
| | | [SerializeField] Text gotoText;
|
| | | [SerializeField] UIEffect effect;
|
| | |
| | | [SerializeField] Button treasureBtn;
|
| | | [SerializeField] Text getAwardDesText;
|
| | | [SerializeField] Text progressText;
|
| | | [SerializeField] Button leftBtn;
|
| | | [SerializeField] Button rightBtn;
|
| | | [SerializeField] List<FunctionButton> funcBtnlist = new List<FunctionButton>();
|
| | | [SerializeField] List<RedpointBehaviour> funcRedlist = new List<RedpointBehaviour>();
|
| | | [SerializeField] List<Text> funcTitlelist = new List<Text>();
|
| | | [SerializeField] FunctionButtonGroup funcBtnGroup;
|
| | |
|
| | | [SerializeField] Image treasureEffectImg1;
|
| | | [SerializeField] RawImage treasureIcon;
|
| | |
|
| | | Button closeBtn;
|
| | | Button leftBtn;
|
| | | Button rightBtn;
|
| | |
|
| | | FunctionButtonGroup funcBtnGroup;
|
| | | List<FunctionButton> funcBtnlist = new List<FunctionButton>();
|
| | | List<RedpointBehaviour> funcRedlist = new List<RedpointBehaviour>();
|
| | | List<Text> funcTitlelist = new List<Text>();
|
| | |
|
| | | TreasureFindHostModel hostModel { get { return ModelCenter.Instance.GetModel<TreasureFindHostModel>(); } }
|
| | | TreasureModel treasureModel { get { return ModelCenter.Instance.GetModel<TreasureModel>(); } }
|
| | |
|
| | |
| | | List<FindTreasureInfo> orderFindlist = new List<FindTreasureInfo>();
|
| | | List<int> treasureIdlist;
|
| | | bool isOpenFirst = true;
|
| | |
|
| | | protected override void BindController()
|
| | | {
|
| | | var oneLevelFrame = UIUtility.CreateWidget("OneLevelWin_Pattern_1", "Pivot");
|
| | | oneLevelFrame.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one);
|
| | | oneLevelFrame.transform.SetAsFirstSibling();
|
| | | var subWindowContainer = oneLevelFrame.transform.Find("Container_SubWindow");
|
| | | m_Content.SetParentEx(subWindowContainer, Vector3.zero, Quaternion.identity, Vector3.one);
|
| | |
|
| | | funcBtnGroup = this.transform.GetComponent<FunctionButtonGroup>("Pivot/Container_Functions");
|
| | | var functionContainer = funcBtnGroup.transform.Find("Content");
|
| | | for (int i = 0; i < 4; i++)
|
| | | {
|
| | | var instance = UIUtility.CreateWidget("FunctionButton_Pattern_1", StringUtility.Contact("FunctionButton_", i + 1));
|
| | | instance.transform.SetParentEx(functionContainer, Vector3.zero, Quaternion.identity, Vector3.one);
|
| | |
|
| | | var functionButton = instance.GetComponent<FunctionButton>();
|
| | | functionButton.order = i;
|
| | | functionButton.group = funcBtnGroup;
|
| | | funcBtnlist.Add(functionButton);
|
| | | funcRedlist.Add(functionButton.redpoint);
|
| | | funcTitlelist.Add(functionButton.title);
|
| | | }
|
| | |
|
| | | reciveConditionCtrl.OnRefreshCell += RefreshConditionCell;
|
| | | reciveConditionCtrl.lockType = EnhanceLockType.KeepVertical;
|
| | | }
|
| | |
|
| | | protected override void AddListeners()
|
| | | {
|
| | | leftBtn = this.GetComponent<Button>("Pivot/Container_Buttons/Btn_Left");
|
| | | rightBtn = this.GetComponent<Button>("Pivot/Container_Buttons/Btn_Right");
|
| | | closeBtn = this.GetComponent<Button>("Pivot/Container_Buttons/Btn_Close");
|
| | |
|
| | | treasureBtn.AddListener(() => { WindowJumpMgr.Instance.WindowJumpTo((JumpUIType)findInfolist[0].jumpId); });
|
| | | leftBtn.onClick.AddListener(OnClickLeftBtn);
|
| | | rightBtn.onClick.AddListener(OnClickRightBtn);
|
| | |
| | | {
|
| | | base.OnActived();
|
| | | FuncBtnUICtrl();
|
| | | if(hostModel.jumpTreasureId == 0)
|
| | | if (hostModel.jumpTreasureId == 0)
|
| | | {
|
| | | for (int i = funcBtnlist.Count - 1; i > -1; i--)
|
| | | {
|
| | | if(i < treasureIdlist.Count)
|
| | | if (i < treasureIdlist.Count)
|
| | | {
|
| | | if (funcBtnlist[i].state != TitleBtnState.Locked)
|
| | | {
|
| | |
| | | }
|
| | | else
|
| | | {
|
| | | for(int i = 0; i < treasureIdlist.Count; i++)
|
| | | for (int i = 0; i < treasureIdlist.Count; i++)
|
| | | {
|
| | | if(treasureIdlist[i] == hostModel.jumpTreasureId)
|
| | | if (treasureIdlist[i] == hostModel.jumpTreasureId)
|
| | | {
|
| | | functionOrder = i;
|
| | | hostModel.jumpTreasureId = 0;
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | funcBtnGroup.TriggerByOrder(functionOrder);
|
| | | }
|
| | |
|
| | | protected override void OnAfterOpen()
|
| | | {
|
| | | |
| | |
|
| | | }
|
| | |
|
| | | protected override void OnPreClose()
|
| | |
| | |
|
| | | private void FuncBtnUICtrl()
|
| | | {
|
| | | for(int i = 0; i < funcBtnlist.Count; i++)
|
| | | for (int i = 0; i < funcBtnlist.Count; i++)
|
| | | {
|
| | | funcBtnlist[i].RemoveAllListeners();
|
| | | if(i < treasureIdlist.Count)
|
| | | if (i < treasureIdlist.Count)
|
| | | {
|
| | | funcBtnlist[i].OnPointClickLockFunc += ClickLockBtn;
|
| | | funcBtnlist[i].enabled = true;
|
| | | funcTitlelist[i].gameObject.SetActive(true);
|
| | | funcRedlist[i].gameObject.SetActive(true);
|
| | | funcBtnlist[i].gameObject.SetActive(true);
|
| | | int treasureId = treasureIdlist[i];
|
| | | int index = i;
|
| | | TreasureConfig config = TreasureConfig.Get(treasureId);
|
| | |
| | | funcRedlist[i].redpointId = hostModel.GetTreasureCellRedIdById(treasureId);
|
| | | funcTitlelist[i].text = config.Name;
|
| | | }
|
| | | funcBtnlist[i].AddListener(() => { ClickTitleBtn(treasureId,index); });
|
| | | funcBtnlist[i].AddListener(() => { ClickTitleBtn(treasureId, index); });
|
| | |
|
| | | if( i != 0)
|
| | | if (i != 0)
|
| | | {
|
| | | int preTreasureId = treasureIdlist[i-1];
|
| | | int preTreasureId = treasureIdlist[i - 1];
|
| | | Treasure treasure = null;
|
| | | treasureModel.TryGetTreasure(preTreasureId, out treasure);
|
| | |
|
| | |
| | | {
|
| | | funcBtnlist[i].state = TitleBtnState.Locked;
|
| | | }
|
| | | else if(treasure != null && treasure.state == TreasureState.Collected)
|
| | | else if (treasure != null && treasure.state == TreasureState.Collected)
|
| | | {
|
| | | funcBtnlist[i].state = TitleBtnState.Normal;
|
| | | }
|
| | |
| | | }
|
| | | else
|
| | | {
|
| | | funcBtnlist[i].enabled = false;
|
| | | funcTitlelist[i].gameObject.SetActive(false);
|
| | | funcRedlist[i].gameObject.SetActive(false);
|
| | | funcBtnlist[i].gameObject.SetActive(false);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void ClickLockBtn(string key)
|
| | | {
|
| | | int index = int.Parse(key.Substring(key.Length - 1,1)) - 2;
|
| | | int index = int.Parse(key.Substring(key.Length - 1, 1)) - 2;
|
| | | TreasureConfig config = TreasureConfig.Get(treasureIdlist[index]);
|
| | | if(config != null)
|
| | | if (config != null)
|
| | | {
|
| | | SysNotifyMgr.Instance.ShowTip("UnLock_TreasureLimit",config.Name);
|
| | | SysNotifyMgr.Instance.ShowTip("UnLock_TreasureLimit", config.Name);
|
| | | }
|
| | | |
| | |
|
| | | }
|
| | |
|
| | | private void OnClickLeftBtn()
|
| | |
| | | funcBtnGroup.TriggerNext();
|
| | | }
|
| | |
|
| | | private void ClickTitleBtn(int treasureId,int index)
|
| | | private void ClickTitleBtn(int treasureId, int index)
|
| | | {
|
| | | if(isOpenFirst)
|
| | | if (isOpenFirst)
|
| | | {
|
| | | isOpenFirst = false;
|
| | | }
|
| | |
| | | string[] treasureEffectImgs = TreasureFindHostConfig.Get(findInfolist[0].id).EffectIconKeys;
|
| | | treasureEffectImg1.SetSprite(treasureEffectImgs[0]);
|
| | | treasureEffectImg1.SetNativeSize();
|
| | | getAwardDesText.text = Language.Get("TreasureFindHost_UnLock",config.Name);
|
| | | getAwardDesText.text = Language.Get("TreasureFindHost_UnLock", config.Name);
|
| | | int progress = 0;
|
| | | Treasure treasure = null;
|
| | | treasureModel.TryGetTreasure(selectTreasureId, out treasure);
|
| | | if (hostModel.IsReachUnlock(selectTreasureId,out progress))
|
| | | if (hostModel.IsReachUnlock(selectTreasureId, out progress))
|
| | | {
|
| | | if(!effect.IsPlaying && treasure.state != TreasureState.Collected)
|
| | | if (!effect.IsPlaying && treasure.state != TreasureState.Collected)
|
| | | {
|
| | | effect.Play();
|
| | | }
|
| | |
| | | {
|
| | | effect.Stop();
|
| | | }
|
| | | progressText.text = UIHelper.AppendColor(TextColType.Green,StringUtility.Contact("(",progress,"/",findInfolist.Count,")"), true);
|
| | | progressText.text = UIHelper.AppendColor(TextColType.Green, StringUtility.Contact("(", progress, "/", findInfolist.Count, ")"), true);
|
| | | }
|
| | | else
|
| | | {
|
| | |
| | | {
|
| | | effect.Stop();
|
| | | }
|
| | | progressText.text = UIHelper.AppendColor(TextColType.Red, StringUtility.Contact("(",progress, "/", findInfolist.Count,")"));
|
| | | progressText.text = UIHelper.AppendColor(TextColType.Red, StringUtility.Contact("(", progress, "/", findInfolist.Count, ")"));
|
| | | }
|
| | | gotoBtn.gameObject.SetActive(true);
|
| | | if (treasure.state == TreasureState.Collected)
|
| | |
| | | gotoText.text = Language.Get("TreasureFindHost_UnLock1");
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | private void OnCompleted()
|
| | | {
|
| | | CreateConditionCell();
|
| | | int progress = 0;
|
| | | if (hostModel.IsReachUnlock(selectTreasureId,out progress))
|
| | | if (hostModel.IsReachUnlock(selectTreasureId, out progress))
|
| | | {
|
| | | SysNotifyMgr.Instance.ShowTip("TreasureFindHost2");
|
| | | }
|
| | |
| | | {
|
| | | SysNotifyMgr.Instance.ShowTip("TreasureFindHost1");
|
| | | }
|
| | | |
| | |
|
| | | }
|
| | |
|
| | | private void CreateConditionCell()
|
| | |
| | | orderFindlist.AddRange(findInfolist);
|
| | | orderFindlist.Sort(CompareByState);
|
| | | reciveConditionCtrl.Refresh();
|
| | | for(int i = 0; i < orderFindlist.Count; i++)
|
| | | for (int i = 0; i < orderFindlist.Count; i++)
|
| | | {
|
| | | reciveConditionCtrl.AddCell(ScrollerDataType.Header, orderFindlist[i].id);
|
| | | }
|
| | |
| | | reciveConditionCtrl.JumpIndex(0);
|
| | | }
|
| | |
|
| | | private int CompareByState(FindTreasureInfo start,FindTreasureInfo next)
|
| | | private int CompareByState(FindTreasureInfo start, FindTreasureInfo next)
|
| | | {
|
| | | bool x = IsReach(start);
|
| | | bool y = IsReach(next);
|