123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- using UI.FieldGuide;
- using FairyGUI;
- using UnityEngine;
- using System.Collections.Generic;
- namespace GFGGame
- {
- public class SuitShowView : BaseWindow
- {
- private UI_SuitShowUI _ui;
- private int _suitTypeId;
- private int _suitId;
- private DressUpObjUI _dressUpObjUI;
- private bool _actionIsPic;
- private List<int> _suitIds;
- public override void Dispose()
- {
- if (_dressUpObjUI != null)
- {
- _dressUpObjUI.Dispose();
- _dressUpObjUI = null;
- }
- if (_dressUpObjUI != null)
- {
- _dressUpObjUI.Dispose();
- _dressUpObjUI = null;
- }
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- packageName = UI_SuitShowUI.PACKAGE_NAME;
- _ui = UI_SuitShowUI.Create();
- this.viewCom = _ui.target;
- isfullScreen = true;
- this.clickBlankToClose = false;
- _dressUpObjUI = new DressUpObjUI("SceneDressUp");
- _ui.m_btnBack.onClick.Add(OnClickBtnBack);
- _ui.m_imgBonusBox.target.onClick.Add(OnClickImgBonusBox);
- _ui.m_btnChangeAction.visible = false;
- _ui.m_btnLeft.onClick.Add(OnClickBtnLeft);
- _ui.m_btnRight.onClick.Add(OnClickBtnRight);
- }
- protected override void OnShown()
- {
- base.OnShown();
- object[] datas = this.viewData as object[];
- _suitTypeId = (int)datas[0];
- _suitId = (int)datas[1];
- List<int> suitIds = datas[2] as List<int>;
- _ui.m_imgBonusBox.target.visible = datas.Length >= 4 ? (bool)datas[3] : true;
- _suitIds = new List<int>();
- foreach (int suitId in suitIds)
- {
- if (DressUpMenuSuitDataManager.CheckHaveSuit(suitId))
- {
- _suitIds.Add(suitId);
- }
- }
- SuitGuideMenuCfg cfg = SuitGuideMenuCfgArray.Instance.GetCfg(_suitTypeId);
- _ui.m_txtTypeName.text = cfg.name;
- _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("tjtj_bjbj");
- UpdateArrows();
- UpdateSuitView();
- UpdateSuitBoxStatus();
- }
- protected override void AddEventListener()
- {
- base.AddEventListener();
- EventAgent.AddEventListener(ConstMessage.SUIT_BOX_STATUS_CHANGED, UpdateSuitBoxStatus);
- }
- protected override void OnHide()
- {
- base.OnHide();
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- EventAgent.RemoveEventListener(ConstMessage.SUIT_BOX_STATUS_CHANGED, UpdateSuitBoxStatus);
- }
- private void OnClickBtnBack()
- {
- this.Hide();
- }
- private void OnClickImgBonusBox()
- {
- SuitUtil.ShowSuitGuideBonus(_suitId);
- }
- private void UpdateSuitView(bool isPic = true)
- {
- _actionIsPic = isPic;
- SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_suitId);
- _ui.m_txtSuitName.text = suitCfg.name;
- _dressUpObjUI.ResetSceneObj(100, false, true, null, false);
- _dressUpObjUI.dressUpObj.PutOnSuitCfg(_suitId, isPic, new int[] { ConstDressUpItemType.BEI_JING }, true, false);
- _dressUpObjUI.UpdateWrapper(_ui.m_holder);
- UpdateSuitBoxStatus();
- }
- private void UpdateArrows()
- {
- int index = _suitIds.IndexOf(_suitId);
- int count = _suitIds.Count;
- _ui.m_btnRight.visible = (index + 1 < count);
- _ui.m_btnLeft.visible = (index - 1 >= 0);
- }
- private void OnClickBtnLeft()
- {
- int index = _suitIds.IndexOf(_suitId);
- int targetIndex = index - 1;
- if (targetIndex >= 0)
- {
- _suitId = _suitIds[targetIndex];
- UpdateArrows();
- UpdateSuitView();
- }
- UpdateSuitBoxStatus();
- }
- private void OnClickBtnRight()
- {
- int index = _suitIds.IndexOf(_suitId);
- int targetIndex = index + 1;
- if (targetIndex < _suitIds.Count)
- {
- _suitId = _suitIds[targetIndex];
- UpdateArrows();
- UpdateSuitView();
- }
- UpdateSuitBoxStatus();
- }
- private void UpdateSuitBoxStatus(EventContext eventContext = null)
- {
- if (eventContext == null || _suitId == (int)eventContext.data)
- {
- int status = DressUpMenuSuitDataManager.GetSuitGuideBonusStatus(_suitId);
- RedDotController.Instance.SetComRedDot(_ui.m_imgBonusBox.target, false);
- RedDotController.Instance.SetComRedDot(_ui.m_imgBonusBox.target, status == ConstBonusStatus.CAN_GET);
- if (status == ConstBonusStatus.CAN_GET)
- {
- _ui.m_imgBonusBox.m_c1.selectedIndex = 1;
- }
- else
- {
- _ui.m_imgBonusBox.m_c1.selectedIndex = 0;
- }
- }
- }
- }
- }
|