978 lines
29 KiB
C#
978 lines
29 KiB
C#
using cfg.CharacterCfg;
|
|
using Framework;
|
|
using NLDPB;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using Gameplay;
|
|
using PhxhSDK;
|
|
using Sirenix.Utilities;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using Image = UnityEngine.UI.Image;
|
|
using Cysharp.Threading.Tasks;
|
|
|
|
public class UISelectCharacterController : UIWindow
|
|
{
|
|
|
|
private const int ALL_DROPDOWN_VALUE = -1;
|
|
|
|
GameObject mFenLeiYiJuItemAssetObj;
|
|
GameObject mCharacterItemAssetObj;
|
|
PhxhScrollView _mCurrentScrollView = null;
|
|
private int mCurrentFraction =0;
|
|
private int mCurrentJob = 0;
|
|
CharacterSortType mCurrentSortType = CharacterSortType.EAll;
|
|
|
|
List<CharacterDataInfo> mShowList = new List<CharacterDataInfo>();
|
|
|
|
List<CharacterDataInfo> mStorageCharacterInfo = new List<CharacterDataInfo>();
|
|
List<CharacterDataInfo> mSortedCInfoList = new List<CharacterDataInfo>();
|
|
Dictionary<GameObject, CharacterDataInfo> mUIHeadGoDic = new Dictionary<GameObject, CharacterDataInfo>();
|
|
private GameObject mCurrentScrollViewContentObj = null;
|
|
|
|
private CharacterBreak characterBreakCfg;
|
|
private JobAttri jobAttriCfg;
|
|
private FactionAttri factionAttriCfg;
|
|
|
|
private GameObject mRarityBtnObj;
|
|
private GameObject mLevelBtnObj;
|
|
private GameObject mOtherBtnObj;
|
|
private GameObject mJobBtnObj;
|
|
|
|
private bool IsSmall2Big = false;
|
|
|
|
private CharacterSortType mCurOtherBtnState = CharacterSortType.EBreak;
|
|
private UITextDropdown<int> factionDropDown;
|
|
private UITextDropdown<int> otherDropDown;
|
|
private UIImageDropDown<int> jobDropDown;
|
|
|
|
private Sprite jobFirstSpr;
|
|
|
|
//打开时传入队列信息
|
|
private Team _curTeam;
|
|
private int _charIdx;
|
|
|
|
private GameObject _goClearTeam;
|
|
|
|
public struct InputData
|
|
{
|
|
public OpenType OpenType;
|
|
public Team Data;
|
|
public int Idx;
|
|
}
|
|
|
|
public enum OpenType
|
|
{
|
|
Default,
|
|
EditTeam
|
|
}
|
|
|
|
private OpenType _curOpenType = OpenType.Default;
|
|
|
|
enum CharacterSortType
|
|
{
|
|
EAll,
|
|
EStar,
|
|
ELevel,
|
|
EAwake,
|
|
EBreak,
|
|
ELikely,
|
|
}
|
|
|
|
public override void PreLoad(object data = null)
|
|
{
|
|
base.PreLoad(data);
|
|
|
|
if (data != null)
|
|
{
|
|
var input = (InputData)data;
|
|
_curOpenType = input.OpenType;
|
|
if (_curOpenType == OpenType.EditTeam)
|
|
{
|
|
_curTeam = input.Data;
|
|
_charIdx = input.Idx;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override async void OnInit()
|
|
{
|
|
BindButton("Image_BG/Image_Menu/Button_Rarity", OnButton_RarityClick);
|
|
BindButton("Image_BG/Image_Menu/Button_Level", OnButton_LevelClick);
|
|
BindButton("Image_BG/Image_Menu/Button_AdvanceLevel", OnButton_AdvanceLevel);
|
|
BindButton("Image_BG/Image_Menu/Button_ChangeLevel", OnButton_ChangeLevelClick);
|
|
BindButton("Image_BG/Button_Back", OnButton_BackClick);
|
|
BindButton("Image_BG/Button_Home", OnClickHome);
|
|
|
|
mCurrentScrollViewContentObj = FindObj("ScrollView_SelectCharacter/Viewport/Content");
|
|
_mCurrentScrollView = GetComponent<PhxhScrollView>("ScrollView_SelectCharacter");
|
|
mRarityBtnObj = FindObj("Image_BG/Image_Menu/Button_Rarity");
|
|
mLevelBtnObj = FindObj("Image_BG/Image_Menu/Button_Level");
|
|
mOtherBtnObj = FindObj("Image_BG/Image_Menu/Button_AdvanceLevel");
|
|
mJobBtnObj = FindObj("Image_BG/Button_Profession");
|
|
|
|
factionDropDown =
|
|
new UITextDropdown<int>(FindObj("Image_BG/Button_Group"), FindObj("Image_BG/Button_Group/Text_Group"), FactionDropdownValueChanged, FactionDropdownData2Text);
|
|
|
|
otherDropDown =
|
|
new UITextDropdown<int>(FindObj("Image_BG/Image_Menu/Button_ChangeLevel"), FindObj("Image_BG/Image_Menu/Button_AdvanceLevel/Text_Default"), OtherDropdownValueChanged, OtherDropdownData2Text);
|
|
|
|
jobDropDown =
|
|
new UIImageDropDown<int>(FindObj("Image_BG/Button_Profession"), FindObj("Image_BG/Button_Profession/Text_Profession"), JobDropdownValueChanged, JobDropdownData2Text, JobDropdownData2Image);
|
|
|
|
|
|
PreLoadCfg();
|
|
await PreLoadAllJobIcon();
|
|
RefreshUpperSortBtn();
|
|
AddDropDownOption();
|
|
|
|
|
|
LayoutRebuilder.ForceRebuildLayoutImmediate((FindObj("Image_BG/Image_Menu/Button_Rarity")).transform as RectTransform);
|
|
LayoutRebuilder.ForceRebuildLayoutImmediate(FindObj("Image_BG/Image_Menu/Button_Level").transform as RectTransform);
|
|
LayoutRebuilder.ForceRebuildLayoutImmediate(FindObj("Image_BG/Image_Menu/Button_AdvanceLevel").transform as RectTransform);
|
|
|
|
|
|
|
|
}
|
|
|
|
private async UniTask PreLoadAllJobIcon()
|
|
{
|
|
foreach (var factionItem in System.Enum.GetValues(typeof(Ejob)))
|
|
{
|
|
await AssetManager.Instance.LoadAssetAsync<Sprite>((jobAttriCfg.Get((int)factionItem).IconPath));
|
|
}
|
|
}
|
|
|
|
private void OnButton_BackClick()
|
|
{
|
|
if (_curOpenType == OpenType.EditTeam)
|
|
{
|
|
BackInTeam();
|
|
return;
|
|
}
|
|
CloseWindow();
|
|
}
|
|
|
|
private async void BackInTeam()
|
|
{
|
|
if (_curOpenType == OpenType.EditTeam)
|
|
{
|
|
//TeamEditManager.Instance.SaveTeam(_curTeam);
|
|
EventManager.Instance.Send(EventManager.EventName.TeamModified, _curTeam.TeamIndex);
|
|
// var window = UIManager.Instance.PopWindow();
|
|
// await UIManager.AnimSwitchWindow(this, UIWindowCloseType.HideAndDestroy, window);
|
|
//window.ReloadWindow(_curTeam);
|
|
}
|
|
CloseWindow();
|
|
}
|
|
|
|
private void OnClickHome()
|
|
{
|
|
UIManager.Instance.CloseAllNormalExcept(UINameConst.UI_MainPanel);
|
|
}
|
|
|
|
private void JobDropdownValueChanged(TMP_Dropdown change)
|
|
{
|
|
if (mCurrentJob == change.value)
|
|
{
|
|
return;
|
|
}
|
|
if (!IfHaveJob((Ejob)change.value)&&(change.value!=0))
|
|
{
|
|
CommonUtils.ShowMessageTips(CommonUtils.GetLocalizeText("cultivate_notHaveFractionJob"));
|
|
return;
|
|
}
|
|
|
|
mCurrentJob = change.value;
|
|
if(change.value==0)
|
|
{
|
|
CommonUtils.GetComponent<TMP_Text>(CommonUtils.GetGameObject(mJobBtnObj, "Text_Profession")).text = CommonUtils.GetLocalizeText("cultivate_AllJob"); ;
|
|
|
|
}
|
|
else
|
|
{
|
|
CommonUtils.GetComponent<TMP_Text>(CommonUtils.GetGameObject(mJobBtnObj, "Text_Profession")).text =CommonUtils.GetLocalizeText( jobAttriCfg.Get(mCurrentJob).DisplayName);
|
|
|
|
}
|
|
SortList(mCurrentSortType);
|
|
SelectListByJobAndFraction();
|
|
RefreshScrollView();
|
|
}
|
|
|
|
|
|
|
|
private string FactionDropdownData2Text(int value)
|
|
{
|
|
if (value==ALL_DROPDOWN_VALUE)
|
|
{
|
|
return CommonUtils.GetLocalizeText("cultivate_AllFraction");
|
|
}
|
|
else
|
|
{
|
|
return CommonUtils.GetLocalizeText( factionAttriCfg.Get(value).DisplayName);
|
|
}
|
|
}
|
|
private string JobDropdownData2Text(int value)
|
|
{
|
|
if (value == ALL_DROPDOWN_VALUE)
|
|
{
|
|
return CommonUtils.GetLocalizeText("cultivate_AllJob");
|
|
}
|
|
else
|
|
{
|
|
return CommonUtils.GetLocalizeText(jobAttriCfg.Get(value).DisplayName);
|
|
}
|
|
}
|
|
private Sprite JobDropdownData2Image(int value)
|
|
{
|
|
if (value == ALL_DROPDOWN_VALUE)
|
|
{
|
|
return AssetManager.GetSingleton().LoadAsset<Sprite>((jobAttriCfg.Get(1).IconPath));
|
|
|
|
}
|
|
else
|
|
{
|
|
return AssetManager.GetSingleton().LoadAsset<Sprite>((jobAttriCfg.Get(value).IconPath));
|
|
|
|
}
|
|
|
|
}
|
|
private string OtherDropdownData2Text(int value)
|
|
{
|
|
string str= GetCharactererSortTypeLocalize((CharacterSortType)(value));
|
|
CommonUtils.GetComponent<TMP_Text>(mOtherBtnObj, "Text_Clip").text = str;
|
|
return str;
|
|
}
|
|
|
|
|
|
private void FactionDropdownValueChanged(int value)
|
|
{
|
|
if (mCurrentFraction == value)
|
|
{
|
|
return;
|
|
}
|
|
|
|
mCurrentFraction = value;
|
|
|
|
if(!IfHaveFraction((Efaction)value) && (value != ALL_DROPDOWN_VALUE))
|
|
{
|
|
CommonUtils.ShowMessageTips(CommonUtils.GetLocalizeText("cultivate_notHaveFractionJob"));
|
|
return;
|
|
}
|
|
|
|
|
|
SortList(mCurrentSortType);
|
|
SelectListByJobAndFraction();
|
|
RefreshScrollView();
|
|
}
|
|
private void OtherDropdownValueChanged(int value)
|
|
{
|
|
if ((int)mCurOtherBtnState == value)
|
|
{
|
|
return;
|
|
}
|
|
mCurOtherBtnState = (CharacterSortType)(value + 3);
|
|
|
|
RefreshBtn(mOtherBtnObj, true, true);
|
|
}
|
|
|
|
private void JobDropdownValueChanged(int value)
|
|
{
|
|
if (mCurrentJob == value)
|
|
{
|
|
return;
|
|
}
|
|
if (!IfHaveJob((Ejob)value) && (value != 0))
|
|
{
|
|
CommonUtils.ShowMessageTips(CommonUtils.GetLocalizeText("cultivate_notHaveFractionJob"));
|
|
return;
|
|
}
|
|
|
|
mCurrentJob = value;
|
|
|
|
SortList(mCurrentSortType);
|
|
SelectListByJobAndFraction();
|
|
RefreshScrollView();
|
|
}
|
|
private void AddDropDownOption()
|
|
{
|
|
AddFactionDropDownOption();
|
|
AddOtherBtnDropDownOption();
|
|
AddJobDropDownOption();
|
|
}
|
|
|
|
private void AddFactionDropDownOption()
|
|
{
|
|
var dropDownData = new List<int>() { ALL_DROPDOWN_VALUE };
|
|
foreach (var faction in Enum.GetValues(typeof(Efaction)))
|
|
{
|
|
dropDownData.Add((int)faction);
|
|
}
|
|
factionDropDown.SetData(dropDownData);
|
|
}
|
|
|
|
private void AddOtherBtnDropDownOption()
|
|
{
|
|
var dropDownData = new List<int>();
|
|
|
|
System.Array ints = System.Enum.GetValues(typeof(CharacterSortType));
|
|
for (int i = 3; i < ints.Length; i++)
|
|
{
|
|
dropDownData.Add((int)ints.GetValue(i));
|
|
}
|
|
otherDropDown.SetData(dropDownData);
|
|
|
|
}
|
|
string GetCharactererSortTypeLocalize(CharacterSortType sortType)
|
|
{
|
|
switch (sortType)
|
|
{
|
|
case CharacterSortType.EAwake:
|
|
return CommonUtils.GetLocalizeText("culitivate_AwakeLevel");
|
|
case CharacterSortType.EBreak:
|
|
return CommonUtils.GetLocalizeText("culitivate_BreakLevel");
|
|
case CharacterSortType.ELikely:
|
|
return CommonUtils.GetLocalizeText("culitivate_likely");
|
|
}
|
|
return "";
|
|
|
|
}
|
|
private void AddJobDropDownOption()
|
|
{
|
|
var dropDownData = new List<int>() { ALL_DROPDOWN_VALUE };
|
|
|
|
foreach (var factionItem in System.Enum.GetValues(typeof(Ejob)))
|
|
{
|
|
dropDownData.Add(((int)factionItem));
|
|
}
|
|
|
|
jobDropDown.SetData(dropDownData);
|
|
|
|
}
|
|
bool IfHaveJob(Ejob job)
|
|
{
|
|
foreach(var v in mStorageCharacterInfo)
|
|
{
|
|
if((v.Cfg.Job == job)&&(IsEqual((int)v.Cfg.Fraction,mCurrentFraction)))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
bool IfHaveFraction(Efaction fraction)
|
|
{
|
|
foreach (var v in mStorageCharacterInfo)
|
|
{
|
|
if ((v.Cfg.Fraction == fraction)&& (IsEqual((int)v.Cfg.Job, mCurrentJob)))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnButton_ChangeLevelClick()
|
|
{
|
|
if (mCurrentSortType == CharacterSortType.ELevel)
|
|
{
|
|
IsSmall2Big = !IsSmall2Big;
|
|
}
|
|
else
|
|
{
|
|
mCurrentSortType = CharacterSortType.ELevel;
|
|
IsSmall2Big = false;
|
|
}
|
|
RefreshUI();
|
|
|
|
}
|
|
|
|
|
|
private void OnButton_AdvanceLevel()
|
|
{
|
|
if(mCurrentSortType== mCurOtherBtnState)
|
|
{
|
|
IsSmall2Big = !IsSmall2Big;
|
|
|
|
}else
|
|
{
|
|
mCurrentSortType = mCurOtherBtnState;
|
|
IsSmall2Big = false;
|
|
|
|
}
|
|
RefreshUI();
|
|
|
|
}
|
|
|
|
private void OnButton_LevelClick()
|
|
{
|
|
if (mCurrentSortType == CharacterSortType.ELevel)
|
|
{
|
|
IsSmall2Big = !IsSmall2Big;
|
|
}
|
|
else
|
|
{
|
|
mCurrentSortType = CharacterSortType.ELevel;
|
|
IsSmall2Big = false;
|
|
}
|
|
RefreshUI();
|
|
}
|
|
|
|
private void OnButton_RarityClick()
|
|
{
|
|
if (mCurrentSortType == CharacterSortType.EStar)
|
|
{
|
|
IsSmall2Big = !IsSmall2Big;
|
|
}
|
|
else
|
|
{
|
|
mCurrentSortType = CharacterSortType.EStar;
|
|
IsSmall2Big = false;
|
|
}
|
|
RefreshUI();
|
|
|
|
}
|
|
|
|
private void PreLoadCfg()
|
|
{
|
|
characterBreakCfg = TableManager.Instance.Tables.CharacterBreak;
|
|
jobAttriCfg = TableManager.Instance.Tables.JobAttri;
|
|
factionAttriCfg = TableManager.Instance.Tables.FactionAttri;
|
|
}
|
|
|
|
protected override void OnShowWindow(object data = null)
|
|
{
|
|
GetStorageData();
|
|
PreLoadAllCharacter();
|
|
RegisterEvent();
|
|
RefreshUI();
|
|
CreateScrollView();
|
|
CommonUtils.GetComponent<TMP_Text>(mOtherBtnObj, "Text_Default").text = GetCharactererSortTypeLocalize(CharacterSortType.EAwake);
|
|
CommonUtils.GetComponent<TMP_Text>(mOtherBtnObj, "Text_Clip").text = GetCharactererSortTypeLocalize(CharacterSortType.EAwake);
|
|
|
|
}
|
|
private void CreateScrollView()
|
|
{
|
|
if (!ShowIfNull())
|
|
{
|
|
SetScrollViewAll();
|
|
|
|
}
|
|
}
|
|
private void PreLoadAllCharacter()
|
|
{
|
|
for (int i = 0; i < mStorageCharacterInfo.Count; i++)
|
|
{
|
|
string path = CommonUtils.GetCharacterPicPath(mStorageCharacterInfo[i].Cfg.RoleID,
|
|
CommonUtils.ECharacterPicPathType.SelectCharacter);
|
|
AssetManager.Instance.PostPreload<Sprite>(path);
|
|
}
|
|
}
|
|
void RefreshUpperSortBtn()
|
|
{
|
|
RefreshBtn(mRarityBtnObj, mCurrentSortType==CharacterSortType.EStar);
|
|
RefreshBtn(mLevelBtnObj, mCurrentSortType == CharacterSortType.ELevel);
|
|
RefreshBtn(mOtherBtnObj, mCurrentSortType == mCurOtherBtnState,true);
|
|
|
|
|
|
}
|
|
void RefreshBtn(GameObject btnObj, bool IsSeleted, bool isLast = false)
|
|
{
|
|
if(IsSeleted)
|
|
{
|
|
CommonUtils.GetGameObject(btnObj, "Image_Default/Image_UP").SetActive(IsSmall2Big);
|
|
CommonUtils.GetGameObject(btnObj, "Image_Default/Image_Down").SetActive(!IsSmall2Big);
|
|
|
|
}
|
|
else
|
|
{
|
|
CommonUtils.GetGameObject(btnObj, "Image_Default/Image_UP").SetActive(false);
|
|
CommonUtils.GetGameObject(btnObj, "Image_Default/Image_Down").SetActive(!false);
|
|
|
|
}
|
|
if (!isLast)
|
|
{
|
|
CommonUtils.GetGameObject(btnObj, "Text_Default/Text_Clip").SetActive(IsSeleted);
|
|
|
|
}
|
|
else
|
|
{
|
|
CommonUtils.GetGameObject(btnObj, "Text_Clip").SetActive(IsSeleted);
|
|
CommonUtils.GetGameObject(btnObj, "Text_Default").SetActive(!IsSeleted);
|
|
|
|
}
|
|
|
|
}
|
|
void RefreshUI()
|
|
{
|
|
SortList(mCurrentSortType);
|
|
SelectListByJobAndFraction();
|
|
|
|
RefreshUpperSortBtn();
|
|
RefreshScrollView();
|
|
|
|
}
|
|
private bool ShowIfNull()
|
|
{
|
|
if (mShowList.Count == 0)
|
|
{
|
|
FindObj("Nothing").SetActive(true);
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
FindObj("Nothing").SetActive(false);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private void RegisterEvent()
|
|
{
|
|
EventManager.Instance.Register(EventManager.EventName.EN_ShowAllCharacterSortType, OnReceiveShowAllCharacterSortEvent);
|
|
EventManager.Instance.Register(EventManager.EventName.EN_CharacterLevelUp, (Action<UpgradeType>)OnCharacterLevelup);
|
|
|
|
//EventManager.Instance.Register(EventManager.EventName.TeamUpdate, OnTeamUpdate);
|
|
}
|
|
|
|
private void OnCharacterLevelup(UpgradeType type)
|
|
{
|
|
if(type!=UpgradeType.UtLevel)
|
|
{
|
|
return;
|
|
}
|
|
GetStorageData();
|
|
RefreshUI();
|
|
}
|
|
|
|
|
|
private void UnRegisterEvent()
|
|
{
|
|
EventManager.Instance.Unregister(EventManager.EventName.EN_ShowAllCharacterSortType, OnReceiveShowAllCharacterSortEvent);
|
|
EventManager.Instance.Register(EventManager.EventName.EN_CharacterLevelUp, (Action<UpgradeType>)OnCharacterLevelup);
|
|
|
|
//EventManager.Instance.Unregister(EventManager.EventName.TeamUpdate, OnTeamUpdate);
|
|
}
|
|
|
|
|
|
private void GetNeedInsObj()
|
|
{
|
|
FindObj("ScrollviewItem");
|
|
|
|
}
|
|
void OnReceiveShowAllCharacterSortEvent()
|
|
{
|
|
DebugUtil.Log("事件接收成功");
|
|
}
|
|
|
|
void SetScrollView()
|
|
{
|
|
_mCurrentScrollView.SetUpdateFunc(RefreshItem);
|
|
_mCurrentScrollView.SetItemCountFunc(GetCountFunc);
|
|
_mCurrentScrollView.UpdateData(false);
|
|
_mCurrentScrollView.SetButton(SetScrollviewItemButton);
|
|
}
|
|
|
|
private void SetScrollviewItemButton(GameObject obj)
|
|
{
|
|
for (int i = 0; i < 6; i++)
|
|
{
|
|
GameObject singleObj = CommonUtils.GetGameObject(obj, (i + 1).ToString());
|
|
if (singleObj != null)
|
|
{
|
|
ClearBind(CommonUtils.GetGameObject(singleObj, "Image_Poster"));
|
|
BindButton<GameObject>(CommonUtils.GetGameObject(singleObj, "Image_Poster"), On2DPicClick, singleObj);
|
|
}
|
|
}
|
|
}
|
|
int GetCountFunc()
|
|
{
|
|
int row;
|
|
if (mShowList.Count % 6 == 0)
|
|
{
|
|
row = mShowList.Count / 6;
|
|
}
|
|
else
|
|
{
|
|
row = mShowList.Count / 6 + 1;
|
|
}
|
|
return row;
|
|
}
|
|
|
|
private void RefreshScrollView()
|
|
{
|
|
_mCurrentScrollView.UpdateData(true);
|
|
|
|
}
|
|
private void SetScrollViewAll()
|
|
{
|
|
|
|
if (null != mCurrentScrollViewContentObj)
|
|
{
|
|
CommonUtils.DestoryAllChildGameObject(mCurrentScrollViewContentObj);
|
|
}
|
|
|
|
|
|
switch (_curOpenType)
|
|
{
|
|
case (OpenType.EditTeam):
|
|
{
|
|
SetScrollView_EditTeam();
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
SetScrollView();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void GetStorageData()
|
|
{
|
|
mStorageCharacterInfo.Clear();
|
|
mStorageCharacterInfo.AddRange(CharacterDataInfoManager.Instance.DataList);
|
|
|
|
}
|
|
void SortList(CharacterSortType ESortType)
|
|
{
|
|
mSortedCInfoList.Clear();
|
|
mSortedCInfoList.AddRange(mStorageCharacterInfo);
|
|
|
|
switch (ESortType)
|
|
{
|
|
case CharacterSortType.EAll:
|
|
return;
|
|
case CharacterSortType.EStar:
|
|
if (!IsSmall2Big)
|
|
{
|
|
mSortedCInfoList.Sort((a, b) => { return a.Cfg.StartStar.CompareTo(b.Cfg.StartStar); });
|
|
}
|
|
else
|
|
{
|
|
mSortedCInfoList.Sort((a, b) => { return b.Cfg.StartStar.CompareTo(a.Cfg.StartStar); });
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CharacterSortType.ELevel:
|
|
if (IsSmall2Big)
|
|
{
|
|
mSortedCInfoList.Sort((a, b) => { return b.Level.CompareTo(a.Level); });
|
|
|
|
}
|
|
else
|
|
{
|
|
mSortedCInfoList.Sort((a, b) => { return a.Level.CompareTo(b.Level); });
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CharacterSortType.EAwake:
|
|
if (IsSmall2Big)
|
|
{
|
|
mSortedCInfoList.Sort((a, b) => { return a.AwakeLevel.CompareTo(b.AwakeLevel); });
|
|
}
|
|
else
|
|
{
|
|
mSortedCInfoList.Sort((a, b) => { return b.AwakeLevel.CompareTo(a.AwakeLevel); });
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
case CharacterSortType.EBreak:
|
|
if (IsSmall2Big)
|
|
{
|
|
mSortedCInfoList.Sort((a, b) => { return a.BreakLevel.CompareTo(b.BreakLevel); });
|
|
|
|
}
|
|
else
|
|
{
|
|
mSortedCInfoList.Sort((a, b) => { return b.BreakLevel.CompareTo(a.BreakLevel); });
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CharacterSortType.ELikely:
|
|
if (IsSmall2Big)
|
|
{
|
|
mSortedCInfoList.Sort((a, b) => { return a.LikelyLevel.CompareTo(b.LikelyLevel); });
|
|
|
|
}
|
|
else
|
|
{
|
|
mSortedCInfoList.Sort((a, b) => { return b.LikelyLevel.CompareTo(a.LikelyLevel); });
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
DebugUtil.LogError("错误脱离switch");
|
|
throw new ArgumentOutOfRangeException(nameof(ESortType), ESortType, null);
|
|
}
|
|
|
|
}
|
|
|
|
void SelectListByJobAndFraction()
|
|
{
|
|
mShowList.Clear();
|
|
for (int i = 0; i < mSortedCInfoList.Count; i++)
|
|
{
|
|
if (IsEqual((int)mSortedCInfoList[i].Cfg.Fraction, mCurrentFraction)
|
|
&& (IsEqual((int)mSortedCInfoList[i].Cfg.Job, mCurrentJob)))
|
|
{
|
|
mShowList.Add(mSortedCInfoList[i]);
|
|
}
|
|
}
|
|
}
|
|
bool IsEqual(int cfg,int current)
|
|
{
|
|
if(current==0 || current == ALL_DROPDOWN_VALUE)
|
|
{
|
|
return true;
|
|
}
|
|
return cfg == current;
|
|
}
|
|
private void RefreshItem(int index, RectTransform item)
|
|
{
|
|
item.gameObject.SetActive(true);
|
|
for (int i = 0; i < 6; i++)
|
|
{
|
|
GameObject singleItem = CommonUtils.GetGameObject(item.gameObject, (i + 1).ToString());
|
|
if (index * 6 + i < mShowList.Count)
|
|
{
|
|
singleItem.SetActive(true);
|
|
CharacterDataInfo tempDataInfo = mShowList[index * 6 + i];
|
|
RefreshSingleItem(singleItem, tempDataInfo);
|
|
mUIHeadGoDic[singleItem] = tempDataInfo;
|
|
}
|
|
else
|
|
{
|
|
singleItem.SetActive(false);
|
|
}
|
|
}
|
|
|
|
}
|
|
public class CultivateStruct {
|
|
public List<CharacterDataInfo> showList;
|
|
public CharacterDataInfo info;
|
|
}
|
|
|
|
private async void On2DPicClick(GameObject go)
|
|
{
|
|
CharacterDataInfo info = mUIHeadGoDic[go];
|
|
CultivateStruct cultivateStruct = new CultivateStruct();
|
|
cultivateStruct.showList = mShowList;
|
|
cultivateStruct.info = info;
|
|
//await UIManager.AnimSwitchWindow(this, UIWindowCloseType.HideAndPush, UINameConst.UI_Cultivate, cultivateStruct);
|
|
await UIManager.Instance.OpenWindow(UINameConst.UI_Cultivate, cultivateStruct);
|
|
}
|
|
|
|
|
|
private async void RefreshSingleItem(GameObject go, CharacterDataInfo dataInfo)
|
|
{
|
|
|
|
CommonUtils.GetComponent<Image>(go, "Image_Poster/Image_Rect/Image_LevelBar").fillAmount = (float)dataInfo.Level / characterBreakCfg.Get(dataInfo.Cfg.RoleID, (int)dataInfo.BreakLevel).LevelLimit;
|
|
CommonUtils.GetComponent<TMP_Text>(go, "Image_Poster/Image_Rect/Image_LevelBar/Text_Level").text = dataInfo.Level.ToString();
|
|
CommonUtils.GetComponent<Image>(go, "Image_Poster/Image_Rect/Image_ProfessionLogo").sprite = await AssetManager.GetSingleton().LoadAssetAsync<Sprite>(TableManager.Instance.Tables.JobAttri.GetOrDefault((int)dataInfo.Cfg.Job).IconPath);
|
|
CommonUtils.GetComponent<TMP_Text>(go, "Image_Poster/Image_ColorCover/Image_CharacterName/Text_CharacterName").text =CommonUtils.GetLocalizeText( dataInfo.Cfg.Name);
|
|
|
|
CommonUtils.GetComponent<Image>(go, "Image_Mask").gameObject.SetActive(_curOpenType == OpenType.EditTeam && _curTeam.IsCharacterInTeam(dataInfo.Uid));
|
|
|
|
var cmp = CommonUtils.GetComponent<Image>(go, "Image_Poster");
|
|
CommonUtils.RefreshCharacter2DPic(cmp,dataInfo.Cfg.RoleID, CommonUtils.ECharacterPicPathType.SelectCharacter);
|
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
GameObject starGo = CommonUtils.GetGameObject(go, string.Format("Image_Poster/Image_ColorCover/Image_CharacterName/Stars/{0}", i + 1));
|
|
if ((i + 1) < dataInfo.Cfg.StartStar)
|
|
{
|
|
starGo.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
starGo.SetActive(false);
|
|
}
|
|
}
|
|
CommonUtils.GetGameObject(go, "DebugID").SetActive(DisplayIDForCeHua.IsDisplayID);
|
|
CommonUtils.GetComponent<TMP_Text>(go, "DebugID").text ="ID:"+ dataInfo.Cfg.RoleID;
|
|
}
|
|
|
|
private void On2DPicLoaded(Sprite sprite, Image image)
|
|
{
|
|
image.sprite= sprite;
|
|
}
|
|
|
|
void CloseCurWindow()
|
|
{
|
|
UnRegisterEvent();
|
|
CloseWindow();
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编队使用
|
|
/// </summary>
|
|
private void SetScrollView_EditTeam()
|
|
{
|
|
_mCurrentScrollView.SetUpdateFunc(RefreshItem_EditTeam);
|
|
_mCurrentScrollView.SetItemCountFunc(GetCountFunc_EditTeam);
|
|
_mCurrentScrollView.UpdateData(false);
|
|
_mCurrentScrollView.SetButton(SetScrollViewItemButton_EditTeam);
|
|
}
|
|
private void RefreshItem_EditTeam(int index, RectTransform item)
|
|
{
|
|
item.gameObject.SetActive(true);
|
|
int count = mShowList.Count + 1;
|
|
for (int i = 0; i < 6; i++)
|
|
{
|
|
GameObject singleItem = CommonUtils.GetGameObject(item.gameObject, (i + 1).ToString());
|
|
if (index * 6 + i < count)
|
|
{
|
|
singleItem.SetActive(true);
|
|
RefreshSingleItem_EditTeam(singleItem, index * 6 + i);
|
|
|
|
int realIdx = index * 6 + i - 1;
|
|
if (realIdx >= 0)
|
|
{
|
|
CharacterDataInfo tempDataInfo = mShowList[realIdx];
|
|
mUIHeadGoDic[singleItem] = tempDataInfo;
|
|
}
|
|
else
|
|
{
|
|
_goClearTeam = singleItem;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
singleItem.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
void RefreshSingleItem_EditTeam(GameObject go, int idx)
|
|
{
|
|
int realIdx = idx - 1;
|
|
if (realIdx < 0)
|
|
{
|
|
CommonUtils.GetGameObject(go, "Image_Poster").SetActive(false);
|
|
CommonUtils.GetGameObject(go, "Image_Mask").SetActive(false);
|
|
CommonUtils.GetGameObject(go, "Image_Clear").SetActive(true);
|
|
|
|
var imgBg = go.GetComponent<Image>();
|
|
if (imgBg)
|
|
{
|
|
var originColor = imgBg.color;
|
|
imgBg.color = new Color(originColor.r, originColor.g, originColor.b, 0);
|
|
}
|
|
|
|
CommonUtils.GetGameObject(go, "DebugID").SetActive(false);
|
|
}
|
|
else
|
|
{
|
|
CharacterDataInfo charDataInfo = mShowList[realIdx];
|
|
RefreshSingleItem(go, charDataInfo);
|
|
if (_curTeam.IsCharacterInTeam(charDataInfo.Uid))
|
|
{
|
|
CommonUtils.GetGameObject(go, "Image_Mask").SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
CommonUtils.GetGameObject(go, "Image_Mask").SetActive(false);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
private int GetCountFunc_EditTeam()
|
|
{
|
|
int row;
|
|
var count = mShowList.Count + 1;
|
|
if (count % 6 == 0)
|
|
{
|
|
row = count / 6;
|
|
}
|
|
else
|
|
{
|
|
row = count / 6 + 1;
|
|
}
|
|
return row;
|
|
}
|
|
|
|
private void SetScrollViewItemButton_EditTeam(GameObject obj)
|
|
{
|
|
for (int i = 0; i < 6; i++)
|
|
{
|
|
GameObject singleObj = CommonUtils.GetGameObject(obj, (i + 1).ToString());
|
|
if (singleObj != null)
|
|
{
|
|
ClearBind(CommonUtils.GetGameObject(singleObj, "Image_Poster"));
|
|
var go = CommonUtils.GetGameObject(singleObj, "Image_Clear");
|
|
if (go != null)
|
|
{
|
|
ClearBind(CommonUtils.GetGameObject(singleObj, "Image_Clear"));
|
|
BindButton<GameObject>(CommonUtils.GetGameObject(singleObj, "Image_Clear"), OnClickHeadClear, singleObj);
|
|
}
|
|
else
|
|
{
|
|
BindButton<GameObject>(CommonUtils.GetGameObject(singleObj, "Image_Poster"), OnClickHeadTeam_Edit, singleObj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void OnClickHeadTeam_Edit(GameObject go)
|
|
{
|
|
if (mUIHeadGoDic.TryGetValue(go, out var data))
|
|
{
|
|
if (data != null)
|
|
{
|
|
uint id = data.Uid;
|
|
if (_curTeam.IsCharacterInTeam(id))
|
|
{
|
|
var ids = _curTeam.GetCharacterIDs();
|
|
var idx = Array.IndexOf(ids, id);
|
|
if (idx >= 0)
|
|
{
|
|
EventManager.Instance.Send(EventManager.EventName.TeamEditModelClear, idx);
|
|
}
|
|
_curTeam.DoCharacterDown(id);
|
|
}
|
|
_curTeam.DoCharacterUp(_charIdx, id);
|
|
EventManager.Instance.Send(EventManager.EventName.TeamEditModelCreate,
|
|
new TeamPreviewNode.CharAddData{ID = id, Idx = _charIdx});
|
|
}
|
|
}
|
|
|
|
RefreshUI();
|
|
BackInTeam();
|
|
}
|
|
|
|
void OnClickHeadClear(GameObject go)
|
|
{
|
|
_curTeam.DoCharacterDown(_charIdx);
|
|
RefreshUI();
|
|
EventManager.Instance.Send(EventManager.EventName.TeamEditModelClear, _charIdx);
|
|
BackInTeam();
|
|
}
|
|
|
|
private void OnTeamUpdate()
|
|
{
|
|
//_curTeam = TeamEditManager.Instance.GetTeamByIndex(_curTeam.)
|
|
RefreshUI();
|
|
}
|
|
}
|