(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,4 +1,4 @@
using System;
using Base;
using Data;
using Item;
using Managers;
@@ -6,16 +6,49 @@ using UnityEngine;
namespace Entity
{
public class Monster:LivingEntity
public class Monster : LivingEntity
{
private WeaponResource weapon;
private void OnCollisionStay2D(Collision2D other)
{
if (!other.gameObject.CompareTag("Player")) return;
var playerEntity = other.gameObject.GetComponent<Entity>();
playerEntity?.OnHit(10);
}
public override void Init(EntityDef entityDefine)
{
base.Init(entityDefine);
var monsterDef = entityDefine as MonsterDef;
if (monsterDef != null)
{
weapon = (WeaponResource)ItemResourceManager.Instance.GetItem(monsterDef.weapon.defName);
weapon = ItemResourceManager.Instance.GetItem(monsterDef.weapon?.defName) as WeaponResource;
if (monsterDef.defaultHediff != null)
{
foreach (var hediffDef in monsterDef.defaultHediff)
{
AddHediff(new Hediff(hediffDef));
}
}
}
}
protected override void ExecuteMeleeAttack(WeaponResource weapon)
{
var attackRange = AttributesNow.attackRange;
var attackTargetCount = AttributesNow.attackTargetCount;
var hits = EntityManager.FindEntity<LivingEntity>(Position, attackRange);
foreach (var hit in hits)
{
if (attackTargetCount <= 0) break; // 已达到最大攻击目标数
if (hit.gameObject == gameObject) continue; // 不攻击自己
var relation = AffiliationManager.Instance.GetRelation(affiliation, hit.affiliation);
if (!Setting.Instance.CurrentSettings.friendlyFire && relation != Relation.Hostile) continue;
hit.OnHit(this);
attackTargetCount--;
}
}
@@ -23,13 +56,5 @@ namespace Entity
{
return weapon;
}
private void OnCollisionStay2D(Collision2D other)
{
if (!other.gameObject.CompareTag("Player")) return;
var playerEntity = other.gameObject.GetComponent<Entity>();
playerEntity?.OnHit(this);
}
}
}