(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:
2025-10-10 14:08:23 +08:00
parent 9a797479ff
commit 16b49f3d3a
1900 changed files with 114053 additions and 34157 deletions

View File

@@ -1,42 +1,47 @@
using Base;
using Data;
using Item;
using Prefab;
using System;
using System.Collections.Generic;
using System.Linq;
using Data;
using Item;
using Managers;
using Prefab;
using UnityEngine;
using Utils;
namespace Entity
{
public class Pickup : Entity
{
public ItemResource itemResource;
private void OnTriggerEnter2D(Collider2D other)
{
var entity = other.GetComponent<Character>();
if (entity == null) return;
if (entity.TryPickupItem(itemResource, 1) <= 0) Kill();
}
protected override void AutoBehave()
{
}
public override void SetTarget(Vector3 pos)
public override bool SetTarget(Vector3 pos)
{
return false;
}
public void Init(ItemDef itemDef)
{
itemResource = Managers.ItemResourceManager.Instance.GetItem(itemDef.defName);
itemResource = ItemResourceManager.Instance.GetItem(itemDef.defName);
// 预缓存枚举值(避免每次循环重复调用 Enum.GetValues
var states = Enum.GetValues(typeof(EntityState)).Cast<EntityState>().ToArray();
// 预初始化字典结构(减少内层循环的字典检查)
foreach (var state in states)
{
bodyNodes.TryAdd(state, new Dictionary<Orientation, GameObject>());
}
foreach (var state in states) bodyNodes.TryAdd(state, new Dictionary<Orientation, GameObject>());
var texture = itemResource.Icon;
if (texture.Count == 1)
{
var imageObj = Instantiate(Utils.GameObjectCreate.ImagePrefab.gameObject, body.transform);
var imageObj = Instantiate(AnimationUtils.ImagePrefab.gameObject, body.transform);
imageObj.transform.localPosition = Vector3.zero;
bodyNodes[EntityState.Idle][Orientation.Down] = imageObj;
var image = imageObj.GetComponent<ImagePrefab>();
@@ -44,25 +49,15 @@ namespace Entity
}
else if (texture.Count > 1)
{
var animatorObj = Instantiate(Utils.GameObjectCreate.AnimatorPrefab.gameObject, body.transform);
var animatorObj = Instantiate(AnimationUtils.AnimatorPrefab.gameObject, body.transform);
animatorObj.transform.localPosition = Vector3.zero;
bodyNodes[EntityState.Idle][Orientation.Down] = animatorObj;
var animator = animatorObj.GetComponent<SpriteAnimator>();
animator.SetSprites(texture.ToArray());
}
SetBodyTexture(EntityState.Idle, Orientation.Down);
}
private void OnTriggerEnter2D(Collider2D other)
{
var entity = other.GetComponent<Character>();
if (entity == null) return;
if (entity.TryPickupItem(itemResource, 1) <= 0)
{
Kill();
}
}
}
}