|
@@ -0,0 +1,392 @@
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using FairyGUI;
|
|
|
+using UI.CommonGame;
|
|
|
+using UI.Main;
|
|
|
+using UnityEngine;
|
|
|
+
|
|
|
+namespace GFGGame
|
|
|
+{
|
|
|
+ public class FieldWorkChooseCardView : BaseWindow
|
|
|
+ {
|
|
|
+ private UI_StoryCardChooseUI _ui;
|
|
|
+ private List<CardData> cardList = new List<CardData>();
|
|
|
+ private static int _scoreType;
|
|
|
+ private int _selectedIndex = 0;
|
|
|
+ private int _cardId = 0; //记录打开界面时的竞技场词牌id
|
|
|
+ private int _skillId = 0;
|
|
|
+
|
|
|
+ private List<EffectUI> _effects = new List<EffectUI>();
|
|
|
+ private GComponent _comSelected;
|
|
|
+
|
|
|
+ private EffectUI _effectUI1;
|
|
|
+ private EffectUI _effectUI2;
|
|
|
+ private EffectUI _effectUI3;
|
|
|
+
|
|
|
+ public override void Dispose()
|
|
|
+ {
|
|
|
+ EffectUIPool.Recycle(_effectUI1);
|
|
|
+ _effectUI1 = null;
|
|
|
+ EffectUIPool.Recycle(_effectUI2);
|
|
|
+ _effectUI2 = null;
|
|
|
+ EffectUIPool.Recycle(_effectUI3);
|
|
|
+ _effectUI3 = null;
|
|
|
+
|
|
|
+ //EffectUIPool.Recycle(_effectUI3);
|
|
|
+ //_effectUI3 = null;
|
|
|
+ if (_comSelected != null)
|
|
|
+ {
|
|
|
+ _comSelected.RemoveFromParent();
|
|
|
+ _comSelected.Dispose();
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < _effects.Count; i++)
|
|
|
+ {
|
|
|
+ EffectUIPool.Recycle(_effects[i]);
|
|
|
+ _effects[i] = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_ui != null)
|
|
|
+ {
|
|
|
+ _ui.Dispose();
|
|
|
+ _ui = null;
|
|
|
+ }
|
|
|
+ base.Dispose();
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override void OnInit()
|
|
|
+ {
|
|
|
+ base.OnInit();
|
|
|
+ packageName = UI_StoryCardChooseUI.PACKAGE_NAME;
|
|
|
+ _ui = UI_StoryCardChooseUI.Create();
|
|
|
+ this.viewCom = _ui.target;
|
|
|
+ this.viewCom.Center();
|
|
|
+ this.modal = true;
|
|
|
+ viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
|
|
|
+
|
|
|
+ _ui.m_listCard.SetVirtual();
|
|
|
+ _ui.m_listCard.itemRenderer = RenderListCardItem;
|
|
|
+ _ui.m_listCard.onClickItem.Add(OnListCardItemClick);
|
|
|
+
|
|
|
+ _ui.m_listSkill.itemRenderer = RenderListSkillItem;
|
|
|
+
|
|
|
+ _ui.m_btnCancel.onClick.Add(OnBtnCancelClick);
|
|
|
+ _ui.m_btnConfirm.onClick.Add(OnBtnComfirmClick);
|
|
|
+ _ui.m_btnUpCard.onClick.Add(OnBtnUpCardClikc);
|
|
|
+
|
|
|
+ _comSelected = UIPackage.CreateObject(UI_MainUI.PACKAGE_NAME, "ComCardSelect").asCom;
|
|
|
+ //_effectUI3 = EffectUIPool.CreateEffectUI(_comSelected.GetChild("holder").asGraph, "ui_fight_new", "kp_Select");
|
|
|
+ AddEffect();
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override void OnShown()
|
|
|
+ {
|
|
|
+ base.OnShown();
|
|
|
+
|
|
|
+ _scoreType = (int)this.viewData;
|
|
|
+
|
|
|
+ cardList = CardDataManager.GetCardListByRoleType(0);
|
|
|
+ if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.FieldWork)
|
|
|
+ {
|
|
|
+ //其他主题带的cardIds
|
|
|
+ var otherThemeCardIds = new HashSet<int>();
|
|
|
+ for (int i = 0; i < FieldWorkDataManager.Instance.DressupList.Count; i++)
|
|
|
+ {
|
|
|
+ if (FieldWorkDataManager.Instance.SelectThemeIndex == i)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ otherThemeCardIds.Add(FieldWorkDataManager.Instance.DressupList[i].cardId);
|
|
|
+ }
|
|
|
+
|
|
|
+ //去掉已经在其他主题装配的cardList
|
|
|
+ cardList = cardList.Where(a => !otherThemeCardIds.Contains(a.id)).ToList();
|
|
|
+ }
|
|
|
+
|
|
|
+ float dressListAllAcore =
|
|
|
+ FightDataManager.Instance.GetDressListAllScore(MyDressUpHelper.dressUpObj.itemList, _scoreType);
|
|
|
+ cardList = FightDataManager.Instance.SortCardList(cardList, dressListAllAcore, _scoreType);
|
|
|
+ if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.FieldWork)
|
|
|
+ {
|
|
|
+ cardList = FieldWorkDataManager.Instance.SortCardList(cardList);
|
|
|
+ }
|
|
|
+ _ui.m_listCard.numItems = cardList.Count;
|
|
|
+ _ui.m_listCard.selectedIndex = 0;
|
|
|
+
|
|
|
+ if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.FieldWork)
|
|
|
+ {
|
|
|
+ _cardId = FieldWorkDataManager.Instance.DressupList[FieldWorkDataManager.Instance.SelectThemeIndex].cardId;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (cardList.Count == 0)
|
|
|
+ {
|
|
|
+ OnCardSelected(0);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ OnCardSelected(cardList[0].id);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ UpdateView(0);
|
|
|
+
|
|
|
+ Timers.inst.AddUpdate(CheckGuide);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void UpdateView(int index)
|
|
|
+ {
|
|
|
+ // CardData cardData = cardList[index];
|
|
|
+ _ui.m_loaScore.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + _scoreType);
|
|
|
+ int cardId;
|
|
|
+ if (cardList.Count == 0)
|
|
|
+ {
|
|
|
+ cardId = 0;
|
|
|
+ _ui.m_noCardTips.visible = true;
|
|
|
+ _ui.m_noCardTips.text = "暂无可用词牌";
|
|
|
+ _ui.m_listSkill.numItems = cardList.Count;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ _ui.m_noCardTips.visible = false;
|
|
|
+ cardId = cardList[index].id;
|
|
|
+ }
|
|
|
+ _ui.m_txtName.text = "无";
|
|
|
+
|
|
|
+ PassivitySkillCfg cfg = ScoreSystemData.Instance.GetShowSkillCfg(cardId);
|
|
|
+ if (cfg == null) return;
|
|
|
+ _ui.m_txtName.text = cardList[index].itemCfg.name;
|
|
|
+
|
|
|
+ List<PassivitySkillCfg> skillCfgs = PassivitySkillCfgArray.Instance.GetCfgsBycardId(cardId);
|
|
|
+ _ui.m_listSkill.data = skillCfgs;
|
|
|
+ _ui.m_listSkill.numItems = skillCfgs.Count;
|
|
|
+ _ui.m_comSkillTips.target.visible = false;
|
|
|
+ _selectedIndex = index;
|
|
|
+ int childIndex = _ui.m_listCard.ItemIndexToChildIndex(index);
|
|
|
+ _ui.m_listCard.GetChildAt(childIndex).asCom.AddChild(_comSelected);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void RenderListSkillItem(int index, GObject obj)
|
|
|
+ {
|
|
|
+ List<PassivitySkillCfg> skillCfgs = obj.parent.data as List<PassivitySkillCfg>;
|
|
|
+ UI_ListCardSkillItem item = UI_ListCardSkillItem.Proxy(obj);
|
|
|
+ item.m_loaSkill.url = ResPathUtil.GetCardSkillPath(skillCfgs[index].res);
|
|
|
+ item.m_txtLv.text = SkillDataManager.Instance
|
|
|
+ .GetCardSkillLv(skillCfgs[index].cardId, skillCfgs[index].skillId).ToString();
|
|
|
+ if (item.target.data == null)
|
|
|
+ item.target.onClick.Add(OnSkillItemClick);
|
|
|
+
|
|
|
+ item.target.data = index; // skillCfgs[index];
|
|
|
+ UI_ListCardSkillItem.ProxyEnd();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void OnSkillItemClick(EventContext context)
|
|
|
+ {
|
|
|
+ GObject gObject = context.sender as GObject;
|
|
|
+ int index = (int)gObject.data;
|
|
|
+ List<PassivitySkillCfg> skillCfgs =
|
|
|
+ PassivitySkillCfgArray.Instance.GetCfgsBycardId(cardList[_selectedIndex].id);
|
|
|
+
|
|
|
+ PassivitySkillCfg skillCfg = skillCfgs[index];
|
|
|
+ _ui.m_comSkillTips.target.visible = _skillId != skillCfg.skillId;
|
|
|
+
|
|
|
+ Vector2 posInA = _ui.m_listSkill.GetChildAt(index).asCom.position;
|
|
|
+ Vector2 posInB = _ui.m_listSkill.TransformPoint(posInA, _ui.target);
|
|
|
+ _ui.m_comSkillTips.target.SetPosition(posInB.x, posInB.y + 110, 0);
|
|
|
+
|
|
|
+ _ui.m_comSkillTips.m_txtName.text = skillCfg.name;
|
|
|
+ int skillLv = SkillDataManager.Instance.GetCardSkillLv(skillCfg.cardId, skillCfg.skillId);
|
|
|
+ PassivitySkillLvlCfg skillLvlCfg =
|
|
|
+ PassivitySkillLvlCfgArray.Instance.GetCfgByskilllvlAndskillId(skillLv, skillCfg.skillId);
|
|
|
+ _ui.m_comSkillTips.m_txtSkillTips.text = skillLvlCfg.describe;
|
|
|
+
|
|
|
+ _skillId = skillCfg.skillId;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void RenderListCardItem(int index, GObject obj)
|
|
|
+ {
|
|
|
+ CardData cardData = cardList[index];
|
|
|
+ UI_ListCardFightItem item = UI_ListCardFightItem.Proxy(obj); // obj as GButton;
|
|
|
+ item.m_txtName.text = cardData.itemCfg.name;
|
|
|
+ item.m_comCardMask.m_loaCard.asLoader.url =
|
|
|
+ ResPathUtil.GetCardIconPath(cardData.resources[cardData.resIndex]);
|
|
|
+ item.m_txtLv.text = string.Format("{0}级", cardData.lv);
|
|
|
+ // item.m_loaRarity.url = ResPathUtil.GetCommonGameResPath("kp_sxing_x_" + cardData.itemCfg.rarity);
|
|
|
+ RarityIconController.UpdateRarityIcon(item.m_loaRarity, cardData.itemCfg.id,
|
|
|
+ false); // ResPathUtil.GetCommonGameResPath("kp_sxing_x_" + data.itemCfg.rarity);
|
|
|
+ item.m_loaMainScore.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + (cardData.itemCfg.mainScore));
|
|
|
+ item.m_loaBorder.url = "ui://CommonGame/kp_kuang_" + cardData.itemCfg.rarity;
|
|
|
+ // UI_ComStar comStar = UI_ComStar.Proxy(item.m_comStar);
|
|
|
+
|
|
|
+ int starLevelDodge = cardData.star / 6;
|
|
|
+ item.m_starNumType.selectedIndex = cardData.itemCfg.starDescArr.Length - 1;
|
|
|
+ for (int i = 0; i < 4; i++)
|
|
|
+ {
|
|
|
+ UI_ComDodgeFightStar dodgeStar = UI_ComDodgeFightStar.Proxy(item.target.GetChild("dodgeStar" + i));
|
|
|
+ dodgeStar.m_lightType.selectedIndex = (starLevelDodge > i) ? 1 : 0;
|
|
|
+ UI_ComDodgeFightStar.ProxyEnd();
|
|
|
+ }
|
|
|
+
|
|
|
+ // comStar.m_c1.selectedIndex = cardData.star;
|
|
|
+ if (_effects.Count <= index)
|
|
|
+ {
|
|
|
+ //EffectUI _effectUI = EffectUIPool.CreateEffectUI(item.m_comEff.m_holder, "ui_fight_new", "kp_Select");
|
|
|
+ // _effects.Add(_effectUI);
|
|
|
+ }
|
|
|
+ if (index == 0)
|
|
|
+ {
|
|
|
+ item.m_useIcon.visible = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ item.m_useIcon.visible = false;
|
|
|
+ }
|
|
|
+ if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.FieldWork)
|
|
|
+ {
|
|
|
+ item.m_fieldwork.visible = true;
|
|
|
+ item.m_useIcon.visible = false;
|
|
|
+ item.m_wearRateText.text = FieldWorkDataManager.Instance.GetCardAbrasion(cardData.itemCfg.id).ToString() + "%";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ item.m_fieldwork.visible = false;
|
|
|
+ }
|
|
|
+ item.target.asCom.RemoveChild(_comSelected);
|
|
|
+ if (_selectedIndex == index)
|
|
|
+ {
|
|
|
+ item.target.asCom.AddChild(_comSelected);
|
|
|
+ }
|
|
|
+
|
|
|
+ UI_ListCardFightItem.ProxyEnd();
|
|
|
+ // UI_ComStar.ProxyEnd();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void OnListCardItemClick(EventContext context)
|
|
|
+ {
|
|
|
+ GObject obj = context.data as GObject;
|
|
|
+ UI_ListCardFightItem item = UI_ListCardFightItem.Proxy(obj);
|
|
|
+ if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.FieldWork)
|
|
|
+ {
|
|
|
+ if (FieldWorkDataManager.Instance.GetCardAbrasion(cardList[_ui.m_listCard.selectedIndex].id) >= 100)
|
|
|
+ {
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt("卡牌磨损程度已无法使用!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ item.m_t0.Play();
|
|
|
+ EffectUIPool.Recycle(_effectUI3);
|
|
|
+ _effectUI3 = null;
|
|
|
+ _effectUI3 = EffectUIPool.CreateEffectUI(item.m_effect, "ui_KP", "KP_Select");
|
|
|
+
|
|
|
+ UpdateView(_ui.m_listCard.selectedIndex);
|
|
|
+
|
|
|
+ OnCardSelected(cardList[_ui.m_listCard.selectedIndex].id);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void OnCardSelected(int cardId)
|
|
|
+ {
|
|
|
+ if (cardId == 0)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.FieldWork)
|
|
|
+ {
|
|
|
+ FieldWorkDataManager dataManager = FieldWorkDataManager.Instance;
|
|
|
+ dataManager.DressupList[dataManager.SelectThemeIndex].cardId = cardId;
|
|
|
+ ArenaDataManager.Instance.SetMineFightAttr(dataManager.DressupList[dataManager.SelectThemeIndex],
|
|
|
+ dataManager.ThemeList[dataManager.SelectThemeIndex]);
|
|
|
+ EventAgent.DispatchEvent(ConstMessage.CARD_SELECTED);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void OnBtnUpCardClikc()
|
|
|
+ {
|
|
|
+ if (cardList.Count == 0) return;
|
|
|
+ cardList[_ui.m_listCard.selectedIndex].fromUIType = typeof(StoryCardChoose).FullName;
|
|
|
+ ViewManager.Show<CardFosterView>(cardList[_ui.m_listCard.selectedIndex]);
|
|
|
+ this.Hide();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void OnBtnComfirmClick()
|
|
|
+ {
|
|
|
+ //搭配时没有词牌特殊处理
|
|
|
+ if (cardList.Count == 0)
|
|
|
+ {
|
|
|
+ if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.FieldWork)
|
|
|
+ {
|
|
|
+ ViewManager.Show<FieldWorkDressFightView>(new object[] { FightRoleType.FieldWork, 0, FieldWorkDataManager.Instance.DressupList, "" }, true);
|
|
|
+ }
|
|
|
+ this.Hide();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ int cardId = cardList[_ui.m_listCard.selectedIndex].id;
|
|
|
+ if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.FieldWork)
|
|
|
+ {
|
|
|
+ if (FieldWorkDataManager.Instance.GetCardAbrasion(cardId) >= 100)
|
|
|
+ {
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt("当前词牌损耗度过高无法使用!");
|
|
|
+ //return;
|
|
|
+ }
|
|
|
+ FieldWorkDataManager dataManager = FieldWorkDataManager.Instance;
|
|
|
+ dataManager.DressupList[dataManager.SelectThemeIndex].itemList = MyDressUpHelper.dressUpObj.itemList;
|
|
|
+ FieldWorkSproxy.ReqChangeFieldWorkDressupOne(dataManager.SelectThemeIndex, cardId, MyDressUpHelper.dressUpObj.itemList).Coroutine();
|
|
|
+ ViewManager.GoBackFrom(typeof(FieldWorkDressFightView).FullName);
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt("保存成功");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ this.Hide();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void OnBtnCancelClick()
|
|
|
+ {
|
|
|
+ OnCardSelected(_cardId);
|
|
|
+ this.Hide();
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override void OnHide()
|
|
|
+ {
|
|
|
+ base.OnHide();
|
|
|
+ _skillId = 0;
|
|
|
+ _ui.m_listCard.ScrollToView(0);
|
|
|
+ Timers.inst.Remove(CheckGuide);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CheckGuide(object param)
|
|
|
+ {
|
|
|
+ if ((GuideDataManager.IsGuideFinish(ConstGuideId.FIELD) <= 0 && InstanceZonesDataManager.FightScene == ConstInstanceZonesType.FieldWork && InstanceZonesDataManager.CheckLevelPass(FieldWorkDataManager.Instance.guideLevelID)))
|
|
|
+ {
|
|
|
+ UpdateToCheckGuide(null);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Timers.inst.Remove(CheckGuide);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override void UpdateToCheckGuide(object param)
|
|
|
+ {
|
|
|
+ if (!ViewManager.CheckIsTopView(this.viewCom)) return;
|
|
|
+ if ((GuideDataManager.IsGuideFinish(ConstGuideId.FIELD) <= 0 && InstanceZonesDataManager.FightScene == ConstInstanceZonesType.FieldWork))
|
|
|
+ {
|
|
|
+ GuideController.TryGuide(_ui.m_listCard, ConstGuideId.FIELD, 10, "战斗结束时使用过的词牌会根据对应的关卡难度形成不同程度损耗关卡的难度合理搭配阵容!", 0);
|
|
|
+ GuideController.TryGuide(_ui.m_btnConfirm, ConstGuideId.FIELD, 11, "确认!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void AddEffect()
|
|
|
+ {
|
|
|
+ //邊框左上角特效
|
|
|
+ _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_holderLeftTop, "ui_Activity", "Com_window_L_up");
|
|
|
+
|
|
|
+ //邊框右下角特效
|
|
|
+ _effectUI2 = EffectUIPool.CreateEffectUI(_ui.m_holderRightDowm, "ui_Activity", "Com_window_R_Down");
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|