We've got enemies and movement!!
This commit is contained in:
parent
42ee0bf65d
commit
3287e8ea43
26 changed files with 1409 additions and 161 deletions
|
|
@ -249,24 +249,27 @@ namespace TD.Combat
|
|||
|
||||
private void ApplyDamageToTarget(TowerDefinition def, EnemyHealth primary, Vector3 primaryPos)
|
||||
{
|
||||
PlayerSlot owner = towerInstance.Owner;
|
||||
|
||||
switch (def.TargetType)
|
||||
{
|
||||
case TargetType.Single:
|
||||
HitEnemy(def, primary);
|
||||
HitEnemy(def, primary, owner);
|
||||
break;
|
||||
|
||||
case TargetType.Splash:
|
||||
HitEnemy(def, primary);
|
||||
ApplySplash(def, primary, primaryPos);
|
||||
HitEnemy(def, primary, owner);
|
||||
ApplySplash(def, primary, primaryPos, owner);
|
||||
break;
|
||||
|
||||
case TargetType.Chain:
|
||||
ApplyChain(def, primary);
|
||||
ApplyChain(def, primary, owner);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplySplash(TowerDefinition def, EnemyHealth primary, Vector3 origin)
|
||||
private void ApplySplash(TowerDefinition def, EnemyHealth primary,
|
||||
Vector3 origin, PlayerSlot owner)
|
||||
{
|
||||
if (def.SplashRadius <= 0f) return;
|
||||
|
||||
|
|
@ -277,25 +280,22 @@ namespace TD.Combat
|
|||
{
|
||||
var eh = s_overlapBuffer[i].GetComponent<EnemyHealth>();
|
||||
if (eh == null || eh.IsDead || (object)eh == (object)primary) continue;
|
||||
HitEnemy(def, eh);
|
||||
HitEnemy(def, eh, owner);
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyChain(TowerDefinition def, EnemyHealth primary)
|
||||
private void ApplyChain(TowerDefinition def, EnemyHealth primary, PlayerSlot owner)
|
||||
{
|
||||
// Chain hit positions are collected and sent to clients for the
|
||||
// future lightning-arc visual. The list is per-fire, so allocation
|
||||
// here is acceptable; optimise to a pool if chain towers become hot.
|
||||
var hitPositions = new List<Vector3> { primary.transform.position };
|
||||
var alreadyHit = new HashSet<EnemyHealth> { primary };
|
||||
|
||||
HitEnemy(def, primary);
|
||||
HitEnemy(def, primary, owner);
|
||||
|
||||
EnemyHealth current = primary;
|
||||
for (int jump = 0; jump < def.ChainCount; jump++)
|
||||
{
|
||||
EnemyHealth next = null;
|
||||
float bestSqr = float.MaxValue;
|
||||
EnemyHealth next = null;
|
||||
float bestSqr = float.MaxValue;
|
||||
|
||||
int count = Physics.OverlapSphereNonAlloc(
|
||||
current.transform.position, def.ChainRange, s_overlapBuffer, enemyLayerMask);
|
||||
|
|
@ -313,20 +313,20 @@ namespace TD.Combat
|
|||
|
||||
alreadyHit.Add(next);
|
||||
hitPositions.Add(next.transform.position);
|
||||
HitEnemy(def, next);
|
||||
HitEnemy(def, next, owner);
|
||||
current = next;
|
||||
}
|
||||
|
||||
ChainFiredClientRpc(hitPositions.ToArray());
|
||||
}
|
||||
|
||||
private void HitEnemy(TowerDefinition def, EnemyHealth target)
|
||||
private void HitEnemy(TowerDefinition def, EnemyHealth target, PlayerSlot owner)
|
||||
{
|
||||
target.TakeDamage(def.Damage, def.DamageType);
|
||||
ApplyStatusEffect(def, target);
|
||||
target.TakeDamage(def.Damage, def.DamageType, owner);
|
||||
ApplyStatusEffect(def, target, owner);
|
||||
}
|
||||
|
||||
private void ApplyStatusEffect(TowerDefinition def, EnemyHealth target)
|
||||
private void ApplyStatusEffect(TowerDefinition def, EnemyHealth target, PlayerSlot owner)
|
||||
{
|
||||
if (def.EffectDuration <= 0f) return;
|
||||
|
||||
|
|
@ -341,7 +341,7 @@ namespace TD.Combat
|
|||
if (magnitude <= 0f) return;
|
||||
|
||||
target.GetComponent<EnemyStatus>()
|
||||
?.ApplyEffect(def.DamageType, magnitude, def.EffectDuration);
|
||||
?.ApplyEffect(def.DamageType, magnitude, def.EffectDuration, owner);
|
||||
}
|
||||
|
||||
// ----- Projectile spawning -----------------------------------------
|
||||
|
|
@ -370,7 +370,8 @@ namespace TD.Combat
|
|||
def.DotDamagePerSecond,
|
||||
def.EffectDuration,
|
||||
def.ProjectileSpeed,
|
||||
enemyLayerMask);
|
||||
enemyLayerMask,
|
||||
towerInstance.Owner);
|
||||
|
||||
go.GetComponent<NetworkObject>().Spawn();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue