1
This commit is contained in:
1 parent
fb353c45a7
commit
84d0a510bb
46 files changed
+9866
-94
No files matched your search
+49
-20
@@ -409,6 +409,11 @@ public class UnitBase : MonoBehaviour
|
||||
|
||||
FaceTarget(friend);
|
||||
|
||||
if (TryReleaseSkill())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//根据目标攻击时长加速或减速完整攻击动画
|
||||
SetAttackAnimationSpeed();
|
||||
|
||||
@@ -419,6 +424,11 @@ public class UnitBase : MonoBehaviour
|
||||
}
|
||||
|
||||
private void FaceTarget(GameObject opponent)
|
||||
{
|
||||
FaceTarget(opponent, modelFacingOffset);
|
||||
}
|
||||
|
||||
private void FaceTarget(GameObject opponent, float facingOffset)
|
||||
{
|
||||
if (opponent == null)
|
||||
{
|
||||
@@ -432,10 +442,38 @@ public class UnitBase : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
ApplyFacingRotation(direction);
|
||||
ApplyFacingRotation(direction, facingOffset);
|
||||
}
|
||||
|
||||
private void ApplyFacingRotation(Vector3 direction)
|
||||
public void FaceCurrentTarget()
|
||||
{
|
||||
FaceTarget(target);
|
||||
}
|
||||
|
||||
public void FaceCurrentTarget(float facingOffset)
|
||||
{
|
||||
FaceTarget(target, facingOffset);
|
||||
}
|
||||
|
||||
private bool TryReleaseSkill()
|
||||
{
|
||||
if (worldHealthBar == null
|
||||
|| !worldHealthBar.IsEnergyFull
|
||||
|| unitSkill == null
|
||||
|| target == null
|
||||
|| !target.activeInHierarchy)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
worldHealthBar.ResetEnergy();
|
||||
state = State.Alert;
|
||||
animator.SetInteger("speed", 0);
|
||||
unitSkill.ReleaseSkill();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void ApplyFacingRotation(Vector3 direction, float facingOffset)
|
||||
{
|
||||
direction.y = 0f;
|
||||
if (direction.sqrMagnitude <= 0.0001f)
|
||||
@@ -446,7 +484,7 @@ public class UnitBase : MonoBehaviour
|
||||
Quaternion targetRotation = Quaternion.LookRotation(direction, Vector3.up);
|
||||
transform.rotation = Quaternion.Euler(
|
||||
0f,
|
||||
targetRotation.eulerAngles.y + modelFacingOffset,
|
||||
targetRotation.eulerAngles.y + facingOffset,
|
||||
0f);
|
||||
}
|
||||
|
||||
@@ -622,6 +660,11 @@ public class UnitBase : MonoBehaviour
|
||||
}
|
||||
|
||||
public void FireSkillProjectile(GameObject opponent)
|
||||
{
|
||||
FireSkillProjectile(opponent, 1f);
|
||||
}
|
||||
|
||||
public void FireSkillProjectile(GameObject opponent, float damageMultiplier)
|
||||
{
|
||||
if (opponent == null || projectilePrefab == null || projectileSpawnPoint == null)
|
||||
{
|
||||
@@ -636,11 +679,11 @@ public class UnitBase : MonoBehaviour
|
||||
if (projectile != null)
|
||||
{
|
||||
// 技能箭不再次积攒能量,避免技能触发递归。
|
||||
projectile.Initialize(opponent, attackPower, gameObject, projectileSpeed, projectileLifetime, false);
|
||||
projectile.Initialize(opponent, attackPower * Mathf.Max(0f, damageMultiplier), gameObject, projectileSpeed, projectileLifetime, false);
|
||||
}
|
||||
}
|
||||
|
||||
// 普通攻击命中后积攒能量,满能量时清空能量并调用技能占位方法。
|
||||
// 普通攻击命中后只积攒能量,大招在下一次普攻开始前释放。
|
||||
private void AddAttackEnergy()
|
||||
{
|
||||
if (worldHealthBar == null || energyPerAttack <= 0f)
|
||||
@@ -648,21 +691,7 @@ public class UnitBase : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
if (!worldHealthBar.AddEnergy(energyPerAttack))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
worldHealthBar.ResetEnergy();
|
||||
ReleaseSkill();
|
||||
}
|
||||
|
||||
private void ReleaseSkill()
|
||||
{
|
||||
if (unitSkill != null)
|
||||
{
|
||||
unitSkill.ReleaseSkill();
|
||||
}
|
||||
worldHealthBar.AddEnergy(energyPerAttack);
|
||||
}
|
||||
|
||||
private float GetSkillAnimationSpeed(float targetDuration)
|
||||
|
||||
Reference in new issue
Block a user