Compare commits
3 Commits
d8f56beee7
...
de63de69a0
Author | SHA1 | Date | |
---|---|---|---|
de63de69a0 | |||
5d761e0053 | |||
5ca5d1d12d |
|
@ -116,47 +116,23 @@ anchors_preset = 2
|
|||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 16.0
|
||||
offset_top = -52.0
|
||||
offset_right = 80.0
|
||||
offset_top = -68.0
|
||||
offset_right = 96.0
|
||||
offset_bottom = 4.0
|
||||
grow_vertical = 0
|
||||
texture_normal = ExtResource("4_nm64b")
|
||||
|
||||
[node name="TabButton2" type="TextureButton" parent="NinePatchRect/MarginContainer/HBoxContainer/VBoxContainer2/Control"]
|
||||
[node name="Icon" type="TextureRect" parent="NinePatchRect/MarginContainer/HBoxContainer/VBoxContainer2/Control/TabButton"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 2
|
||||
anchor_top = 1.0
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 80.0
|
||||
offset_top = -52.0
|
||||
offset_right = 144.0
|
||||
offset_bottom = 4.0
|
||||
grow_vertical = 0
|
||||
texture_normal = ExtResource("4_nm64b")
|
||||
|
||||
[node name="TabButton3" type="TextureButton" parent="NinePatchRect/MarginContainer/HBoxContainer/VBoxContainer2/Control"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 2
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 144.0
|
||||
offset_top = -52.0
|
||||
offset_right = 208.0
|
||||
offset_bottom = 4.0
|
||||
grow_vertical = 0
|
||||
texture_normal = ExtResource("4_nm64b")
|
||||
|
||||
[node name="TabButton4" type="TextureButton" parent="NinePatchRect/MarginContainer/HBoxContainer/VBoxContainer2/Control"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 2
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 208.0
|
||||
offset_top = -52.0
|
||||
offset_right = 272.0
|
||||
offset_bottom = 4.0
|
||||
grow_vertical = 0
|
||||
texture_normal = ExtResource("4_nm64b")
|
||||
offset_left = 8.0
|
||||
offset_top = 24.0
|
||||
offset_right = -8.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
stretch_mode = 3
|
||||
|
||||
[node name="NinePatchRect" type="NinePatchRect" parent="NinePatchRect/MarginContainer/HBoxContainer/VBoxContainer2"]
|
||||
layout_mode = 2
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 390 B After Width: | Height: | Size: 419 B |
Binary file not shown.
After Width: | Height: | Size: 263 B |
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://b3cyuhkpk5jc0"
|
||||
path="res://.godot/imported/TabIcon1.png-959d0384e8e61550e56702a962ae1355.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://resource/sprite/ui/encyclopedia/TabIcon1.png"
|
||||
dest_files=["res://.godot/imported/TabIcon1.png-959d0384e8e61550e56702a962ae1355.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
Binary file not shown.
After Width: | Height: | Size: 315 B |
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://vpm33qtm7w"
|
||||
path="res://.godot/imported/TabSelect.png-d8a3ea74ef504abc15dab702abedc9bc.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://resource/sprite/ui/encyclopedia/TabSelect.png"
|
||||
dest_files=["res://.godot/imported/TabSelect.png-d8a3ea74ef504abc15dab702abedc9bc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
|
@ -627,6 +627,20 @@ public partial class ActivityObject : CharacterBody2D, IDestroy, ICoroutine
|
|||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加组件时调用
|
||||
/// </summary>
|
||||
public virtual void OnAddComponent(Component component)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除组件时调用
|
||||
/// </summary>
|
||||
public virtual void OnRemoveComponent(Component component)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回当物体 CollisionLayer 是否能与 mask 层碰撞
|
||||
/// </summary>
|
||||
|
@ -773,6 +787,7 @@ public partial class ActivityObject : CharacterBody2D, IDestroy, ICoroutine
|
|||
component.Master = this;
|
||||
component.Ready();
|
||||
component.OnEnable();
|
||||
OnAddComponent(component);
|
||||
return component;
|
||||
}
|
||||
|
||||
|
@ -794,6 +809,7 @@ public partial class ActivityObject : CharacterBody2D, IDestroy, ICoroutine
|
|||
component.Master = this;
|
||||
component.Ready();
|
||||
component.OnEnable();
|
||||
OnAddComponent(component);
|
||||
return component;
|
||||
}
|
||||
|
||||
|
@ -811,6 +827,7 @@ public partial class ActivityObject : CharacterBody2D, IDestroy, ICoroutine
|
|||
if (_updatingComp)
|
||||
{
|
||||
_changeComponents.Add(new KeyValuePair<Component, bool>(component, false));
|
||||
OnRemoveComponent(component);
|
||||
component.Destroy();
|
||||
}
|
||||
else
|
||||
|
@ -820,6 +837,7 @@ public partial class ActivityObject : CharacterBody2D, IDestroy, ICoroutine
|
|||
if (_components[i].Value == component)
|
||||
{
|
||||
_components.RemoveAt(i);
|
||||
OnRemoveComponent(component);
|
||||
component.Destroy();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -81,23 +81,6 @@ public abstract partial class UiBase : Control, IDestroy, ICoroutine
|
|||
UiManager.RecordUi(this, UiManager.RecordType.Open);
|
||||
}
|
||||
|
||||
public sealed override void _Ready()
|
||||
{
|
||||
if (Math.Abs(Scale.X - 1f) > 0.001f)
|
||||
{
|
||||
Resized += OnResizeUi;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnResizeUi()
|
||||
{
|
||||
if (ParentUi == null)
|
||||
{
|
||||
var viewportSize = GameApplication.Instance.ViewportSize;
|
||||
Size = viewportSize;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建当前ui时调用
|
||||
/// </summary>
|
||||
|
|
4
DungeonShooting_Godot/src/game/buff/BuffBase.cs
Normal file
4
DungeonShooting_Godot/src/game/buff/BuffBase.cs
Normal file
|
@ -0,0 +1,4 @@
|
|||
|
||||
public abstract partial class BuffBase : Component<Role>
|
||||
{
|
||||
}
|
|
@ -299,6 +299,14 @@ public class ResourcePath
|
|||
public const string resource_sprite_ui_sursors_CursorCenter_png = "res://resource/sprite/ui/sursors/CursorCenter.png";
|
||||
public const string resource_sprite_ui_sursors_Cursors_png = "res://resource/sprite/ui/sursors/Cursors.png";
|
||||
public const string resource_sprite_ui_sursors_Cursors_Ui_png = "res://resource/sprite/ui/sursors/Cursors_Ui.png";
|
||||
public const string resource_sprite_ui_encyclopedia_TitleBg_png = "res://resource/sprite/ui/encyclopedia/TitleBg.png";
|
||||
public const string resource_sprite_ui_encyclopedia_Panel2_png = "res://resource/sprite/ui/encyclopedia/Panel2.png";
|
||||
public const string resource_sprite_ui_encyclopedia_Tab_png = "res://resource/sprite/ui/encyclopedia/Tab.png";
|
||||
public const string resource_sprite_ui_encyclopedia_Panel_png = "res://resource/sprite/ui/encyclopedia/Panel.png";
|
||||
public const string resource_sprite_ui_encyclopedia_Item_png = "res://resource/sprite/ui/encyclopedia/Item.png";
|
||||
public const string resource_sprite_ui_encyclopedia_TabSelect_png = "res://resource/sprite/ui/encyclopedia/TabSelect.png";
|
||||
public const string resource_sprite_ui_encyclopedia_Select_png = "res://resource/sprite/ui/encyclopedia/Select.png";
|
||||
public const string resource_sprite_ui_encyclopedia_TabIcon1_png = "res://resource/sprite/ui/encyclopedia/TabIcon1.png";
|
||||
public const string resource_sprite_ui_mapEditorTools_DoorDragButton_png = "res://resource/sprite/ui/mapEditorTools/DoorDragButton.png";
|
||||
public const string resource_sprite_ui_mapEditorTools_DoorDragButton_hover_png = "res://resource/sprite/ui/mapEditorTools/DoorDragButton_hover.png";
|
||||
public const string resource_sprite_ui_mapEditorTools_DoorDragButton_down_png = "res://resource/sprite/ui/mapEditorTools/DoorDragButton_down.png";
|
||||
|
|
|
@ -81,42 +81,37 @@ public abstract partial class Encyclopedia : UiBase
|
|||
public override TextureRect Clone() => new (UiPanel, (Godot.TextureRect)Instance.Duplicate());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 类型: <see cref="Godot.TextureRect"/>, 路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.Control.TabButton.Icon
|
||||
/// </summary>
|
||||
public class Icon : UiNode<EncyclopediaPanel, Godot.TextureRect, Icon>
|
||||
{
|
||||
public Icon(EncyclopediaPanel uiPanel, Godot.TextureRect node) : base(uiPanel, node) { }
|
||||
public override Icon Clone() => new (UiPanel, (Godot.TextureRect)Instance.Duplicate());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 类型: <see cref="Godot.TextureButton"/>, 路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.Control.TabButton
|
||||
/// </summary>
|
||||
public class TabButton : UiNode<EncyclopediaPanel, Godot.TextureButton, TabButton>
|
||||
{
|
||||
/// <summary>
|
||||
/// 使用 Instance 属性获取当前节点实例对象, 节点类型: <see cref="Godot.TextureRect"/>, 节点路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.Control.Icon
|
||||
/// </summary>
|
||||
public Icon L_Icon
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_L_Icon == null) _L_Icon = new Icon(UiPanel, Instance.GetNode<Godot.TextureRect>("Icon"));
|
||||
return _L_Icon;
|
||||
}
|
||||
}
|
||||
private Icon _L_Icon;
|
||||
|
||||
public TabButton(EncyclopediaPanel uiPanel, Godot.TextureButton node) : base(uiPanel, node) { }
|
||||
public override TabButton Clone() => new (UiPanel, (Godot.TextureButton)Instance.Duplicate());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 类型: <see cref="Godot.TextureButton"/>, 路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.Control.TabButton2
|
||||
/// </summary>
|
||||
public class TabButton2 : UiNode<EncyclopediaPanel, Godot.TextureButton, TabButton2>
|
||||
{
|
||||
public TabButton2(EncyclopediaPanel uiPanel, Godot.TextureButton node) : base(uiPanel, node) { }
|
||||
public override TabButton2 Clone() => new (UiPanel, (Godot.TextureButton)Instance.Duplicate());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 类型: <see cref="Godot.TextureButton"/>, 路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.Control.TabButton3
|
||||
/// </summary>
|
||||
public class TabButton3 : UiNode<EncyclopediaPanel, Godot.TextureButton, TabButton3>
|
||||
{
|
||||
public TabButton3(EncyclopediaPanel uiPanel, Godot.TextureButton node) : base(uiPanel, node) { }
|
||||
public override TabButton3 Clone() => new (UiPanel, (Godot.TextureButton)Instance.Duplicate());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 类型: <see cref="Godot.TextureButton"/>, 路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.Control.TabButton4
|
||||
/// </summary>
|
||||
public class TabButton4 : UiNode<EncyclopediaPanel, Godot.TextureButton, TabButton4>
|
||||
{
|
||||
public TabButton4(EncyclopediaPanel uiPanel, Godot.TextureButton node) : base(uiPanel, node) { }
|
||||
public override TabButton4 Clone() => new (UiPanel, (Godot.TextureButton)Instance.Duplicate());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 类型: <see cref="Godot.Control"/>, 路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.Control
|
||||
/// </summary>
|
||||
|
@ -135,45 +130,6 @@ public abstract partial class Encyclopedia : UiBase
|
|||
}
|
||||
private TabButton _L_TabButton;
|
||||
|
||||
/// <summary>
|
||||
/// 使用 Instance 属性获取当前节点实例对象, 节点类型: <see cref="Godot.TextureButton"/>, 节点路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.TabButton2
|
||||
/// </summary>
|
||||
public TabButton2 L_TabButton2
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_L_TabButton2 == null) _L_TabButton2 = new TabButton2(UiPanel, Instance.GetNode<Godot.TextureButton>("TabButton2"));
|
||||
return _L_TabButton2;
|
||||
}
|
||||
}
|
||||
private TabButton2 _L_TabButton2;
|
||||
|
||||
/// <summary>
|
||||
/// 使用 Instance 属性获取当前节点实例对象, 节点类型: <see cref="Godot.TextureButton"/>, 节点路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.TabButton3
|
||||
/// </summary>
|
||||
public TabButton3 L_TabButton3
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_L_TabButton3 == null) _L_TabButton3 = new TabButton3(UiPanel, Instance.GetNode<Godot.TextureButton>("TabButton3"));
|
||||
return _L_TabButton3;
|
||||
}
|
||||
}
|
||||
private TabButton3 _L_TabButton3;
|
||||
|
||||
/// <summary>
|
||||
/// 使用 Instance 属性获取当前节点实例对象, 节点类型: <see cref="Godot.TextureButton"/>, 节点路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.TabButton4
|
||||
/// </summary>
|
||||
public TabButton4 L_TabButton4
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_L_TabButton4 == null) _L_TabButton4 = new TabButton4(UiPanel, Instance.GetNode<Godot.TextureButton>("TabButton4"));
|
||||
return _L_TabButton4;
|
||||
}
|
||||
}
|
||||
private TabButton4 _L_TabButton4;
|
||||
|
||||
public Control(EncyclopediaPanel uiPanel, Godot.Control node) : base(uiPanel, node) { }
|
||||
public override Control Clone() => new (UiPanel, (Godot.Control)Instance.Duplicate());
|
||||
}
|
||||
|
@ -581,26 +537,16 @@ public abstract partial class Encyclopedia : UiBase
|
|||
/// </summary>
|
||||
public TextureRect S_TextureRect => L_NinePatchRect.L_TextureRect;
|
||||
|
||||
/// <summary>
|
||||
/// 场景中唯一名称的节点, 节点类型: <see cref="Godot.TextureRect"/>, 节点路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.Control.TabButton.Icon
|
||||
/// </summary>
|
||||
public Icon S_Icon => L_NinePatchRect.L_MarginContainer.L_HBoxContainer.L_VBoxContainer2.L_Control.L_TabButton.L_Icon;
|
||||
|
||||
/// <summary>
|
||||
/// 场景中唯一名称的节点, 节点类型: <see cref="Godot.TextureButton"/>, 节点路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.Control.TabButton
|
||||
/// </summary>
|
||||
public TabButton S_TabButton => L_NinePatchRect.L_MarginContainer.L_HBoxContainer.L_VBoxContainer2.L_Control.L_TabButton;
|
||||
|
||||
/// <summary>
|
||||
/// 场景中唯一名称的节点, 节点类型: <see cref="Godot.TextureButton"/>, 节点路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.Control.TabButton2
|
||||
/// </summary>
|
||||
public TabButton2 S_TabButton2 => L_NinePatchRect.L_MarginContainer.L_HBoxContainer.L_VBoxContainer2.L_Control.L_TabButton2;
|
||||
|
||||
/// <summary>
|
||||
/// 场景中唯一名称的节点, 节点类型: <see cref="Godot.TextureButton"/>, 节点路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.Control.TabButton3
|
||||
/// </summary>
|
||||
public TabButton3 S_TabButton3 => L_NinePatchRect.L_MarginContainer.L_HBoxContainer.L_VBoxContainer2.L_Control.L_TabButton3;
|
||||
|
||||
/// <summary>
|
||||
/// 场景中唯一名称的节点, 节点类型: <see cref="Godot.TextureButton"/>, 节点路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.Control.TabButton4
|
||||
/// </summary>
|
||||
public TabButton4 S_TabButton4 => L_NinePatchRect.L_MarginContainer.L_HBoxContainer.L_VBoxContainer2.L_Control.L_TabButton4;
|
||||
|
||||
/// <summary>
|
||||
/// 场景中唯一名称的节点, 节点类型: <see cref="Godot.Control"/>, 节点路径: Encyclopedia.NinePatchRect.MarginContainer.HBoxContainer.VBoxContainer2.Control
|
||||
/// </summary>
|
||||
|
|
|
@ -6,32 +6,47 @@ namespace UI.Encyclopedia;
|
|||
|
||||
public partial class EncyclopediaPanel : Encyclopedia
|
||||
{
|
||||
|
||||
//tab网格
|
||||
private UiGrid<TabButton, TabData> _tab;
|
||||
//item网格
|
||||
private UiGrid<ObjectButton, ExcelConfig.ActivityBase> _grid;
|
||||
private long _id;
|
||||
|
||||
public override void OnCreateUi()
|
||||
{
|
||||
_tab = CreateUiGrid<TabButton, TabData, TabCell>(S_TabButton);
|
||||
_tab.SetColumns(10);
|
||||
_tab.SetCellOffset(new Vector2I(0, 0));
|
||||
_tab.Add(new TabData(ResourcePath.resource_sprite_ui_encyclopedia_TabIcon1_png, ActivityType.Weapon));
|
||||
_tab.Add(new TabData(ResourcePath.resource_sprite_ui_encyclopedia_TabIcon1_png, ActivityType.Prop));
|
||||
_tab.Add(new TabData(ResourcePath.resource_sprite_ui_encyclopedia_TabIcon1_png, ActivityType.Enemy));
|
||||
|
||||
_grid = CreateUiGrid<ObjectButton, ExcelConfig.ActivityBase, ItemCell>(S_ObjectButton);
|
||||
_grid.SetHorizontalExpand(true);
|
||||
_grid.SetAutoColumns(true);
|
||||
_grid.SetCellOffset(new Vector2I(10, 10));
|
||||
ShowWeaponItem();
|
||||
|
||||
_tab.SelectIndex = 0;
|
||||
}
|
||||
|
||||
public override void OnDestroyUi()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void ShowWeaponItem()
|
||||
|
||||
/// <summary>
|
||||
/// 设置选中的tab
|
||||
/// </summary>
|
||||
public void SelectTab(ActivityType type)
|
||||
{
|
||||
StopCoroutine(_id);
|
||||
_id = StartCoroutine(
|
||||
_grid.SetDataListCoroutine(
|
||||
ExcelConfig.ActivityBase_List.Where(data => data.Type == ActivityType.Weapon).ToArray()
|
||||
ExcelConfig.ActivityBase_List.Where(data => data.Type == type).ToArray()
|
||||
)
|
||||
);
|
||||
|
||||
SelectItem(null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -43,7 +58,14 @@ public partial class EncyclopediaPanel : Encyclopedia
|
|||
{
|
||||
S_ItemName.Instance.Text = config.Name;
|
||||
S_ItemTexture.Instance.Texture = ResourceManager.LoadTexture2D(config.Icon);
|
||||
S_ItemDes.Instance.Text = config.Details;
|
||||
S_ItemDes.Instance.Text = config.Intro;
|
||||
//S_ItemDes.Instance.Text = config.Details;
|
||||
}
|
||||
else
|
||||
{
|
||||
S_ItemName.Instance.Text = null;
|
||||
S_ItemTexture.Instance.Texture = null;
|
||||
S_ItemDes.Instance.Text = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
54
DungeonShooting_Godot/src/game/ui/encyclopedia/TabCell.cs
Normal file
54
DungeonShooting_Godot/src/game/ui/encyclopedia/TabCell.cs
Normal file
|
@ -0,0 +1,54 @@
|
|||
using Godot;
|
||||
|
||||
namespace UI.Encyclopedia;
|
||||
|
||||
public class TabCell : UiCell<Encyclopedia.TabButton, TabData>
|
||||
{
|
||||
//选中时页签显示的纹理
|
||||
private const string SelectTexture = ResourcePath.resource_sprite_ui_encyclopedia_TabSelect_png;
|
||||
private static Texture2D _selectTexture;
|
||||
|
||||
private static Texture2D GetSelectTexture()
|
||||
{
|
||||
if (_selectTexture == null)
|
||||
{
|
||||
_selectTexture = ResourceManager.LoadTexture2D(SelectTexture);
|
||||
}
|
||||
|
||||
return _selectTexture;
|
||||
}
|
||||
|
||||
|
||||
private float _startY;
|
||||
private Texture2D _originTexture;
|
||||
|
||||
public override void OnInit()
|
||||
{
|
||||
_originTexture = CellNode.Instance.TextureNormal;
|
||||
}
|
||||
|
||||
public override void OnSetData(TabData data)
|
||||
{
|
||||
CellNode.L_Icon.Instance.Texture = ResourceManager.LoadTexture2D(data.Icon);
|
||||
var position = CellNode.L_Icon.Instance.Position;
|
||||
_startY = position.Y;
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
Grid.SelectIndex = Index;
|
||||
}
|
||||
|
||||
public override void OnSelect()
|
||||
{
|
||||
CellNode.Instance.TextureNormal = GetSelectTexture();
|
||||
CellNode.L_Icon.Instance.Position = new Vector2(CellNode.L_Icon.Instance.Position.X, _startY - 12);
|
||||
CellNode.UiPanel.SelectTab(Data.Type);
|
||||
}
|
||||
|
||||
public override void OnUnSelect()
|
||||
{
|
||||
CellNode.Instance.TextureNormal = _originTexture;
|
||||
CellNode.L_Icon.Instance.Position = new Vector2(CellNode.L_Icon.Instance.Position.X, _startY);
|
||||
}
|
||||
}
|
19
DungeonShooting_Godot/src/game/ui/encyclopedia/TabData.cs
Normal file
19
DungeonShooting_Godot/src/game/ui/encyclopedia/TabData.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
namespace UI.Encyclopedia;
|
||||
|
||||
public class TabData
|
||||
{
|
||||
/// <summary>
|
||||
/// 图标
|
||||
/// </summary>
|
||||
public string Icon;
|
||||
/// <summary>
|
||||
/// 物体类型
|
||||
/// </summary>
|
||||
public ActivityType Type;
|
||||
|
||||
public TabData(string icon, ActivityType type)
|
||||
{
|
||||
Icon = icon;
|
||||
Type = type;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user