|
@ -344,15 +344,28 @@ namespace GWConquest |
|
|
Formation.TakeMoraleDamage((Hitpoints <= 0 ? Class.Morale : remainingDamage * moraleFactor) * flankFactor); |
|
|
Formation.TakeMoraleDamage((Hitpoints <= 0 ? Class.Morale : remainingDamage * moraleFactor) * flankFactor); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var evnt = UnitDamageAnimEvent.Create(entity); |
|
|
|
|
|
evnt.Attacker = attacker.entity; |
|
|
|
|
|
evnt.IsDead = State.Hitpoints <= 0; |
|
|
|
|
|
evnt.IsDemoralized = IsDemoralized; |
|
|
|
|
|
evnt.ShieldDamage = Shields > 0; |
|
|
|
|
|
evnt.ShieldBroken = shieldBroken; |
|
|
|
|
|
evnt.GlancingHit = isGlancingHit; |
|
|
|
|
|
evnt.WeaponType = (int) weaponType; |
|
|
|
|
|
evnt.Send(); |
|
|
|
|
|
|
|
|
DamageAnimationType animType = DamageAnimationType.Damage; |
|
|
|
|
|
if(Hitpoints <= 0) |
|
|
|
|
|
{ |
|
|
|
|
|
animType = DamageAnimationType.Death; |
|
|
|
|
|
} |
|
|
|
|
|
else if(IsDemoralized) |
|
|
|
|
|
{ |
|
|
|
|
|
animType = DamageAnimationType.Demoralized; |
|
|
|
|
|
} |
|
|
|
|
|
else if(shieldBroken) |
|
|
|
|
|
{ |
|
|
|
|
|
animType = DamageAnimationType.ShieldBroken; |
|
|
|
|
|
} |
|
|
|
|
|
else if(Shields > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
animType = DamageAnimationType.ShieldDamage; |
|
|
|
|
|
} |
|
|
|
|
|
else if(isGlancingHit) |
|
|
|
|
|
{ |
|
|
|
|
|
animType = DamageAnimationType.GlancingHit; |
|
|
|
|
|
} |
|
|
|
|
|
PlayUnitDamageAnimation(weaponType, animType, attacker); |
|
|
|
|
|
|
|
|
if(Hitpoints <= 0) |
|
|
if(Hitpoints <= 0) |
|
|
{ |
|
|
{ |
|
@ -364,41 +377,44 @@ namespace GWConquest |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public override void OnEvent(UnitDamageAnimEvent evnt) |
|
|
|
|
|
|
|
|
public enum DamageAnimationType |
|
|
|
|
|
{ |
|
|
|
|
|
Death, Damage, Demoralized, ShieldDamage, ShieldBroken, GlancingHit |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[ClientRpc] |
|
|
|
|
|
public void PlayUnitDamageAnimation(WeaponType weaponType, DamageAnimationType animationType, NullableNetworkBehaviourReference attacker) |
|
|
{ |
|
|
{ |
|
|
if(IconEnabled) |
|
|
if(IconEnabled) |
|
|
{ |
|
|
{ |
|
|
WeaponType weaponType = (WeaponType)evnt.WeaponType; |
|
|
|
|
|
|
|
|
|
|
|
if (evnt.IsDead) |
|
|
|
|
|
|
|
|
switch(animationType) |
|
|
{ |
|
|
{ |
|
|
CurrentIcon.PlayDeathAnim(evnt); |
|
|
|
|
|
} |
|
|
|
|
|
else if(evnt.IsDemoralized && !DemoralizedAnimPlayed) |
|
|
|
|
|
{ |
|
|
|
|
|
CurrentIcon.PlayDemoralizedAnim(); |
|
|
|
|
|
DemoralizedAnimPlayed = true; |
|
|
|
|
|
} |
|
|
|
|
|
else if(evnt.ShieldBroken) |
|
|
|
|
|
{ |
|
|
|
|
|
CurrentIcon.PlayShieldBreakAnim(); |
|
|
|
|
|
} |
|
|
|
|
|
else if(evnt.ShieldDamage) |
|
|
|
|
|
{ |
|
|
|
|
|
CurrentIcon.PlayShieldDamageAnim(); |
|
|
|
|
|
} |
|
|
|
|
|
else if(evnt.GlancingHit) |
|
|
|
|
|
{ |
|
|
|
|
|
CurrentIcon.PlayGlancingHitAnim(weaponType == WeaponType.Light || weaponType == WeaponType.Ship); |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
CurrentIcon.PlayHitAnim(evnt); |
|
|
|
|
|
|
|
|
case DamageAnimationType.Death: |
|
|
|
|
|
CurrentIcon.PlayDeathAnim(attacker.GetBehaviour<Unit>()); |
|
|
|
|
|
break; |
|
|
|
|
|
case DamageAnimationType.Demoralized: |
|
|
|
|
|
CurrentIcon.PlayDemoralizedAnim(); |
|
|
|
|
|
DemoralizedAnimPlayed = true; |
|
|
|
|
|
break; |
|
|
|
|
|
case DamageAnimationType.ShieldBroken: |
|
|
|
|
|
CurrentIcon.PlayShieldBreakAnim(); |
|
|
|
|
|
break; |
|
|
|
|
|
case DamageAnimationType.ShieldDamage: |
|
|
|
|
|
CurrentIcon.PlayShieldDamageAnim(); |
|
|
|
|
|
break; |
|
|
|
|
|
case DamageAnimationType.GlancingHit: |
|
|
|
|
|
CurrentIcon.PlayGlancingHitAnim(weaponType == WeaponType.Light || weaponType == WeaponType.Ship); |
|
|
|
|
|
break; |
|
|
|
|
|
case DamageAnimationType.Damage: |
|
|
|
|
|
CurrentIcon.PlayHitAnim(attacker.GetBehaviour<Unit>()); |
|
|
|
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public override void OnEvent(UnitAttackingEvent evnt) |
|
|
|
|
|
|
|
|
public void PlayUnitAttackingAnimation(NullableNetworkBehaviourReference target, bool hit, WeaponType weaponType) |
|
|
{ |
|
|
{ |
|
|
if(IconEnabled) |
|
|
if(IconEnabled) |
|
|
{ |
|
|
{ |
|
@ -406,15 +422,13 @@ namespace GWConquest |
|
|
|
|
|
|
|
|
if(Class.UnitType == UnitType.Artillery) |
|
|
if(Class.UnitType == UnitType.Artillery) |
|
|
{ |
|
|
{ |
|
|
SoundEffects.Instance.PlayEffect("ArtilleryShot", volumeMultilpier: evnt.Hit? 1f: 0.5f); |
|
|
|
|
|
|
|
|
SoundEffects.Instance.PlayEffect("ArtilleryShot", volumeMultilpier: hit? 1f: 0.5f); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
|
|
|
|
|
|
var target = evnt.Target?.GetComponent<Unit>(); |
|
|
|
|
|
WeaponType weaponType = (WeaponType)evnt.WeaponType; |
|
|
|
|
|
if(target != null && evnt.Hit) |
|
|
|
|
|
|
|
|
if(target.HasValue && hit) |
|
|
{ |
|
|
{ |
|
|
CurrentIcon.GetComponentInParent<BattleUI>().SpawnShotEffect(CurrentIcon, target.CurrentIcon, weaponType); |
|
|
|
|
|
|
|
|
CurrentIcon.GetComponentInParent<BattleUI>().SpawnShotEffect(CurrentIcon, target.GetBehaviour<Unit>().CurrentIcon, weaponType); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
CurrentIcon.GetComponentInParent<BattleUI>().SpawnShotEffect(CurrentIcon, null, weaponType); |
|
|
CurrentIcon.GetComponentInParent<BattleUI>().SpawnShotEffect(CurrentIcon, null, weaponType); |
|
@ -423,15 +437,14 @@ namespace GWConquest |
|
|
} |
|
|
} |
|
|
else if(Class.ZoneType == ZoneType.Space && IngameUI.PlanetViewEnabled) |
|
|
else if(Class.ZoneType == ZoneType.Space && IngameUI.PlanetViewEnabled) |
|
|
{ |
|
|
{ |
|
|
var target = evnt.Target?.GetComponent<Unit>(); |
|
|
|
|
|
if(evnt.Hit && target != null) |
|
|
|
|
|
|
|
|
if(target.HasValue && hit) |
|
|
{ |
|
|
{ |
|
|
var planetView = IngameUI.Instance.PlanetView; |
|
|
var planetView = IngameUI.Instance.PlanetView; |
|
|
if(planetView.selectedPlanet == Formation.currentZone.planet) |
|
|
if(planetView.selectedPlanet == Formation.currentZone.planet) |
|
|
{ |
|
|
{ |
|
|
if(planetView.FleetIcons.isActiveAndEnabled) |
|
|
if(planetView.FleetIcons.isActiveAndEnabled) |
|
|
{ |
|
|
{ |
|
|
planetView.FleetIcons.PlayShotEffect(this, target); |
|
|
|
|
|
|
|
|
planetView.FleetIcons.PlayShotEffect(this, target.GetBehaviour<Unit>()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -547,6 +560,12 @@ namespace GWConquest |
|
|
SetActionCooldown(GameManager.Instance.ArtilleryCooldown / movement); |
|
|
SetActionCooldown(GameManager.Instance.ArtilleryCooldown / movement); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[ServerRpc] |
|
|
|
|
|
public void StartShellingRpc(NetworkBehaviourReference target) |
|
|
|
|
|
{ |
|
|
|
|
|
StartShelling(target.GetBehaviour<BattleFlank>()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public float MoraleDamageFactor { |
|
|
public float MoraleDamageFactor { |
|
|
get => 0.8f; |
|
|
get => 0.8f; |
|
|
} |
|
|
} |
|
@ -624,4 +643,6 @@ namespace GWConquest |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |