首次提交
This commit is contained in:
32
Assets/Scripts/UI/Shops/FishingShopPanel.Designer.cs
generated
Normal file
32
Assets/Scripts/UI/Shops/FishingShopPanel.Designer.cs
generated
Normal file
@@ -0,0 +1,32 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改,生成插件文档及项目地址:https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
|
||||
|
||||
using FairyGUI;
|
||||
using FairyGUI.Utils;
|
||||
using NBC;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
/// <summary> </summary>
|
||||
public partial class FishingShopPanel
|
||||
{
|
||||
public GObject this[string aKey] => ContentPane.GetChild(aKey);
|
||||
public override string UIPackName => "Main";
|
||||
public override string UIResName => "FishingShopPanel";
|
||||
|
||||
[AutoFind(Name = "loading")]
|
||||
public Controller loading;
|
||||
[AutoFind(Name = "ItemList")]
|
||||
public CommonItemList ItemList;
|
||||
[AutoFind(Name = "Loading")]
|
||||
public GLabel Loading;
|
||||
public override string[] GetDependPackages(){ return new string[] {"Common","CommonNew"}; }
|
||||
|
||||
public static void Show(object param = null){ UI.Inst.OpenUI<FishingShopPanel>(param); }
|
||||
|
||||
public static void Hide(){ UI.Inst.HideUI<FishingShopPanel>(); }
|
||||
|
||||
public static void Del(){ UI.Inst.DestroyUI<FishingShopPanel>(); }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 77b9a0646693d344b8dd031f4537c3c8
|
||||
127
Assets/Scripts/UI/Shops/FishingShopPanel.cs
Normal file
127
Assets/Scripts/UI/Shops/FishingShopPanel.cs
Normal file
@@ -0,0 +1,127 @@
|
||||
// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using FairyGUI;
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
using NBC;
|
||||
using NUnit.Framework;
|
||||
using UnityEngine;
|
||||
using Log = NBC.Log;
|
||||
using UIPanel = NBC.UIPanel;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class FishingShopPanel : UIPanel
|
||||
{
|
||||
protected override void OnInit()
|
||||
{
|
||||
base.OnInit();
|
||||
}
|
||||
|
||||
protected override void OnShow()
|
||||
{
|
||||
InputManager.Instance.On(this);
|
||||
ItemList.List.OnClickItem += OnClickItem;
|
||||
|
||||
GetShopData().Coroutine();
|
||||
|
||||
// List<TabItemData> tabItemList = GoodsConfigHelper.TabItemList;
|
||||
|
||||
// ItemList.SetData(tabItemList, true, true);
|
||||
}
|
||||
|
||||
private async FTask GetShopData()
|
||||
{
|
||||
Stopwatch stopwatch = Stopwatch.StartNew();
|
||||
|
||||
loading.selectedIndex = 0;
|
||||
var response = (Game2C_GetShopItemsResponse)await Net.Call(new C2Game_GetShopItemsRequest());
|
||||
//处理数据
|
||||
var tabItemList = response.Items.ToTabItemData();
|
||||
ItemList.SetData(tabItemList, true, true);
|
||||
loading.selectedIndex = 1;
|
||||
stopwatch.Stop();
|
||||
Log.Info("商店物品获取耗时=" + stopwatch.ElapsedMilliseconds);
|
||||
}
|
||||
|
||||
|
||||
private void OnClickItem(object item)
|
||||
{
|
||||
if (item is not ShopGearItem gearItem) return;
|
||||
// ItemDetailsPanel.s
|
||||
// ItemDetailsPanel.Show(bagItem.ItemInfo);
|
||||
ShopDetailsPanel.Show(gearItem.Info);
|
||||
}
|
||||
|
||||
#region UI事件
|
||||
|
||||
[InputInvoke(InputDef.UI.Prev, UIInputButtonShowMode.MenuLeft)]
|
||||
private void OnPrev()
|
||||
{
|
||||
ItemList.Menu.OnClickBtnPrev();
|
||||
}
|
||||
|
||||
[InputInvoke(InputDef.UI.Next, UIInputButtonShowMode.MenuRight)]
|
||||
private void OnNext()
|
||||
{
|
||||
ItemList.Menu.OnClickBtnNext();
|
||||
}
|
||||
|
||||
[InputInvoke(InputDef.UI.Left, UIInputButtonShowMode.BottomLeft)]
|
||||
private void OnLeft()
|
||||
{
|
||||
ItemList.List.Selector.Left();
|
||||
}
|
||||
|
||||
[InputInvoke(InputDef.UI.Right, UIInputButtonShowMode.BottomLeft)]
|
||||
private void OnRight()
|
||||
{
|
||||
ItemList.List.Selector.Right();
|
||||
}
|
||||
|
||||
[InputInvoke(InputDef.UI.Up, UIInputButtonShowMode.BottomLeft)]
|
||||
private void OnUp()
|
||||
{
|
||||
ItemList.List.Selector.Up();
|
||||
// ChangeListSelected();
|
||||
}
|
||||
|
||||
[InputInvoke(InputDef.UI.Down, UIInputButtonShowMode.BottomLeft)]
|
||||
private void OnDown()
|
||||
{
|
||||
ItemList.List.Selector.Down();
|
||||
}
|
||||
|
||||
[InputInvoke(InputDef.UI.Enter, UIInputButtonShowMode.BottomLeft, "查看")]
|
||||
private void OnApplySettings()
|
||||
{
|
||||
var selectedItem = ItemList.List.Selector.SelectedItem;
|
||||
if (selectedItem != null)
|
||||
{
|
||||
ItemList.List.InvokeClickItem(selectedItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[InputInvoke(InputDef.UI.Back, UIInputButtonShowMode.BottomRight)]
|
||||
private void OnBack()
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
ItemList.List.OnClickItem -= OnClickItem;
|
||||
InputManager.Instance.Off(this);
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
base.OnDestroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Shops/FishingShopPanel.cs.meta
Normal file
2
Assets/Scripts/UI/Shops/FishingShopPanel.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9c7e605b14059445a8598c3cc8d3997
|
||||
76
Assets/Scripts/UI/Shops/GoodsConfigHelper.cs
Normal file
76
Assets/Scripts/UI/Shops/GoodsConfigHelper.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NBF.Utils;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public static class GoodsConfigHelper
|
||||
{
|
||||
public static readonly List<TabItemData> TabItemList = new List<TabItemData>();
|
||||
|
||||
/// <summary>
|
||||
/// 组合和id映射关系
|
||||
/// </summary>
|
||||
private static readonly Dictionary<int, List<int>> _group2Id = new Dictionary<int, List<int>>();
|
||||
|
||||
private static readonly Dictionary<int, cfg.Goods> _googs = new Dictionary<int, cfg.Goods>();
|
||||
|
||||
// private static readonly Dictionary<>
|
||||
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
var listGoods = Game.Tables.TbGoods.DataList; //GoodsConfig.GetList();
|
||||
TabItemList.Clear();
|
||||
|
||||
|
||||
foreach (var goodsConfig in listGoods)
|
||||
{
|
||||
var group = goodsConfig.Group;
|
||||
if (group < 1)
|
||||
{
|
||||
// goodsConfig.Group = goodsConfig.Id;
|
||||
group = goodsConfig.Id;
|
||||
}
|
||||
|
||||
if (!_group2Id.TryGetValue(group, out List<int> ids))
|
||||
{
|
||||
ids = new List<int>();
|
||||
_group2Id.Add(group, ids);
|
||||
}
|
||||
|
||||
ids.Add(goodsConfig.Id);
|
||||
_googs[goodsConfig.Id] = goodsConfig;
|
||||
}
|
||||
|
||||
Dictionary<ItemType, List<cfg.Goods>> tabDic = new Dictionary<ItemType, List<cfg.Goods>>();
|
||||
foreach (var goodsId in _group2Id.Keys)
|
||||
{
|
||||
var good = _googs[goodsId];
|
||||
var awards = good.Awards;
|
||||
var type = awards.First().Id.GetItemType();
|
||||
if (!tabDic.ContainsKey(type))
|
||||
{
|
||||
tabDic.Add(type, new List<cfg.Goods>());
|
||||
}
|
||||
|
||||
tabDic[type].Add(good);
|
||||
}
|
||||
|
||||
foreach (var (key, list) in tabDic)
|
||||
{
|
||||
list.Sort((x, y) => (int)(y.Price1 - x.Price1));
|
||||
}
|
||||
|
||||
foreach (var (type, list) in tabDic)
|
||||
{
|
||||
TabItemData tabItem = new TabItemData
|
||||
{
|
||||
Key = type.ToString()
|
||||
};
|
||||
tabItem.Items.AddRange(list);
|
||||
TabItemList.Add(tabItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/UI/Shops/GoodsConfigHelper.cs.meta
Normal file
3
Assets/Scripts/UI/Shops/GoodsConfigHelper.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 488efa1c587a4dc7a08fb18550e6f470
|
||||
timeCreated: 1763867799
|
||||
36
Assets/Scripts/UI/Shops/ShopDetailsPanel.Designer.cs
generated
Normal file
36
Assets/Scripts/UI/Shops/ShopDetailsPanel.Designer.cs
generated
Normal file
@@ -0,0 +1,36 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改,生成插件文档及项目地址:https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
|
||||
|
||||
using FairyGUI;
|
||||
using FairyGUI.Utils;
|
||||
using NBC;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
/// <summary> </summary>
|
||||
public partial class ShopDetailsPanel
|
||||
{
|
||||
public GObject this[string aKey] => ContentPane.GetChild(aKey);
|
||||
public override string UIPackName => "Main";
|
||||
public override string UIResName => "ShopDetailsPanel";
|
||||
|
||||
[AutoFind(Name = "back")]
|
||||
public UIBlurBackground back;
|
||||
[AutoFind(Name = "Model")]
|
||||
public ModelViewer Model;
|
||||
[AutoFind(Name = "Line")]
|
||||
public GImage Line;
|
||||
[AutoFind(Name = "TextTitle")]
|
||||
public GComponent TextTitle;
|
||||
[AutoFind(Name = "Content")]
|
||||
public GComponent Content;
|
||||
public override string[] GetDependPackages(){ return new string[] {"Common","CommonNew"}; }
|
||||
|
||||
public static void Show(object param = null){ UI.Inst.OpenUI<ShopDetailsPanel>(param); }
|
||||
|
||||
public static void Hide(){ UI.Inst.HideUI<ShopDetailsPanel>(); }
|
||||
|
||||
public static void Del(){ UI.Inst.DestroyUI<ShopDetailsPanel>(); }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 05068004b176c354aa41b3db4f299fce
|
||||
60
Assets/Scripts/UI/Shops/ShopDetailsPanel.cs
Normal file
60
Assets/Scripts/UI/Shops/ShopDetailsPanel.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
|
||||
|
||||
using System.Linq;
|
||||
using Fantasy;
|
||||
using UnityEngine;
|
||||
using NBC;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class ShopDetailsPanel : UIPanel
|
||||
{
|
||||
protected override void OnShow()
|
||||
{
|
||||
var config = GetData() as cfg.Goods;
|
||||
var first = config.Awards.First();
|
||||
var itemConfig = Game.Tables.TbItem.Get(first.Id);
|
||||
Model.SetData(itemConfig);
|
||||
InputManager.Instance.On(this);
|
||||
}
|
||||
|
||||
#region UI输入事件
|
||||
|
||||
[InputInvoke(InputDef.UI.Up, UIInputButtonShowMode.BottomLeft)]
|
||||
private void OnUp()
|
||||
{
|
||||
// ItemList.List.Selector.Up();
|
||||
// ChangeListSelected();
|
||||
}
|
||||
|
||||
[InputInvoke(InputDef.UI.Down, UIInputButtonShowMode.BottomLeft)]
|
||||
private void OnDown()
|
||||
{
|
||||
// ItemList.List.Selector.Down();
|
||||
}
|
||||
|
||||
[InputInvoke(InputDef.UI.Enter, UIInputButtonShowMode.BottomLeft, "购买")]
|
||||
private void OnApplySettings()
|
||||
{
|
||||
// var selectedItem = ItemList.List.Selector.SelectedItem;
|
||||
// if (selectedItem != null)
|
||||
// {
|
||||
// ItemList.List.InvokeClickItem(selectedItem);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
[InputInvoke(InputDef.UI.Back, UIInputButtonShowMode.BottomRight)]
|
||||
private void OnBack()
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
InputManager.Instance.Off(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Shops/ShopDetailsPanel.cs.meta
Normal file
2
Assets/Scripts/UI/Shops/ShopDetailsPanel.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b94c59d346c7a1d458f0bbdd72e12768
|
||||
29
Assets/Scripts/UI/Shops/ShopGearItem.Designer.cs
generated
Normal file
29
Assets/Scripts/UI/Shops/ShopGearItem.Designer.cs
generated
Normal file
@@ -0,0 +1,29 @@
|
||||
/**本脚本为自动生成,每次生成会覆盖!请勿手动修改,生成插件文档及项目地址:https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
|
||||
|
||||
|
||||
using FairyGUI;
|
||||
using FairyGUI.Utils;
|
||||
using NBC;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class ShopGearItem
|
||||
{
|
||||
public const string URL = "ui://hxr7rc7poome9";
|
||||
|
||||
public GImage bacl_full;
|
||||
public GImage select;
|
||||
public GImage bacl_bottom;
|
||||
|
||||
public override void ConstructFromXML(XML xml)
|
||||
{
|
||||
base.ConstructFromXML(xml);
|
||||
|
||||
bacl_full = (GImage)GetChild("bacl_full");
|
||||
select = (GImage)GetChild("select");
|
||||
bacl_bottom = (GImage)GetChild("bacl_bottom");
|
||||
OnInited();
|
||||
UILanguage.TrySetComponentLanguage(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Shops/ShopGearItem.Designer.cs.meta
Normal file
2
Assets/Scripts/UI/Shops/ShopGearItem.Designer.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 92579122ea9d5304082e11a70b36b7e1
|
||||
37
Assets/Scripts/UI/Shops/ShopGearItem.cs
Normal file
37
Assets/Scripts/UI/Shops/ShopGearItem.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
|
||||
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
using Fantasy;
|
||||
using NBC;
|
||||
using NBF.Utils;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class ShopGearItem : GButton
|
||||
{
|
||||
public ShopItemInfo Info;
|
||||
|
||||
private void OnInited()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void SetData(ShopItemInfo shopItemInfo)
|
||||
{
|
||||
Info = shopItemInfo;
|
||||
var award = shopItemInfo.Config; //goodsConfig.Awards.First();
|
||||
title = award.Id.GetName();
|
||||
this.SetIcon(award.Id);
|
||||
|
||||
var cfg = Game.Tables.TbItem.Get(award.Id);
|
||||
|
||||
// Quality.SetQuality(cfg.Quality);
|
||||
// QualityCtrl.selectedIndex = cfg.Quality;
|
||||
this.SetTitleQuality(cfg.Quality);
|
||||
|
||||
// TextAmount.text = $"个数:{1}";
|
||||
// TextPrice.text = shopItemInfo.Price1.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Shops/ShopGearItem.cs.meta
Normal file
2
Assets/Scripts/UI/Shops/ShopGearItem.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d9f9ed6de5b3acd40916c6a8a0aa1b1b
|
||||
42
Assets/Scripts/UI/Shops/ShopItemHelper.cs
Normal file
42
Assets/Scripts/UI/Shops/ShopItemHelper.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System.Collections.Generic;
|
||||
using Fantasy;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public static class ShopItemHelper
|
||||
{
|
||||
public static List<TabItemData> ToTabItemData(this List<ShopItemInfo> shopItems)
|
||||
{
|
||||
List<TabItemData> ret = new List<TabItemData>();
|
||||
Dictionary<ItemType, List<ShopItemInfo>> tabDic = new Dictionary<ItemType, List<ShopItemInfo>>();
|
||||
|
||||
foreach (var shopItemInfo in shopItems)
|
||||
{
|
||||
var type = shopItemInfo.ItemType;
|
||||
if (!tabDic.ContainsKey(type))
|
||||
{
|
||||
tabDic.Add(type, new List<ShopItemInfo>());
|
||||
}
|
||||
|
||||
tabDic[type].Add(shopItemInfo);
|
||||
}
|
||||
|
||||
foreach (var (key, list) in tabDic)
|
||||
{
|
||||
list.Sort((x, y) => (int)(y.Price1 - x.Price1));
|
||||
}
|
||||
|
||||
foreach (var (type, list) in tabDic)
|
||||
{
|
||||
TabItemData tabItem = new TabItemData
|
||||
{
|
||||
Key = type.ToString()
|
||||
};
|
||||
tabItem.Items.AddRange(list);
|
||||
ret.Add(tabItem);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/UI/Shops/ShopItemHelper.cs.meta
Normal file
3
Assets/Scripts/UI/Shops/ShopItemHelper.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e108e7b5732478bb02dd6c84f24870b
|
||||
timeCreated: 1771304672
|
||||
Reference in New Issue
Block a user