123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- using System.Collections.Generic;
- using ET;
- using FairyGUI;
- using UI.Travel;
- using UnityEngine;
- namespace GFGGame
- {
- public class TravelDressupView : BaseWindow
- {
- private UI_TravelDressupUI _ui;
- private List<int> _selectTravelSuitIds = new List<int>();
- private List<int> _travelSuitIds = new List<int>();
- public override void Dispose()
- {
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- packageName = UI_TravelDressupUI.PACKAGE_NAME;
- _ui = UI_TravelDressupUI.Create();
- this.viewCom = _ui.target;
- isfullScreen = true;
- _ui.m_btnCancle.onClick.Add(Hide);
- _ui.m_btnGo.onClick.Add(OnBtnGoClick);
- _ui.m_comDress0.target.onClick.Add(OnComDressClick0);
- _ui.m_comDress1.target.onClick.Add(OnComDressClick);
- _ui.m_comDress2.target.onClick.Add(OnComDressClick);
- }
- protected override void AddEventListener()
- {
- base.AddEventListener();
- }
- protected override void OnShown()
- {
- base.OnShown();
- UpdateView();
- }
- protected override void OnHide()
- {
- base.OnHide();
- _selectTravelSuitIds.Clear();
- _travelSuitIds.Clear();
- if (_ui.m_list.numItems > 0) _ui.m_list.ScrollToView(0);
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- }
- private void UpdateView()
- {
- _travelSuitIds = new List<int>(DressUpMenuSuitDataManager.TravelSuitIDList.ToArray());
- for (int i = 0; i < _selectTravelSuitIds.Count; i++)
- {
- if (_travelSuitIds.IndexOf(_selectTravelSuitIds[i]) >= 0)
- {
- _travelSuitIds.Remove(_selectTravelSuitIds[i]);
- }
- }
- _ui.m_list.numItems = _travelSuitIds.Count;
- }
- private void OnListItemClick(EventContext context)
- {
- if (_selectTravelSuitIds.Count >= 2)
- {
- PromptController.Instance.ShowFloatTextPrompt("行囊已满");
- return;
- }
- GObject obj = context.sender as GObject;
- if (obj.data == null)
- {
- PromptController.Instance.ShowFloatTextPrompt("请选择游历要带的服装");
- return;
- }
- int travelSuitId = (int)obj.data;
- _selectTravelSuitIds.Add(travelSuitId);
- UpdateView();
- }
- private void OnComDressClick0()
- {
- PromptController.Instance.ShowFloatTextPrompt("必带服装不能取消");
- }
- private void OnComDressClick(EventContext context)
- {
- GObject obj = context.sender as GObject;
- int travelSuitId = (int)obj.data;
- _selectTravelSuitIds.Remove(travelSuitId);
- obj.data = null;
- UpdateView();
- }
- private async void OnBtnGoClick()
- {
- if (_selectTravelSuitIds.Count < 2)
- {
- PromptController.Instance.ShowFloatTextPrompt("需带齐服装才能出发");
- return;
- }
- bool result = await TravelSProxy.ReqGoTravel(_selectTravelSuitIds);
- if (result)
- {
- this.Hide();
- }
- }
- }
- }
|