|
@@ -2,7 +2,9 @@ using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using FairyGUI;
|
|
|
using UI.ClothingFoster;
|
|
|
+using UI.CommonGame;
|
|
|
using UnityEngine;
|
|
|
+using ET;
|
|
|
|
|
|
namespace GFGGame
|
|
|
{
|
|
@@ -18,9 +20,12 @@ namespace GFGGame
|
|
|
|
|
|
private List<int> _suitIds;//已解锁套装列表
|
|
|
private SortedList _propertyList;
|
|
|
+ private SortedList _addPropertyList;
|
|
|
private int _suitId;
|
|
|
private int _index;
|
|
|
|
|
|
+ private bool _canRenew;
|
|
|
+
|
|
|
public override void Dispose()
|
|
|
{
|
|
|
|
|
@@ -45,11 +50,24 @@ namespace GFGGame
|
|
|
_ui.m_btnBack.onClick.Add(OnClickBtnBack);
|
|
|
_ui.m_btnLeft.onClick.Add(() => { OnClickBtnDirection(-1); });
|
|
|
_ui.m_btnRight.onClick.Add(() => { OnClickBtnDirection(1); });
|
|
|
- _ui.m_btnReward.target.onClick.Add(OnClickBtnReward);
|
|
|
+ _ui.m_comFosterReward.target.onClick.Add(OnClickComFosterReward);
|
|
|
_ui.m_btnPropertyShow.onClick.Add(OnClickBtnPropertyShow);
|
|
|
|
|
|
_ui.m_listFoster.itemRenderer = ListFosterItemRender;
|
|
|
_ui.m_listFoster.onClickItem.Add(OnClickListFosterItem);
|
|
|
+ _ui.m_listProperty.itemRenderer = ListPropertyItemRender;
|
|
|
+
|
|
|
+
|
|
|
+ _ui.m_listRenewMaterial.itemRenderer = ListRenewMaterialItemRender;
|
|
|
+ _ui.m_listRenewMaterial.onClickItem.Add(OnListRenewMaterialsItem);
|
|
|
+ _ui.m_btnRenew.onClick.Add(OnClickBtnRenew);
|
|
|
+
|
|
|
+ _ui.m_c1.onChanged.Add(OnTabChange);
|
|
|
+
|
|
|
+ // EventAgent.AddEventListener(ConstMessage.GET_SUIT_INFOS)
|
|
|
+ EventAgent.AddEventListener(ConstMessage.MAINTAIN_SUIT, OnListenerFoster);
|
|
|
+ EventAgent.AddEventListener(ConstMessage.GET_MAINTAIN_SUIT_BONUS, OnListenerGetFosterReward);
|
|
|
+ EventAgent.AddEventListener(ConstMessage.MAKE_NEW_SUIT, OnListenerRenew);
|
|
|
}
|
|
|
|
|
|
protected override void OnShown()
|
|
@@ -80,16 +98,26 @@ namespace GFGGame
|
|
|
{
|
|
|
ViewManager.GoBackFrom(typeof(SuitView).FullName);
|
|
|
}
|
|
|
+ private void OnTabChange()
|
|
|
+ {
|
|
|
+ if (_ui.m_c1.selectedIndex == 0)
|
|
|
+ {
|
|
|
+ UpdateFoster();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ UpdateRenew();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
private void UpdateView()
|
|
|
{
|
|
|
UpdateArrows();
|
|
|
UpdateSuitView();
|
|
|
-
|
|
|
- _ui.m_listFoster.numItems = SuitFosterCfgArray.Instance.GetCfgs(_suitId).Length;
|
|
|
- _propertyList = SuitFosterDataManager.Instance.GetPropertyData(_suitId, _index);
|
|
|
- _ui.m_listProperty.numItems = _propertyList.Count;
|
|
|
+ UpdateFoster();
|
|
|
+ UpdateRenew();
|
|
|
}
|
|
|
+
|
|
|
private void UpdateArrows()
|
|
|
{
|
|
|
int index = _suitIds.IndexOf(_suitId);
|
|
@@ -98,16 +126,7 @@ namespace GFGGame
|
|
|
_ui.m_btnLeft.visible = (index - 1 >= 0);
|
|
|
}
|
|
|
|
|
|
- private void OnClickBtnDirection(int direction)
|
|
|
- {
|
|
|
- int index = _suitIds.IndexOf(_suitId);
|
|
|
- int targetIndex = index + direction;
|
|
|
- if (targetIndex >= 0 && direction == -1 || targetIndex < _suitIds.Count && direction == 1)
|
|
|
- {
|
|
|
- _suitId = _suitIds[targetIndex];
|
|
|
- UpdateView();
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
private void UpdateSuitView(bool isPic = true)
|
|
|
{
|
|
|
_actionIsPic = isPic;
|
|
@@ -134,33 +153,188 @@ namespace GFGGame
|
|
|
_wrapper.wrapTarget = _sceneObject;
|
|
|
}
|
|
|
}
|
|
|
+ private void OnClickBtnDirection(int direction)
|
|
|
+ {
|
|
|
+ int index = _suitIds.IndexOf(_suitId);
|
|
|
+ int targetIndex = index + direction;
|
|
|
+ if (targetIndex >= 0 && direction == -1 || targetIndex < _suitIds.Count && direction == 1)
|
|
|
+ {
|
|
|
+ _suitId = _suitIds[targetIndex];
|
|
|
+ UpdateView();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /*************************************************养护************************************************/
|
|
|
|
|
|
-
|
|
|
+ private void UpdateFoster()
|
|
|
+ {
|
|
|
+ UpdateFosterReward();
|
|
|
+ SuitFosterDataManager.Instance.GetPropertyData(_suitId, _index, out _propertyList, out _addPropertyList);
|
|
|
+ _ui.m_listProperty.numItems = _propertyList.Count;
|
|
|
+ _ui.m_listFoster.numItems = SuitFosterCfgArray.Instance.GetCfgs(_suitId).Length;
|
|
|
+ }
|
|
|
+ private void UpdateFosterReward()
|
|
|
+ {
|
|
|
+ SuitFosterDataManager.Instance.GetFosterRewardState(_suitId, out int state, out int index);
|
|
|
+ SuitFosterCfg cfg = SuitFosterCfgArray.Instance.GetCfgs(_suitId)[index];
|
|
|
+ ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(cfg.rewardsArr[0][0]);
|
|
|
+ _ui.m_comFosterReward.m_loaReward.url = ResPathUtil.GetIconPath(itemCfg);
|
|
|
+ _ui.m_comFosterReward.m_c1.selectedIndex = state;
|
|
|
+ }
|
|
|
|
|
|
private void ListFosterItemRender(int index, GObject obj)
|
|
|
{
|
|
|
UI_ListFosterItem item = UI_ListFosterItem.Proxy(obj);
|
|
|
item.target.data = index;
|
|
|
+ item.m_finish.selectedIndex = SuitFosterDataManager.Instance.GetFosterState(_suitId, index);
|
|
|
if (SuitFosterDataManager.Instance.GetSuitFosterData(_suitId).maintainStep == index)
|
|
|
{
|
|
|
_index = index;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private void ListPropertyItemRender(int index, GObject obj)
|
|
|
+ {
|
|
|
+ UI_ListPropertyItem item = UI_ListPropertyItem.Proxy(obj);
|
|
|
+ int score = (int)_propertyList.GetKey(index);
|
|
|
+ item.m_txtProperty.text = _propertyList[score].ToString();
|
|
|
+ item.m_loaIcon.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + (score));
|
|
|
+ }
|
|
|
+
|
|
|
private void OnClickListFosterItem(EventContext context)
|
|
|
{
|
|
|
int index = (int)(context.data as GObject).data;
|
|
|
- if (index == _index)
|
|
|
+ int state = SuitFosterDataManager.Instance.GetFosterState(_suitId, index);
|
|
|
+ if (state == 0)
|
|
|
+ {
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt("已完成该阶段");
|
|
|
+ }
|
|
|
+ else if (state == 1)
|
|
|
+ {
|
|
|
+ ViewManager.Show<SuitFosterView>(new object[] { _suitId, index, _propertyList, _addPropertyList });
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- ViewManager.Show<SuitFosterView>(new object[] { _suitId, index });
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt(string.Format("请完成{0}阶段", SuitFosterDataManager.Instance.stepNames[_index]));
|
|
|
}
|
|
|
+ SuitFosterHelper.SendMaintainSuit(_suitId, index + 1).Coroutine();
|
|
|
}
|
|
|
- private void OnClickBtnReward()
|
|
|
+ private void OnClickComFosterReward()
|
|
|
{
|
|
|
- ViewManager.Show<SuitRewardView>(_suitId);
|
|
|
+ SuitFosterDataManager.Instance.GetFosterRewardState(_suitId, out int state, out int index);
|
|
|
+ if (state == 1 || state == 2)
|
|
|
+ {
|
|
|
+ ViewManager.Show<SuitRewardView>(_suitId);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SuitFosterHelper.SendGetMaintainSuitBonus(_suitId, index + 1).Coroutine();
|
|
|
+ }
|
|
|
}
|
|
|
private void OnClickBtnPropertyShow()
|
|
|
{
|
|
|
ViewManager.Show<SuitPropertyShowView>(new object[] { _suitId, _index });
|
|
|
}
|
|
|
+
|
|
|
+ private void OnListenerFoster()
|
|
|
+ {
|
|
|
+ _ui.m_comFosterAni.target.visible = true;
|
|
|
+ _ui.m_comFosterAni.m_proFoster.value = 0;
|
|
|
+ _ui.m_comFosterAni.m_proFoster.TweenValue(100, 2f).OnComplete(() =>
|
|
|
+ {
|
|
|
+ _ui.m_comFosterAni.target.visible = false;
|
|
|
+ ViewManager.Show<SuitFosterFinishView>(_propertyList);
|
|
|
+ UpdateFoster();
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ private void OnListenerGetFosterReward(EventContext context)
|
|
|
+ {
|
|
|
+ SuitFosterCfg cfg = SuitFosterCfgArray.Instance.GetCfgs(_suitId)[(int)(context.data) - 1];
|
|
|
+ ViewManager.Show<RewardView>(ItemUtil.CreateItemDataList(cfg.rewardsArr));
|
|
|
+ UpdateFosterReward();
|
|
|
+ }
|
|
|
+ /*************************************************换新************************************************/
|
|
|
+ private void UpdateRenew()
|
|
|
+ {
|
|
|
+ SuitFosterData suitFosterData = SuitFosterDataManager.Instance.GetSuitFosterData(_suitId);
|
|
|
+ if (suitFosterData.makeNewState > 0)
|
|
|
+ {
|
|
|
+ _ui.m_c2.selectedIndex = 1;
|
|
|
+ UpdateRenewFinish();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ _ui.m_c2.selectedIndex = 0;
|
|
|
+ UpdateRenewView();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void UpdateRenewView()
|
|
|
+ {
|
|
|
+ int suitrarity = SuitCfgArray.Instance.GetCfg(_suitId).rarity;
|
|
|
+ SuitRenewCfg renewCfg = SuitRenewCfgArray.Instance.GetCfg(suitrarity);
|
|
|
+ SuitFosterListCfg cfg = SuitFosterListCfgArray.Instance.GetCfg(_suitId);
|
|
|
+ _ui.m_comRenewReward.m_loaReward.visible = false;
|
|
|
+ if (cfg.renewRewardsArr.Length > 0)
|
|
|
+ {
|
|
|
+ _ui.m_comRenewReward.m_loaReward.visible = true;
|
|
|
+ ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(cfg.renewRewardsArr[0][0]);
|
|
|
+ _ui.m_comRenewReward.m_loaReward.url = ResPathUtil.GetIconPath(itemCfg);
|
|
|
+ }
|
|
|
+ _ui.m_txtRenewProperty.text = string.Format("套装所有部件属性+{0}%", renewCfg.addition * 100 / 10000);
|
|
|
+ _ui.m_txtRenewTips.text = string.Format("完成{0}阶段", SuitFosterDataManager.Instance.stepNames[cfg.renewOpenLv - 1]);
|
|
|
+ _ui.m_listRenewMaterial.numItems = renewCfg.materialsArr.Length;
|
|
|
+
|
|
|
+ _canRenew = true;
|
|
|
+ UI_ComConsumeCurrency comConsumeCurrency = UI_ComConsumeCurrency.Proxy(_ui.m_comRenewCost);
|
|
|
+ int has = ItemDataManager.GetItemNum(renewCfg.costId);
|
|
|
+ int need = renewCfg.costNum;
|
|
|
+ // comConsumeCurrency.m_txtHas.text = has.ToString();
|
|
|
+ comConsumeCurrency.m_txtNeed.text = need.ToString();
|
|
|
+ if (_canRenew && has < need) _canRenew = false;
|
|
|
+ }
|
|
|
+ private void UpdateRenewFinish()
|
|
|
+ {
|
|
|
+ int suitrarity = SuitCfgArray.Instance.GetCfg(_suitId).rarity;
|
|
|
+ SuitRenewCfg renewCfg = SuitRenewCfgArray.Instance.GetCfg(suitrarity);
|
|
|
+ SuitFosterListCfg cfg = SuitFosterListCfgArray.Instance.GetCfg(_suitId);
|
|
|
+ _ui.m_txtRenewShow.text = string.Format("套装所有部件属性+{0}%", renewCfg.addition * 100 / 10000);
|
|
|
+ ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(cfg.renewRewardsArr[0][0]);
|
|
|
+ _ui.m_comRenewRewardGet.m_loaReward.url = ResPathUtil.GetIconPath(itemCfg);
|
|
|
+
|
|
|
+ }
|
|
|
+ private void ListRenewMaterialItemRender(int index, GObject obj)
|
|
|
+ {
|
|
|
+ UI_ListMaterialsItem item = UI_ListMaterialsItem.Proxy(obj);
|
|
|
+ int suitrarity = SuitCfgArray.Instance.GetCfg(_suitId).rarity;
|
|
|
+ int[][] materialsArr = SuitRenewCfgArray.Instance.GetCfg(suitrarity).materialsArr;
|
|
|
+ ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(materialsArr[index][0]);
|
|
|
+ item.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
|
|
|
+ int has = ItemDataManager.GetItemNum(itemCfg.id);
|
|
|
+ item.m_txtHas.text = has.ToString();
|
|
|
+ int need = materialsArr[index][1];
|
|
|
+ item.m_txtNeed.text = StringUtil.GetColorText(need.ToString(), has >= need ? "#DD994A" : "#DD994A");
|
|
|
+ if (_canRenew && has < need) _canRenew = false;
|
|
|
+ item.target.data = materialsArr[index][0];
|
|
|
+ }
|
|
|
+ private void OnListRenewMaterialsItem(EventContext context)
|
|
|
+ {
|
|
|
+ int itemId = (int)(context.data as GComponent).data;
|
|
|
+ GoodsItemTipsController.ShowItemTips(itemId);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void OnClickBtnRenew()
|
|
|
+ {
|
|
|
+
|
|
|
+ if (!_canRenew)
|
|
|
+ {
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt("材料不足");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void OnListenerRenew()
|
|
|
+ {
|
|
|
+ ViewManager.Show<SuitRenewFinishView>(_suitId);
|
|
|
+ UpdateRenew();
|
|
|
+ }
|
|
|
}
|
|
|
}
|