This commit is contained in:
2025-10-11 09:11:32 +08:00
parent bf7b1bbbb2
commit 939d3d81fc
23 changed files with 201 additions and 51 deletions

View File

@@ -19,6 +19,15 @@ namespace NBF.Fishing2
}
}
public class RoleAwakeSystem : AwakeSystem<Role>
{
protected override void Awake(Role self)
{
// self.AddComponent<RoleBag>();
// self.AddComponent<RoleFishBag>();
}
}
public async FTask GetRoleInfo()
{
var response = (Game2C_GetRoleInfoResponse)await Net.Call(new C2Game_GetRoleInfoRequest());

View File

@@ -0,0 +1,24 @@
using System.Collections.Generic;
using NBC;
using NBC.Entitas;
namespace NBF.Fishing2
{
public class RoleBag : Entity
{
public readonly List<ItemInfo> Items = new List<ItemInfo>();
public readonly List<ItemBindInfo> Rigs = new List<ItemBindInfo>();
public async FTask GetBagInfo()
{
Items.Clear();
Rigs.Clear();
var response = (Game2C_GetItemsResponse)await Net.Call(new C2Game_GetItemsRequest());
if (response.ErrorCode == ErrorCode.Success)
{
Items.AddRange(response.Items);
Rigs.AddRange(response.Rigs);
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4affcf4934a845c59879e02b01acc709
timeCreated: 1760102338

View File

@@ -0,0 +1,9 @@
using NBC.Entitas;
namespace NBF.Fishing2
{
public class RoleFishBag : Entity
{
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4848b3391419459b883ae2fcb5fc88e6
timeCreated: 1760102442

View File

@@ -4,50 +4,75 @@ using Random = UnityEngine.Random;
namespace NBF
{
// public class TabItemData
// {
// public string Name; // 菜单显示名
// public string Key; // 唯一标识
// public string Icon; // 图标
// public bool IsAll; // 是否是“全部”选项
// public List<TabItemData> Children = new List<TabItemData>(); // 二级菜单
// }
public class TabItemData
{
public string Name;
public string Key;
public string Icon;
}
public bool IsAll;
public class TabListData : TabItemData
{
}
public class TabSubItemData : TabListData
{
// 条目可以是任意对象类型
public List<object> Items = new List<object>();
// 子菜单
public List<TabItemData> Children = new List<TabItemData>();
}
/// <summary>
/// 保护二级子目录的列表
/// </summary>
public class TabListAndSubListData : TabListData
{
public List<TabSubItemData> SubTab = new List<TabSubItemData>();
// public class TabItemData
// {
// public string Name;
// public string Key;
// public string Icon;
// }
//
// public class TabListData : TabItemData
// {
// }
//
// public class TabSubItemData : TabListData
// {
// public List<object> Items = new List<object>();
// }
public void AddTestData(int index)
{
Name = $"标题-{index + 1}";
string[] testIcon = { "Globe", "Granade", "Gun" };
var count1 = Random.Range(5, 10);
var count2 = Random.Range(90, 200);
for (int i = 0; i < count1; i++)
{
TabSubItemData subTab = new TabSubItemData();
subTab.Name = $"类型-{i}";
subTab.Icon = testIcon[Random.Range(0, testIcon.Length)];
for (int j = 0; j < count2; j++)
{
var item = new ShopGearData();
item.title = $"Item {index}-{i}-" + j;
subTab.Items.Add(item);
}
SubTab.Add(subTab);
}
}
}
// /// <summary>
// /// 保护二级子目录的列表
// /// </summary>
// public class TabListAndSubListData : TabListData
// {
// public List<TabSubItemData> SubTab = new List<TabSubItemData>();
//
// public void AddTestData(int index)
// {
// Name = $"标题-{index + 1}";
//
// string[] testIcon = { "Globe", "Granade", "Gun" };
// var count1 = Random.Range(5, 10);
// var count2 = Random.Range(90, 200);
// for (int i = 0; i < count1; i++)
// {
// TabSubItemData subTab = new TabSubItemData();
// subTab.Name = $"类型-{i}";
// subTab.Icon = testIcon[Random.Range(0, testIcon.Length)];
// for (int j = 0; j < count2; j++)
// {
// var item = new ShopGearData();
// item.title = $"Item {index}-{i}-" + j;
// subTab.Items.Add(item);
// }
//
// SubTab.Add(subTab);
// }
// }
// }
}

View File

@@ -63,15 +63,15 @@ namespace NBF
await role.GetRoleInfo();
Log.Debug(
$"获取角色信息成功roleId={role.Id} Room={role.RoomCode} RoleInfo={JsonConvert.SerializeObject(role.Info)}");
var mapId = role.Info.MapId;
if (mapId == 0)
{
Log.Warning("账号没有进入过地图,进入新手引导地图");
mapId = 99;
}
//获取背包数据
var roleBag = role.GetOrAddComponent<RoleBag>();
await roleBag.GetBagInfo();
Game.SelfId = loginResponse.RoleId;
await MapHelper.EnterMap(mapId, role.RoomCode);
}
}
}

View File

@@ -21,6 +21,7 @@ namespace NBF
UIObjectFactory.SetPackageItemExtension(NoticeItem.URL, typeof(NoticeItem));
UIObjectFactory.SetPackageItemExtension(CommonSubMenu.URL, typeof(CommonSubMenu));
UIObjectFactory.SetPackageItemExtension(BtnInputControl.URL, typeof(BtnInputControl));
UIObjectFactory.SetPackageItemExtension(ListTitleItem.URL, typeof(ListTitleItem));
}
}
}

View File

@@ -63,14 +63,17 @@ namespace NBF
}
}
public void SetListData(List<object> listData, ListSelectionMode selectionMode = ListSelectionMode.Single)
public void SetListData(List<object> listData,
ListSelectionMode selectionMode = ListSelectionMode.Single)
{
List.selectedIndex = -1;
List.defaultItem = GetListDefaultItemResource(listData);
List.defaultItem = ListTitleItem.URL;
List.itemProvider = GetListItemResource;
List.itemRenderer = OnRenderItem;
List.onClickItem.Add(OnClickListItem);
List.SetVirtual();
// List.SetVirtual();
_listData.Clear();
foreach (var obj in listData)
{
_listData.Add(obj);
@@ -92,19 +95,30 @@ namespace NBF
if (obj is ListItemBase item)
{
item.SetData(_listData[index]);
obj.SetSize(350, 300);
}
else if (obj is ListTitleItem titleItem)
{
titleItem.SetSize(List.width, 32);
}
}
//根据索引的不同返回不同的资源URL
string GetListDefaultItemResource(List<object> listData)
string GetListItemResource(int index)
{
var itemData = listData.Find(t => t != null);
var itemData = _listData[index];
if (itemData is ShopGearData)
{
return ShopGearItem.URL;
}
if (itemData is string title)
{
return ListTitleItem.URL;
}
return List.defaultItem;
}
}

View File

@@ -0,0 +1,25 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
namespace NBF
{
public partial class ListTitleItem
{
public const string URL = "ui://6hgkvlaush9ymc";
public Controller show;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
show = GetController("show");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f130a01ca6286e1408db0809028cf787

View File

@@ -0,0 +1,15 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using UnityEngine;
using FairyGUI;
using NBC;
namespace NBF
{
public partial class ListTitleItem : GLabel
{
private void OnInited()
{
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: b2881797917479b469f018a06726152d

View File

@@ -76,6 +76,17 @@ namespace NBF
private async FTask OnLoginClick()
{
await LoginHelper.Login(InputAccount.text);
BagPanel.Show();
FishingShopPanel.Show();
// var mapId = role.Info.MapId;
// if (mapId == 0)
// {
// Log.Warning("账号没有进入过地图,进入新手引导地图");
// mapId = 99;
// }
// await MapHelper.EnterMap(mapId, role.RoomCode);
// await MapHelper.EnterMap(99);
Del();
}

View File

@@ -32,9 +32,6 @@
<item url="ui://146ra2lqoome9"/>
<item url="ui://146ra2lqoome9"/>
<item url="ui://146ra2lqoome9"/>
<item url="ui://146ra2lqoome9"/>
<item url="ui://146ra2lqoome9"/>
<item url="ui://146ra2lqoome9"/>
</list>
</displayList>
</component>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<component size="231,32" extention="Label">
<controller name="show" pages="0,,1," selected="0"/>
<displayList>
<text id="n6_e9z8" name="title" xy="0,0" size="189,32" alpha="0.7" fontSize="22" color="#ffffff" text="Screen resolution"/>
</displayList>
</component>

View File

@@ -222,6 +222,7 @@
<component id="5dtxm9" name="ModelTexture.xml" path="/Com/" exported="true"/>
<component id="9zboma" name="CommonInput.xml" path="/Com/Inputs/" exported="true"/>
<component id="9zbomb" name="BtnCommon.xml" path="/Com/Buttons/" exported="true"/>
<component id="sh9ymc" name="ListTitleItem.xml" path="/Com/Items/" exported="true"/>
</resources>
<publish name="" path="../Assets/Resources/Fgui/Common" packageCount="2" genCode="true"/>
</packageDescription>

View File

@@ -4,11 +4,12 @@
<image id="n0_lvql" name="back" src="kryob" fileName="Images/Square.png" pkg="6hgkvlau" xy="0,0" size="1920,1080" color="#182128">
<relation target="" sidePair="width-width,height-height"/>
</image>
<component id="n1_lvql" name="Menu" src="fcfggr" fileName="Com/Menu/CommonMenu.xml" pkg="6hgkvlau" xy="0,0">
<component id="n1_lvql" name="Menu" src="fcfggr" fileName="Com/Menu/CommonMenu.xml" pkg="6hgkvlau" xy="0,0" controller="showType,1">
<relation target="" sidePair="width-width,center-center,top-top"/>
</component>
<component id="n2_lvql" name="BottomMenu" src="9mf1z" fileName="Com/Menu/BottomMenu.xml" pkg="6hgkvlau" xy="0,992" size="1920,88">
<relation target="" sidePair="width-width,center-center,bottom-bottom"/>
</component>
<component id="n4_sh9y" name="n4" src="drkwh1" fileName="Com/ClassifyList.xml" pkg="6hgkvlau" xy="37,111" size="1846,872"/>
</displayList>
</component>

View File

@@ -8,7 +8,7 @@
<relation target="" sidePair="width-width,center-center,top-top"/>
</component>
<component id="n25_r03u" name="SubMenu" src="r03us" fileName="Com/Menu/CommonSubMenu.xml" pkg="6hgkvlau" xy="49,96" size="1830,80"/>
<component id="n6_drkw" name="List" src="drkwh1" fileName="Com/ClassifyList.xml" pkg="6hgkvlau" xy="50,193" size="1846,806">
<component id="n6_drkw" name="List" src="drkwh1" fileName="Com/ClassifyList.xml" pkg="6hgkvlau" xy="49,193" size="1846,806">
<relation target="" sidePair="width-width,top-top,bottomext-bottom"/>
</component>
<component id="n30_r03u" name="Currencys" src="fcfggq" fileName="Com/Tags/CurrencyGroup.xml" pkg="6hgkvlau" xy="1595,111">

View File

@@ -0,0 +1 @@
{"url":"ui://6hgkvlaush9ymc","name":"ListTitleItem","scriptType":"component","isCustomName":false,"customName":"","annotation":"","member":{}}