using UI.DressUp;
using FairyGUI;
using UnityEngine;
using System.Collections.Generic;
using ET;
namespace GFGGame
{
public class DressUpView : BaseView
{
public const int MAX_MEMORY_STEP = 20;//最大记录步数
public const int BOTTOM_BLANK = 20;
public const int RIGHT_BLANK = 36;
private const int SORT_BY_HIGH_RARITY = 0;
private const int SORT_BY_LOW_RARITY = 1;
private const int SORT_BY_GET_TIME = 2;
private UI_DressUpUI _ui;
private float listType1X = 0;
private float partsListX = 0;
private float partsListScrollingPosY = 0;
private DressUpListType currentListType;
///
/// 子菜单列表
///
private int[] _currentList2;
private GameObject _sceneObject;
private List _currentList3 = new List();
private List _currentList4 = new List();
private int _currentMenuType;
private int _currentSuitId;
private bool _isNormalSuitType = false;//当前套装部件列表是否为普通动作列表
private int _rarityIndex = SORT_BY_HIGH_RARITY;
private UI_TypeItem listTypeItem_FreedomDress;
private List _listLongPress = new List();
private int currentIndex = 0;
public override void Dispose()
{
if (_sceneObject != null)
{
GameObject.Destroy(_sceneObject);
_sceneObject = null;
}
for (int i = 0; i < _listLongPress.Count; i++)
{
_listLongPress[i].Dispose();
}
_listLongPress.Clear();
if (_ui != null)
{
_ui.Dispose();
_ui = null;
}
base.Dispose();
}
protected override void Init()
{
base.Init();
packageName = UI_DressUpUI.PACKAGE_NAME;
_ui = UI_DressUpUI.Create();
viewCom = _ui.target;
isfullScreen = true;
}
protected override void OnInit()
{
base.OnInit();
_ui.m_btnLastStep.visible = true;
_ui.m_btnNextStep.visible = true;
_ui.m_btnSearch.visible = true;
_ui.m_btnPhoto.visible = true;
_ui.m_btnAction.visible = false;
// _ui.m_comboBox.items = new string[] { "我的套装一", "我的套装二", "我的套装三", "我的套装四", "我的套装五", "我的套装六" };
_ui.m_partsList.m_comboBoxRarity.items = new string[] { "高稀有度", "低稀有度", "最近获得" };
_ui.m_partsListSearch.m_comboBoxRarity.items = new string[] { "高稀有度", "低稀有度", "最近获得" };
InitLists();
_ui.m_btnBack.onClick.Add(OnClickBtnBack);
_ui.m_btnHome.onClick.Add(OnClickBtnHome);
_ui.m_btnLastStep.onClick.Add(OnClickBtnLastStep);
_ui.m_btnNextStep.onClick.Add(OnClickBtnNextStep);
_ui.m_comboBox.onChanged.Add(OnComboBoxChanged);
_ui.m_comListType1.m_listType.onClickItem.Add(OnClickListType1Item);
_ui.m_comListType2.m_listType.onClickItem.Add(OnClickListType2Item);
// _ui.m_partsList.m_list.SetVirtual();
// _ui.m_partsList.m_list.onClickItem.Add(OnClickPartsListItem);
_ui.m_partsList2.m_list.onClickItem.Add(OnClickSuitPartsListItem);
// _ui.m_partsListSearch.m_list.onClickItem.Add(OnClickPartsListItem);
_ui.m_touchPad.onClick.Add(OnTouchPad);
_ui.m_btnDelete.onClick.Add(OnClickBtnDelete);
_ui.m_btnSave.onClick.Add(OnClickBtnSave);
_ui.m_partsList.m_comboBoxRarity.onChanged.Add(OnComboBoxRarityChanged);
_ui.m_partsListSearch.m_comboBoxRarity.onChanged.Add(OnSearchComboBoxRarityChanged);
_ui.m_btnAction.onClick.Add(OnClickBtnAction);
_ui.m_btnSearch.onClick.Add(OnClickBtnSearch);
_ui.m_btnNext.onClick.Add(OnClickBtnNext);
_ui.m_btnShow.onClick.Add(OnClickBtnShow);
_ui.m_btnHide.onClick.Add(OnClickBtnHide);
_ui.m_loaShow.onClick.Add(OnClickLoaShow);
_ui.m_btnPhoto.onClick.Add(OnClickBtnPhoto);
_ui.m_partsList2.m_comboBoxRarity.visible = false;
_ui.m_partsList2.m_imgTop.visible = true;
_ui.m_partsList.m_imgTop.visible = false;
}
private void InitLists()
{
_ui.m_comListType2.m_listType.itemRenderer = ListType2Item;
_ui.m_partsList.m_list.itemRenderer = ListPartsItem;
_ui.m_partsList2.m_list.itemRenderer = ListParts2Item;
_ui.m_partsListSearch.m_list.itemRenderer = ListPartsItem;
listType1X = _ui.m_comListType1.target.x;
partsListX = _ui.m_partsList.target.x - _ui.m_partsList.target.width;// - DressUpView.RIGHT_BLANK;
//一级菜单
_ui.m_comListType1.m_listType.itemRenderer = ListType1Item;
_ui.m_comListType1.m_listType.numItems = DressUpMenuItemCfg1Array.Instance.dataArray.Length;
//_ui.m_comListType1.m_listType1.ResizeToFit(_ui.m_comListType1.m_listType1.numItems);
float maxHeight = _ui.target.height - _ui.m_comListType1.target.y - DressUpView.BOTTOM_BLANK;
if (_ui.m_comListType1.m_listType.height > maxHeight)
{
_ui.m_comListType1.m_listType.height = maxHeight;
}
}
protected override void AddEventListener()
{
base.AddEventListener();
EventAgent.AddEventListener(ConstMessage.CLOSE_PHOTOGRAPHVIEW, UpdateScene);
EventAgent.AddEventListener(ConstMessage.DRESS_FILTER, UpdatePartsListSort);
EventAgent.AddEventListener(ConstMessage.DRESS_SEARCH, UpdateSearch);
EventAgent.AddEventListener(ConstMessage.DRESS_FILTER, UpdateSearch);
EventAgent.AddEventListener(ConstMessage.DRESS_FILTER_RESET, DressResetSerch);
}
protected override void OnShown()
{
base.OnShown();
if (this.viewData != null)
{
_ui.m_c2.selectedIndex = (int)this.viewData;
}
_rarityIndex = SORT_BY_HIGH_RARITY;
// MusicManager.Instance.Play(ResPathUtil.GetMusicPath(ConstMusicName.DRESS_UP, "mp3"));
_ui.m_comListType1.target.x = _ui.target.width;
_ui.m_comListType2.target.x = _ui.target.width;
_ui.m_partsList.target.x = _ui.target.width;
_ui.m_partsList2.target.x = _ui.target.width;
_ui.m_partsListSearch.target.x = _ui.target.width;
this.showListType1();
if (_sceneObject == null)
{
_sceneObject = GFGAsset.Load(ResPathUtil.GetPrefabPath("SceneDressUp"));
}
MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject);
currentIndex = CustomSuitDataManager.currentIndex;
_ui.m_comboBox.items = CustomSuitDataManager.GetSuitPosItems();
_ui.m_comboBox.selectedIndex = currentIndex;
MyDressUpHelper.PutOnSuitSavedByPos(currentIndex);
UpdateStepBtn(true);
Timers.inst.AddUpdate(CheckGuide);
}
protected override void OnHide()
{
base.OnHide();
listTypeItem_FreedomDress = null;
// MusicManager.Instance.Play(ResPathUtil.GetMusicPath(ConstMusicName.DEFAULT));
MyDressUpHelper.dressUpObj.TakeOffAll();
if (_sceneObject != null)
{
GameObject.Destroy(_sceneObject);
_sceneObject = null;
}
_ui.m_c2.selectedIndex = 0;
Reset();
Timers.inst.Remove(CheckGuide);
}
protected override void RemoveEventListener()
{
base.RemoveEventListener();
EventAgent.RemoveEventListener(ConstMessage.CLOSE_PHOTOGRAPHVIEW, UpdateScene);
EventAgent.RemoveEventListener(ConstMessage.DRESS_FILTER, UpdatePartsListSort);
EventAgent.RemoveEventListener(ConstMessage.DRESS_SEARCH, UpdateSearch);
EventAgent.RemoveEventListener(ConstMessage.DRESS_FILTER, UpdateSearch);
EventAgent.RemoveEventListener(ConstMessage.DRESS_FILTER_RESET, DressResetSerch);
}
private void OnClickBtnBack()
{
Reset();
// this.Hide();
//ViewManager.Show();
ViewManager.GoBackFrom(typeof(DressUpView).FullName);
}
private void OnClickBtnHome()
{
GameController.GoBackToMainView();
Reset();
}
private void Reset()
{
DressUpMenuItemDataManager.Clear();
MyDressUpHelper.ResetMemory();
}
private void OnClickBtnLastStep()
{
if (!MyDressUpHelper.OnClickBtnLastStep()) return;
UpdateStepBtn(false);
}
private void OnClickBtnNextStep()
{
if (!MyDressUpHelper.OnClickBtnNextStep()) return;
UpdateStepBtn(false);
}
private void OnComboBoxChanged()
{
if (_ui.m_comboBox.selectedIndex == currentIndex) return;
if (CustomSuitDataManager.GetPosType(_ui.m_comboBox.selectedIndex) == MonthCardType.Gold && !RoleDataManager.CheckIsMonthCardOpenByType(MonthCardType.Gold))
{
ViewManager.Show(new object[] { ConstStoreTabId.STORE_MONTH_CARD, ConstStoreSubId.STORE_MONTH_GOLD_CARD });
_ui.m_comboBox.selectedIndex = currentIndex;
return;
}
if (CustomSuitDataManager.GetPosType(_ui.m_comboBox.selectedIndex) == MonthCardType.BlackGold && !RoleDataManager.CheckIsMonthCardOpenByType(MonthCardType.BlackGold))
{
ViewManager.Show(new object[] { ConstStoreTabId.STORE_MONTH_CARD, ConstStoreSubId.STORE_MONTH_BLACK_CARD });
_ui.m_comboBox.selectedIndex = currentIndex;
return;
}
currentIndex = _ui.m_comboBox.selectedIndex;
MyDressUpHelper.PutOnSuitSavedByPos(_ui.m_comboBox.selectedIndex);
UpdateStepBtn(true);
}
private void OnClickListType1Item(EventContext context)
{
GObject typeItem = (GObject)context.data as GObject;
int order = (int)typeItem.data;
DressUpMenuItemCfg1 item1 = DressUpMenuItemCfg1Array.Instance.dataArray[order - 1];
if (item1.subMenusArr.Length > 0)
{
this.showListType2(item1.subMenusArr);
}
else
{
if (this.showListParts(item1.type) == false)
{
PromptController.Instance.ShowFloatTextPrompt("未获得此类部件");
return;
}
}
this.hideListType1();
UpdateListPartsSelected();
}
private void OnClickListType2Item(EventContext context)
{
GObject typeItem = (GObject)context.data as GObject;
int order = (int)typeItem.data;
DressUpMenuItemCfg2 item2 = DressUpMenuItemCfg2Array.Instance.dataArray[order - 1];
if (this.showListParts(item2.type) == false)
{
PromptController.Instance.ShowFloatTextPrompt("未获得此类部件");
return;
}
this.hideListType2();
}
private void OnClickPartsListItem(EventContext context)
{
if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
{
return;
}
int id = (int)(context.sender as GObject).data;
if (_currentMenuType == ConstDressUpItemType.TAO_ZHUANG)
{
partsListScrollingPosY = _ui.m_partsList.m_list.scrollPane.scrollingPosY;
OnBtnNormalClick(context);
}
else if (_currentMenuType == ConstDressUpItemType.DONG_ZUO)
{
MyDressUpHelper.dressUpObj.PutOnOrTakeOffAction(id);
}
else
{
MyDressUpHelper.dressUpObj.AddOrRemove(id, true);
}
UpdateStepBtn(true, id);
}
private void OnBtnNormalClick(EventContext context)
{
// _isNormalSuitType = true;
GObject gObject = context.sender as GObject;
int suitId = (int)gObject.data;
ShowSuitPartList(suitId, false);
}
private void OnBtnActionClick(EventContext context)
{
// _isNormalSuitType = false;
GObject gObject = context.sender as GObject;
int suitId = (int)gObject.data;
ShowSuitPartList(suitId, true);
}
private void ShowSuitPartList(int suitId, bool showAction)
{
_isNormalSuitType = !showAction;
this.showListParts2(suitId);
this.hideListParts();
if (showAction)
{
MyDressUpHelper.dressUpObj.PutOnSuitCfg(suitId, true);
}
else
{
MyDressUpHelper.dressUpObj.PutOnSuitCfg(suitId, false);
}
UpdateStepBtn(true);
}
private void OnClickSuitPartsListItem(EventContext context)
{
if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
{
return;
}
GObject listItem = (GObject)context.data as GObject;
int id = (int)listItem.data;
ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(id);
if (itemCfg != null)
{
if (!DressUpMenuItemDataManager.CheckHasItem(itemCfg.id))
{
PromptController.Instance.ShowFloatTextPrompt("还未获得这件装扮");
return;
}
MyDressUpHelper.dressUpObj.AddOrRemove(id, true);
}
else
{
MyDressUpHelper.dressUpObj.PutOnOrTakeOffAction(id);
}
UpdateStepBtn(true);
// UpdateListSuitPartsSelected();
}
private void UpdateStepBtn(bool isAdd, int suitId = 0)
{
if (isAdd)
{
MyDressUpHelper.AddMemoryDressup();
}
_ui.m_btnLastStep.enabled = MyDressUpHelper.stepIndex > 0;
_ui.m_btnNextStep.enabled = MyDressUpHelper.stepIndex < MyDressUpHelper.dressMemory.Count - 1;
UpdateListPartsSelected(suitId);
UpdateListSuitPartsSelected();
}
private void OnLongPress(EventContext context)
{
LongPressGesture gesture = (LongPressGesture)context.sender;
int itemId = (int)gesture.host.data;
GoodsItemTipsController.ShowItemTips(itemId);
}
private void OnTouchPad()
{
if (this.currentListType == DressUpListType.List4)
{
this.hideListParts2();
this.showListParts(ConstDressUpItemType.TAO_ZHUANG, true);
}
else if (this.currentListType == DressUpListType.List3)
{
if (_currentList2 != null)
{
this.showListType2(_currentList2);
// _ui.m_comListType2.m_listType.numItems = _ui.m_comListType2.m_listType.numItems;
}
else
{
this.showListType1();
}
this.hideListParts();
}
else if (this.currentListType == DressUpListType.List2)
{
this.showListType1();
this.hideListType2();
}
else if (this.currentListType == DressUpListType.List4)
{
this.showListType1();
this.hideListType2();
}
else if (this.currentListType == DressUpListType.List5)
{
this.showListType1();
this.hideSearchListType();
}
// _ui.m_comListType1.m_listType.numItems = _ui.m_comListType1.m_listType.numItems;
// this.ShowSubList();
}
private void OnClickBtnDelete()
{
MyDressUpHelper.dressUpObj.TakeOffAll();
MyDressUpHelper.dressUpObj.AddOrRemove(ConstItemID.DEFULT_BG, false);
UpdateBtnAction();
_ui.m_partsList.m_list.numItems = _currentList3.Count;
_ui.m_partsList2.m_list.numItems = _currentList4.Count;
UpdateStepBtn(true);
}
private void OnClickBtnSave()
{
CustomSuitDataManager.SaveCurrentSuit(_ui.m_comboBox.selectedIndex);
}
private void OnComboBoxRarityChanged()
{
_rarityIndex = _ui.m_partsList.m_comboBoxRarity.selectedIndex;
this.UpdatePartsListSort();
}
private void OnSearchComboBoxRarityChanged()
{
_rarityIndex = _ui.m_partsListSearch.m_comboBoxRarity.selectedIndex;
this.UpdateSearchList();
}
private void OnClickBtnAction()
{
MyDressUpHelper.dressUpObj.PutOnOrTakeOffAction(201003);
}
private void OnClickBtnSearch()
{
ViewManager.Show(true, new object[] { typeof(DressUpView).FullName});
}
private void showListType1()
{
_currentList2 = null;
currentListType = DressUpListType.List1;
_ui.m_comListType1.m_listType.numItems = DressUpMenuItemCfg1Array.Instance.dataArray.Length;
GTween.To(_ui.target.width, listType1X, 0.5f)
.SetTarget(_ui.m_comListType1.target)
.OnUpdate((GTweener t) =>
{
_ui.m_comListType1.target.x = t.value.x;
});
}
private void hideListType1()
{
GTween.To(listType1X, _ui.target.width, 0.5f)
.SetTarget(_ui.m_comListType1.target)
.OnUpdate((GTweener t) =>
{
_ui.m_comListType1.target.x = t.value.x;
});
}
private void showListType2(int[] menuStrArr = null)
{
currentListType = DressUpListType.List2;
if (menuStrArr != null && menuStrArr.Length > 0)
{
int len = menuStrArr.Length;
_currentList2 = menuStrArr.Clone() as int[];
_ui.m_comListType2.m_listType.RemoveChildrenToPool();
_ui.m_comListType2.m_listType.numItems = len;
//_ui.m_comListType2.m_listType2.ResizeToFit(_ui.m_comListType2.m_listType2.numItems);
float maxHeight = _ui.target.height - _ui.m_comListType2.m_listType.y - DressUpView.BOTTOM_BLANK;
if (_ui.m_comListType2.m_listType.height > maxHeight)
{
_ui.m_comListType2.m_listType.height = maxHeight;
}
}
GTween.To(_ui.target.width, listType1X, 0.5f)
.SetTarget(_ui.m_comListType2.target)
.OnUpdate((GTweener t) =>
{
_ui.m_comListType2.target.x = t.value.x;
});
}
private void hideListType2()
{
GTween.To(listType1X, _ui.target.width, 0.5f)
.SetTarget(_ui.m_comListType2.target)
.OnUpdate((GTweener t) =>
{
_ui.m_comListType2.target.x = t.value.x;
});
}
private bool showListParts(int type, bool selectItem = false)
{
_currentMenuType = type;
if (type == (int)ConstDressUpItemType.TAO_ZHUANG)
{
_ui.m_partsList.m_comboBoxRarity.items = new string[] { "高稀有度", "低稀有度", "最近获得" };
if (_rarityIndex >= SORT_BY_GET_TIME)
{
_rarityIndex = SORT_BY_HIGH_RARITY;
}
}
else
{
_ui.m_partsList.m_comboBoxRarity.items = new string[] { "高稀有度", "低稀有度", "最近获得" };
}
this.UpdatePartsListSort();
if (_ui.m_partsList.m_list.numItems <= 0) return false;
_ui.m_partsList.m_list.ResizeToFit(_ui.m_partsList.m_list.numItems);
float maxHeight = _ui.m_partsList.target.height - _ui.m_partsList.m_list.y;// - DressUpView.BOTTOM_BLANK;
if (_ui.m_partsList.m_list.height > maxHeight)
{
_ui.m_partsList.m_list.height = maxHeight;
}
if (type == (int)ConstDressUpItemType.TAO_ZHUANG)
{
_ui.m_partsList.m_list.scrollPane.SetPosY(partsListScrollingPosY, false);
partsListScrollingPosY = 0;
}
currentListType = DressUpListType.List3;
GTween.To(_ui.target.width, partsListX, 0.5f)
.SetTarget(_ui.m_partsList)
.OnUpdate((GTweener t) =>
{
_ui.m_partsList.target.x = t.value.x;
});
UpdateBtnAction();
UpdateListPartsSelected();
return true;
}
private void hideListParts()
{
// _currentMenuType = 0;
UpdateBtnAction();
GTween.To(partsListX, _ui.target.width, 0.5f)
.SetTarget(_ui.m_partsList)
.OnUpdate((GTweener t) =>
{
_ui.m_partsList.target.x = t.value.x;
});
}
private void showListParts2(int suitId)
{
_currentSuitId = suitId;
_ui.m_partsList2.m_comboBoxRarity.items = new string[] { "高稀有度", "低稀有度", "最近获得" };
if (_rarityIndex >= SORT_BY_GET_TIME)
{
_rarityIndex = SORT_BY_HIGH_RARITY;
}
this.UpdateSuitPartsListSort();
_ui.m_partsList2.m_list.ResizeToFit(_ui.m_partsList2.m_list.numItems);
float maxHeight = _ui.m_partsList2.target.height - _ui.m_partsList2.m_list.y;// - DressUpView.BOTTOM_BLANK;
if (_ui.m_partsList2.m_list.height > maxHeight)
{
_ui.m_partsList2.m_list.height = maxHeight;
}
currentListType = DressUpListType.List4;
GTween.To(_ui.target.width, partsListX, 0.5f)
.SetTarget(_ui.m_partsList2)
.OnUpdate((GTweener t) =>
{
_ui.m_partsList2.target.x = t.value.x;
});
UpdateBtnAction();
}
private void hideListParts2()
{
_currentMenuType = ConstDressUpItemType.TAO_ZHUANG;
UpdateBtnAction();
GTween.To(partsListX, _ui.target.width, 0.5f)
.SetTarget(_ui.m_partsList2)
.OnUpdate((GTweener t) =>
{
_ui.m_partsList2.target.x = t.value.x;
});
}
private void showSearchListType()
{
// _currentList2 = null;
currentListType = DressUpListType.List5;
GTween.To(_ui.target.width, partsListX, 0.5f)
.SetTarget(_ui.m_partsListSearch.target)
.OnUpdate((GTweener t) =>
{
_ui.m_partsListSearch.target.x = t.value.x;
});
}
private void hideSearchListType()
{
GTween.To(partsListX, _ui.target.width, 0.5f)
.SetTarget(_ui.m_partsListSearch.target)
.OnUpdate((GTweener t) =>
{
_ui.m_partsListSearch.target.x = t.value.x;
});
}
/****************************************************************************************************************************/
private void DressResetSerch()
{
if (currentListType == DressUpListType.List5)
{
OnTouchPad();
}
}
private void UpdateSearch(EventContext context)
{
if (context.data.ToString() == ConstMessage.DRESS_SEARCH)
{
_currentList3 = DressUpMenuItemDataManager.DressSearch();
}
else if (context.data.ToString() == ConstMessage.DRESS_FILTER)
{
_currentList3 = DressUpMenuItemDataManager.DressFilter();
}
ViewManager.Hide();
UpdateSearchList();
if (currentListType != DressUpListType.List5)
{
hideListParts();
hideListParts2();
hideListType1();
hideListType2();
showSearchListType();
}
_currentMenuType = 0;
}
private void UpdateSearchList()
{
if (_rarityIndex == SORT_BY_HIGH_RARITY)
{
_currentList3 = DressUpMenuItemDataManager.SortItemListByHighRarity(_currentList3);
}
else if (_rarityIndex == SORT_BY_LOW_RARITY)
{
_currentList3 = DressUpMenuItemDataManager.SortItemListByLowRarity(_currentList3);
}
_currentMenuType = 0;
_ui.m_partsListSearch.m_list.numItems = _currentList3.Count;
}
private void ListType1Item(int index, GObject item)
{
UI_TypeItem typeItem = UI_TypeItem.Proxy(item);
DressUpMenuItemCfg1 item1 = DressUpMenuItemCfg1Array.Instance.dataArray[index];
typeItem.m_icon.url = "ui://DressUp/hz_fenleitu_" + item1.id;
typeItem.m_txtname.text = item1.name;
//typeItem.m_imgTitle.url = "ui://DressUp/hz_iconzi_" + item1.id;
typeItem.target.data = item1.id;
typeItem.m_imgNeed.visible = false;
typeItem.m_imgNew.visible = DressUpMenuItemDataManager.CheckIsFirstMenuNew(item1.id);
UI_TypeItem.ProxyEnd();
}
private void ListType2Item(int index, GObject item)
{
UI_TypeItem typeItem = UI_TypeItem.Proxy(item);
DressUpMenuItemCfg2 item2 = DressUpMenuItemCfg2Array.Instance.dataArray[_currentList2[index] - 1];
typeItem.m_icon.url = "ui://DressUp/hz_fenleituej_" + item2.id;
typeItem.m_txtname.text = item2.name;
//typeItem.m_imgTitle.url = "ui://DressUp/hz_iconziej_" + item2.id;
typeItem.target.data = item2.id;
typeItem.m_imgNeed.visible = false;
typeItem.m_imgNew.visible = DressUpMenuItemDataManager.CheckIsSecondMenuNew(item2.id);
UI_TypeItem.ProxyEnd();
}
private void ListPartsItem(int index, GObject item)
{
UI_PartsListItem listItem = UI_PartsListItem.Proxy(item);
int id = (int)_currentList3[index];
string iconRes = "";
string partName = "";
string ext = "png";
listItem.m_btnAni.visible = false;
Debug.Log("id:" + id + " _currentMenuType:" + _currentMenuType);
if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
{
SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(id);
iconRes = suitCfg.res;
partName = suitCfg.name;
listItem.m_iconSelected.visible = false;
RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false, true);
listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + suitCfg.rarity;
listItem.m_ScoreType.visible = false;
listItem.m_imgNew.visible = false;
bool SuitHasAction = SuitCfgArray.Instance.CheckSuitHasAction(id);
bool HasActionRes = DressUpMenuSuitDataManager.CheckSuitHasActionRes(id);
Debug.Log("SuitHasAction:" + SuitHasAction + " HasActionRes:" + HasActionRes + " suitCfg.res" + suitCfg.aniRes);
listItem.m_btnAni.visible = SuitCfgArray.Instance.CheckSuitHasAction(id) && DressUpMenuSuitDataManager.CheckSuitHasActionRes(id);
// listItem.m_comAxtionSelect.m_btnNormal.icon = ResPathUtil.GetIconPath(suitCfg.res, ext);
// listItem.m_comAxtionSelect.m_btnAction.icon = ResPathUtil.GetIconPath(suitCfg.res, ext);
if (listItem.m_btnAni.data == null)
{
listItem.m_btnAni.onClick.Add(OnBtnActionClick);
}
listItem.m_btnAni.data = id;
}
else if (_currentMenuType == (int)ConstDressUpItemType.DONG_ZUO)
{
SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(id);
iconRes = suitCfg.res;
partName = suitCfg.name;
listItem.m_iconSelected.visible = false;
RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false, true);
listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + suitCfg.rarity;
listItem.m_ScoreType.visible = false;
listItem.m_imgNew.visible = false;
}
else
{
ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(id);
iconRes = itemCfg.res;
partName = itemCfg.name;
listItem.m_iconSelected.visible = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
listItem.m_loaBorder.url = "ui://DressUp/hz_kuangk_" + itemCfg.rarity;
RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false);
// ext = ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType, true);
listItem.m_ScoreType.visible = true;
listItem.m_ScoreType.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + itemCfg.mainScore);
bool isNew = DressUpMenuItemDataManager.CheckIsDressUpItemNew(id);
listItem.m_imgNew.visible = isNew;
if (isNew)
{
ItemProxy.ReqSetItemRead(id).Coroutine();
}
}
if (listItem.m_icon.data == null)
{
listItem.m_icon.onClick.Add(OnClickPartsListItem);
}
listItem.m_icon.data = id;
if (listItem.target.data == null)
{
LongPressGesture longPressGesture = new LongPressGesture(listItem.target);
longPressGesture.once = true;
longPressGesture.onAction.Add(OnLongPress);
_listLongPress.Add(longPressGesture);
}
listItem.m_icon.url = ResPathUtil.GetIconPath(iconRes, ext);
listItem.m_txtTitle.text = partName;
listItem.target.data = id;
listItem.m_grpScore.visible = false;
//listItem.m_ScoreType.visible = true;
listItem.m_imgNeed.visible = false;
UI_PartsListItem.ProxyEnd();
}
private void ListParts2Item(int index, GObject item)
{
UI_PartsListItem listItem = UI_PartsListItem.Proxy(item);
int id = (int)_currentList4[index];
string iconRes = "";
string partName = "";
// string ext = "png";
if (listItem.target.data == null)
{
LongPressGesture longPressGesture = new LongPressGesture(listItem.target);
longPressGesture.once = true;
longPressGesture.onAction.Add(OnLongPress);
_listLongPress.Add(longPressGesture);
}
ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(id);
SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(id);
iconRes = itemCfg != null ? itemCfg.res : suitCfg.res;
partName = itemCfg != null ? itemCfg.name : suitCfg.name;
bool isPutOn = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
bool isAction = MyDressUpHelper.dressUpObj.IsAction && SuitCfgArray.Instance.CheckActionContainsItem(id, MyDressUpHelper.dressUpObj.actionId);
listItem.m_iconSelected.visible = isPutOn || isAction;
RarityIconController.UpdateRarityIcon(listItem.m_rarity, id, false, itemCfg == null);
listItem.m_ScoreType.visible = false;
if (itemCfg != null)
{
listItem.m_ScoreType.visible = true;
listItem.m_ScoreType.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + itemCfg.mainScore);
}
listItem.m_btnAni.visible = false;
listItem.m_icon.url = ResPathUtil.GetIconPath(iconRes, "png");
listItem.m_txtTitle.text = partName;
listItem.target.data = id;
listItem.m_grpScore.visible = false;
//listItem.m_ScoreType.visible = true;
listItem.m_imgNeed.visible = false;
bool isNew = DressUpMenuItemDataManager.CheckIsDressUpItemNew(id);
listItem.m_imgNew.visible = isNew;
if (isNew)
{
ItemProxy.ReqSetItemRead(id).Coroutine();
}
UI_PartsListItem.ProxyEnd();
}
private void UpdateListPartsSelected(int selectSuitId = 0)
{
GList list;
if (_ui.m_partsList.target.x == partsListX)
{
list = _ui.m_partsList.m_list;
}
else if (_ui.m_partsListSearch.target.x == partsListX)
{
list = _ui.m_partsListSearch.m_list;
}
else
{
return;
}
int count = list.numChildren;
int suitId = MyDressUpHelper.dressUpObj.suitId;
for (int i = 0; i < count; i++)
{
UI_PartsListItem listItem = UI_PartsListItem.Proxy(list.GetChildAt(i));
int id = (int)listItem.target.data;
if (_currentMenuType == ConstDressUpItemType.TAO_ZHUANG)
{
listItem.m_iconSelected.visible = suitId > 0 && id == suitId;
}
else if (_currentMenuType == ConstDressUpItemType.DONG_ZUO)
{
listItem.m_iconSelected.visible = MyDressUpHelper.dressUpObj.IsAction && MyDressUpHelper.dressUpObj.actionId == id;
}
else
{
bool isPutOn = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);
bool isAction = MyDressUpHelper.dressUpObj.IsAction && SuitCfgArray.Instance.CheckActionContainsItem(id, MyDressUpHelper.dressUpObj.actionId);
listItem.m_iconSelected.visible = isPutOn || isAction;
}
UI_PartsListItem.ProxyEnd();
}
}
private void UpdateListSuitPartsSelected()
{
int count = _ui.m_partsList2.m_list.numChildren;
for (int i = 0; i < count; i++)
{
UI_PartsListItem listItem = UI_PartsListItem.Proxy(_ui.m_partsList2.m_list.GetChildAt(i));
int id = (int)listItem.target.data;
bool isSuitSelect = MyDressUpHelper.dressUpObj.CheckDressUpItemIsOn(id);//可换部件是否穿戴
bool isActionSelect = MyDressUpHelper.dressUpObj.actionId == id;
listItem.m_iconSelected.visible = isSuitSelect || isActionSelect;
UI_PartsListItem.ProxyEnd();
}
}
private void UpdatePartsListSort()
{
if (_currentMenuType == 0) return;
if (_currentMenuType == (int)ConstDressUpItemType.TAO_ZHUANG)
{
_currentList3 = DressUpMenuSuitDataManager.GetSuitIDList();
if (_rarityIndex == SORT_BY_HIGH_RARITY)
{
_currentList3 = SuitUtil.SortSuitListByHighRarity(_currentList3);
}
else if (_rarityIndex == SORT_BY_LOW_RARITY)
{
_currentList3 = SuitUtil.SortSuitListByLowRarity(_currentList3);
}
else
{
_currentList3.Reverse();
}
}
else if (_currentMenuType == (int)ConstDressUpItemType.DONG_ZUO)
{
_currentList3 = DressUpMenuSuitDataManager.GetActionIDList();
if (_rarityIndex == SORT_BY_HIGH_RARITY)
{
_currentList3 = SuitUtil.SortSuitListByHighRarity(_currentList3);
}
else if (_rarityIndex == SORT_BY_LOW_RARITY)
{
_currentList3 = SuitUtil.SortSuitListByLowRarity(_currentList3);
}
else
{
_currentList3.Reverse();
}
}
else
{
_currentList3 = DressUpMenuItemDataManager.getItemDatasByType(_currentMenuType);
if (_rarityIndex == SORT_BY_HIGH_RARITY)
{
_currentList3 = DressUpMenuItemDataManager.SortItemListByHighRarity(_currentList3);
}
else if (_rarityIndex == SORT_BY_LOW_RARITY)
{
_currentList3 = DressUpMenuItemDataManager.SortItemListByLowRarity(_currentList3);
}
else
{
_currentList3.Reverse();
}
}
// if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Search)
// {
// _currentList3 = DressUpMenuItemDataManager.DressSearch(_currentList3);
// }
// else if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Filter)
// {
// _currentList3 = DressUpMenuItemDataManager.DressFilter(_currentList3);
// }
_ui.m_partsList.m_list.RemoveChildrenToPool();
_ui.m_partsList.m_list.numItems = _currentList3.Count;
}
private void UpdateSuitPartsListSort()
{
if (_currentMenuType == 0) return;
if (_isNormalSuitType)
{
_currentList4 = new List(SuitCfgArray.Instance.GetSuitItems(_currentSuitId));
}
else
{
_currentList4 = SuitCfgArray.Instance.GetOneSuitAllNotActionParts(_currentSuitId);
_currentList4.Add(_currentSuitId);
}
// if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Search)
// {
// _currentList4 = DressUpMenuItemDataManager.DressSearch(_currentList4);
// }
// else if (DressUpMenuItemDataManager.dressFilterType == DressFilterType.Filter)
// {
// _currentList4 = DressUpMenuItemDataManager.DressFilter(_currentList4);
// }
_ui.m_partsList2.m_list.RemoveChildrenToPool();
_ui.m_partsList2.m_list.numItems = _currentList4.Count;
}
private void UpdateBtnAction()
{
// _ui.m_btnAction.visible = (_currentMenuType == ConstDressUpItemType.TAO_ZHUANG) || this.currentListType == DressUpListType.List4;
// if (_ui.m_btnAction.visible)
// {
//_ui.m_btnAction.grayed = !EquipDataCache.cacher.HasSuitActionRes;
// }
}
private void OnClickBtnShow()
{
Timers.inst.Remove(SetBtnShowVisable);
_ui.m_c1.selectedIndex = 0;
_ui.m_btnHide.visible = true;
_ui.m_btnShow.visible = false;
_ui.m_loaShow.visible = false;
}
private void OnClickBtnHide()
{
_ui.m_c1.selectedIndex = 1;
_ui.m_btnHide.visible = false;
_ui.m_btnShow.visible = true;
_ui.m_loaShow.visible = true;
Timers.inst.Add(2f, 1, SetBtnShowVisable);
}
private void OnClickLoaShow()
{
_ui.m_btnShow.alpha = 1;
_ui.m_btnShow.enabled = true;
Timers.inst.Add(2f, 1, SetBtnShowVisable);
}
private void OnClickBtnPhoto()
{
LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.PAI_ZHAO, 1);
if (!ViewManager.Show())
{
return;
}
_ui.target.visible = false;
this._sceneObject.gameObject.SetActive(false);
}
private void OnClickBtnNext()
{
// if (!EquipDataCache.cacher.CheckPutOnFinish())
// {
// AlertUI.Show("只有换好衣服才能出门哦!")
// .SetRightButton(true, "好的");
// return;
// }
if (!ViewManager.Show(this.viewData))
{
return;
}
_ui.target.visible = false;
this._sceneObject.gameObject.SetActive(false);
}
private void UpdateScene()
{
_ui.target.visible = true;
this._sceneObject.gameObject.SetActive(true);
}
private void SetBtnShowVisable(object param)
{
_ui.m_btnShow.enabled = false;
GTween.To(1, 0, 0.3f).SetTarget(_ui.m_btnShow, TweenPropType.Alpha);
}
private bool CheckListCount(int type)
{
if (type == (int)ConstDressUpItemType.TAO_ZHUANG)
{
return DressUpMenuSuitDataManager.GetSuitIDList().Count > 0;
}
else
{
return DressUpMenuItemDataManager.getItemDatasByType(type).Count > 0;
}
}
private void CheckGuide(object param)
{
if (GuideDataManager.IsGuideFinish(ConstGuideId.FREEDOM_DRESS) <= 0
|| GuideDataManager.IsGuideFinish(ConstGuideId.ENTER_CHAPTER) <= 0)
{
UpdateToCheckGuide(null);
}
else
{
Timers.inst.Remove(CheckGuide);
}
}
protected override void UpdateToCheckGuide(object param)
{
if (!ViewManager.CheckIsTopView(this.viewCom)) return;
if (listTypeItem_FreedomDress == null && GuideDataManager.IsGuideFinish(ConstGuideId.FREEDOM_DRESS) <= 0)
{
int len = _ui.m_comListType1.m_listType.numChildren;
for (int i = 0; i < len; i++)
{
UI_TypeItem item = UI_TypeItem.Proxy(_ui.m_comListType1.m_listType.GetChildAt(i));
if (item != null)
{
int menuID = (int)item.target.data;
DressUpMenuItemCfg1 dressUpMenuItemCfg1 = DressUpMenuItemCfg1Array.Instance.GetCfg(menuID);
if (dressUpMenuItemCfg1.type == ConstDressUpItemType.TAO_ZHUANG)
{
listTypeItem_FreedomDress = item;
_ui.m_comListType1.m_listType.ScrollToView(i);
break;
}
}
UI_TypeItem.ProxyEnd();
}
}
if (listTypeItem_FreedomDress != null) GuideController.TryGuide(listTypeItem_FreedomDress.target, ConstGuideId.FREEDOM_DRESS, 3, "套装分类里,可以查看集齐成套的服饰,点击一键换上。");
GuideController.TryGuide(_ui.m_partsList.m_list, ConstGuideId.FREEDOM_DRESS, 4, "", 0);
// if (_ui.m_partsList.m_list.numItems > 0)
// {
// UI_PartsListItem listItem = UI_PartsListItem.Proxy(_ui.m_partsList.m_list.GetChildAt(0).asCom);
// GuideController.TryGuide(listItem.m_comAxtionSelect.m_btnAction, ConstGuideId.FREEDOM_DRESS, 5, "选择特殊动作并穿上。");
// UI_PartsListItem.ProxyEnd();
// }
GuideController.TryGuide(_ui.m_btnSave, ConstGuideId.FREEDOM_DRESS, 5, "搭配好的服饰,可以保存到主界面显示。");
GuideController.TryGuide(_ui.m_btnPhoto, ConstGuideId.FREEDOM_DRESS, 6, "辛苦搭配完,去拍个照片留念呀~~");
GuideController.TryGuide(_ui.m_btnBack, ConstGuideId.ENTER_CHAPTER, 2, "");
}
}
}