mirror of
http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite.git
synced 2025-11-20 04:07:13 +08:00
(client) feat:健康给予,路径优化,结算界面,商店界面 (#60)
Co-authored-by: m0_75251201 <m0_75251201@noreply.gitcode.com> Reviewed-on: http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite/pulls/60
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Data;
|
||||
using Managers;
|
||||
@@ -25,34 +24,34 @@ namespace UI
|
||||
// 目标角色动画显示尺寸
|
||||
private float targetCharacterAnimationDisplaySize = 600f;
|
||||
|
||||
// 当前选中的角色索引
|
||||
public int currentCharacter;
|
||||
|
||||
// 存储角色动画和角色定义的列表
|
||||
public List<(TemporaryAnimatorImageUI, CharacterDef)> characterAnimation = new();
|
||||
|
||||
// 当前选中的角色索引
|
||||
public int currentCharacter = 0;
|
||||
|
||||
// 获取当前选中的角色定义
|
||||
public CharacterDef SelectedCharacter => characterAnimation[currentCharacter].Item2;
|
||||
|
||||
/// <summary>
|
||||
/// 当脚本实例被启用时调用。
|
||||
/// 初始化角色UI,加载角色数据,并生成动画。
|
||||
/// 当脚本实例被启用时调用。
|
||||
/// 初始化角色UI,加载角色数据,并生成动画。
|
||||
/// </summary>
|
||||
private void Start()
|
||||
{
|
||||
Program.Instance.FocusedDimension.OnDimensionLoaded += MapLoaded;
|
||||
enterButton.interactable = false;
|
||||
buttonText.text = "地图加载中";
|
||||
|
||||
|
||||
var characterDefs = DefineManager.Instance.QueryDefinesByType<CharacterDef>();
|
||||
|
||||
|
||||
if (characterDefs == null || characterDefs.Length == 0)
|
||||
{
|
||||
Debug.LogWarning("未找到任何角色定义,禁用SelectCharacterUI。");
|
||||
gameObject.SetActive(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
foreach (var def in characterDefs)
|
||||
{
|
||||
if (def.drawingOrder == null)
|
||||
@@ -120,7 +119,6 @@ namespace UI
|
||||
}
|
||||
|
||||
UpdateUI(currentCharacter); // 初始显示第一个角色
|
||||
|
||||
}
|
||||
|
||||
private void MapLoaded(Dimension dimension)
|
||||
@@ -131,7 +129,7 @@ namespace UI
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新UI显示当前选中角色的动画和信息。
|
||||
/// 更新UI显示当前选中角色的动画和信息。
|
||||
/// </summary>
|
||||
/// <param name="newCharacterIndex">新角色的索引。</param>
|
||||
public void UpdateUI(int newCharacterIndex)
|
||||
@@ -163,9 +161,7 @@ namespace UI
|
||||
{
|
||||
var previousAnimator = characterAnimation[currentCharacter].Item1;
|
||||
if (previousAnimator != null && previousAnimator.gameObject.activeSelf)
|
||||
{
|
||||
previousAnimator.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
currentCharacter = newCharacterIndex; // 更新当前角色索引
|
||||
@@ -173,23 +169,18 @@ namespace UI
|
||||
// 激活新的角色动画
|
||||
var currentAnimator = characterAnimation[currentCharacter].Item1;
|
||||
if (currentAnimator != null)
|
||||
{
|
||||
currentAnimator.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果当前选中的角色动画组件丢失,记录警告并尝试继续显示信息
|
||||
Debug.LogWarning($"当前选中角色的动画组件为null (索引: {currentCharacter})。");
|
||||
// 考虑更强大的错误处理:跳到下一个有效角色,或者禁用此UI。
|
||||
}
|
||||
|
||||
// 考虑更强大的错误处理:跳到下一个有效角色,或者禁用此UI。
|
||||
// 更新角色信息
|
||||
var def = characterAnimation[currentCharacter].Item2;
|
||||
characterInformation.text = $"<color=#FFBF00>{def.label}</color>\n{def.description}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理用户点击左箭头按钮的逻辑,切换到上一个角色。
|
||||
/// 处理用户点击左箭头按钮的逻辑,切换到上一个角色。
|
||||
/// </summary>
|
||||
public void OnLeft()
|
||||
{
|
||||
@@ -207,7 +198,7 @@ namespace UI
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理用户点击右箭头按钮的逻辑,切换到下一个角色。
|
||||
/// 处理用户点击右箭头按钮的逻辑,切换到下一个角色。
|
||||
/// </summary>
|
||||
public void OnRight()
|
||||
{
|
||||
@@ -225,7 +216,7 @@ namespace UI
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理用户点击“确认”按钮的逻辑,选择当前角色并关闭UI。
|
||||
/// 处理用户点击“确认”按钮的逻辑,选择当前角色并关闭UI。
|
||||
/// </summary>
|
||||
public void OnEnter()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user