(client) feat:状态UI
This commit is contained in:
@ -52,7 +52,13 @@ namespace Entity
|
||||
/// <summary>
|
||||
/// 实体的属性定义,包括生命值、攻击力、防御力等。
|
||||
/// </summary>
|
||||
public Attributes attributes = new();
|
||||
public virtual Attributes attributes { get; protected set; }
|
||||
|
||||
private Attributes _baseAttributes;
|
||||
public virtual Attributes baseAttributes
|
||||
{
|
||||
get { return _baseAttributes ??= new Attributes(entityDef.attributes); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体当前的移动方向。
|
||||
@ -169,8 +175,6 @@ namespace Entity
|
||||
// 协程引用
|
||||
private Coroutine _attackCoroutine;
|
||||
|
||||
protected List<Hediff> hediffs;
|
||||
|
||||
|
||||
[SerializeField] private float _hitBarUIShowTime = 5;
|
||||
private float _hitBarUIShowTimer = 0;
|
||||
@ -462,7 +466,7 @@ namespace Entity
|
||||
/// <summary>
|
||||
/// 更新实体的逻辑,包括玩家控制和自动行为。
|
||||
/// </summary>
|
||||
public void Tick()
|
||||
public virtual void Tick()
|
||||
{
|
||||
if (_walkingTimer > 0)
|
||||
{
|
||||
@ -523,7 +527,7 @@ namespace Entity
|
||||
if (IsAttacking || IsDead) return; // 死亡时无法攻击
|
||||
|
||||
// 尝试获取当前武器
|
||||
WeaponResource currentWeapon = GetCurrentWeapon();
|
||||
var currentWeapon = GetCurrentWeapon();
|
||||
|
||||
// 如果没有武器,可以选择进行徒手攻击或者直接返回
|
||||
// 暂时设定为:如果没有武器,则不进行攻击
|
||||
@ -777,7 +781,7 @@ namespace Entity
|
||||
}
|
||||
|
||||
// STEP 4: 等待到攻击判定时间
|
||||
float elapsedTime = 0f;
|
||||
var elapsedTime = 0f;
|
||||
while (elapsedTime < weapon.AttackDetectionTime)
|
||||
{
|
||||
if (IsDead)
|
||||
@ -799,7 +803,7 @@ namespace Entity
|
||||
|
||||
ExecuteWeaponAction(weapon);
|
||||
|
||||
float remainingAnimationTime = weapon.AttackAnimationTime - elapsedTime;
|
||||
var remainingAnimationTime = weapon.AttackAnimationTime - elapsedTime;
|
||||
if (remainingAnimationTime > 0)
|
||||
{
|
||||
yield return new WaitForSeconds(remainingAnimationTime);
|
||||
@ -884,10 +888,10 @@ namespace Entity
|
||||
|
||||
// 获取子弹方向。这里使用实体当前的移动方向作为子弹发射方向
|
||||
// 更复杂的逻辑可能根据鼠标位置、目标位置等确定
|
||||
Vector3 bulletDirection = direction; // 实体当前的朝向
|
||||
var bulletDirection = direction; // 实体当前的朝向
|
||||
if (PlayerControlled && Input.GetMouseButton(0)) // 玩家控制时,如果鼠标按下,尝试朝鼠标方向发射
|
||||
{
|
||||
Vector3 mouseWorldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
var mouseWorldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
mouseWorldPos.z = transform.position.z; // 保持Z轴一致
|
||||
bulletDirection = (mouseWorldPos - transform.position).normalized;
|
||||
}
|
||||
|
Reference in New Issue
Block a user