(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,14 +1,52 @@
using Base;
using Data;
using Managers;
using Prefab;
using UnityEngine;
using Utils;
namespace Entity
{
public class Bullet : Entity
{
public Entity bulletSource { get; private set; }
public float lifeTime = 10;
private BulletDef bulletDef;
public Entity bulletSource { get; private set; }
private void OnTriggerEnter2D(Collider2D other)
{
var entity = other.GetComponent<EntityPrefab>()?.entity;
if (!entity)
{
Kill();
return;
}
if (IsDead || entity == bulletSource || entity is not CombatantEntity) return;
if (AffiliationManager.Instance.GetRelation(bulletSource.affiliation, entity.affiliation) !=
Relation.Friendly || Setting.Instance.CurrentSettings.friendlyFire)
{
entity.OnHit(bulletSource);
bulletSource.OnDealHit(entity);
if (bulletDef?.hitHediffs != null && entity is LivingEntity livingEntity)
foreach (var hediff in bulletDef.hitHediffs)
livingEntity.AddHediff(new Hediff(hediff));
}
else
{
return; // 如果是友好关系且不允许友军伤害,则不处理
}
OnHit(1, false);
}
public override void Init(EntityDef entityDefine)
{
base.Init(entityDefine);
bulletDef = entityDefine as BulletDef;
}
public void SetBulletSource(Entity source)
@@ -16,51 +54,23 @@ namespace Entity
bulletSource = source;
AttributesNow.attack = source.AttributesNow.attack;
var weapon = source.GetCurrentWeapon();
if (weapon != null)
{
lifeTime = weapon.Attributes.attackRange / AttributesNow.moveSpeed;
}
if (weapon != null) lifeTime = weapon.Attributes.attackRange / AttributesNow.moveSpeed;
affiliation = source.affiliation;
}
public override void SetTarget(Vector3 pos)
public override bool SetTarget(Vector3 pos)
{
base.SetTarget(pos);
Utils.RotateTool.RotateTransformToDirection(transform, Direction);
RotateTool.RotateTransformToDirection(transform, Direction);
return true;
}
protected override void AutoBehave()
{
Move();
lifeTime -= Time.deltaTime;
if (lifeTime <= 0)
{
Kill();
}
if (lifeTime <= 0) Kill();
}
private void OnTriggerEnter2D(Collider2D other)
{
var entity = other.GetComponent<Entity>();
if (!entity)
{
Kill();
return;
}
if (IsDead || entity == bulletSource || entity is Pickup) return;
if (Managers.AffiliationManager.Instance.GetRelation(bulletSource.affiliation, entity.affiliation) != Relation.Friendly || Setting.Instance.CurrentSettings.friendlyFire)
{
entity.OnHit(this);
}
else
{
return; // 如果是友好关系且不允许友军伤害,则不处理
}
AttributesNow.health -= 1;
}
}
}