123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- using FairyGUI;
- using UI.ClothingFoster;
- using UI.CommonGame;
- namespace GFGGame
- {
- public class SuitFosterView : BaseWindow
- {
- private UI_SuitFosterUI _ui;
- private int _suitId;
- private int _index;
- private bool _canFoster;
- public override void Dispose()
- {
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- packageName = UI_SuitFosterUI.PACKAGE_NAME;
- _ui = UI_SuitFosterUI.Create();
- this.viewCom = _ui.target;
- this.viewCom.Center();
- // this.modal = true;
- // viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
- _ui.m_listMaterials.itemRenderer = ListMaterialItemRender;
- _ui.m_listPropertyAdd.itemRenderer = ListPropertyItemRender;
- _ui.m_btnFoster.onClick.Add(OnClickBtnFoster);
- }
- protected override void OnShown()
- {
- base.OnShown();
- _suitId = (int)(this.viewData as object[])[0];
- _index = (int)(this.viewData as object[])[1];
- _canFoster = true;
- SuitFosterCfg cfg = SuitFosterCfgArray.Instance.GetCfgs(_suitId)[_index];
- _ui.m_listMaterials.numItems = cfg.materialsArr.Length;
- int has = ItemDataManager.GetItemNum(cfg.costId);
- int need = cfg.costNum;
- UI_ComConsumeCurrency comConsume = UI_ComConsumeCurrency.Proxy(_ui.m_ComConsume);
- comConsume.m_txtHas.text = has.ToString();
- comConsume.m_txtNeed.text = need.ToString();
- if (_canFoster && has < need) _canFoster = false;
- }
- protected override void OnHide()
- {
- base.OnHide();
- }
- private void ListMaterialItemRender(int index, GObject obj)
- {
- UI_ListMaterialsItem item = UI_ListMaterialsItem.Proxy(obj);
- int[][] materialsArr = SuitFosterCfgArray.Instance.GetCfgs(_suitId)[_index].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 (_canFoster && has < need) _canFoster = false;
- }
- private void ListPropertyItemRender(int index, GObject obj)
- {
- UI_ListPropertyAddItem item = UI_ListPropertyAddItem.Proxy(obj);
- }
- private void OnClickBtnFoster()
- {
- if (!_canFoster)
- {
- PromptController.Instance.ShowFloatTextPrompt("材料不足");
- return;
- }
- }
- }
- }
|