public void FaceHitbox(IAttackHitbox hitbox) { if (hitbox.Stats.FaceOwnerWhenHit) { character.Face(hitbox.GetOwner()); } }
public void Push(IAttackHitbox hitbox) { Vector2 launchVector = SmashCalculator.ShieldKnockbackVector(hitbox, this); Debug.Log(launchVector); character.Velocity = launchVector; }
public static Vector2 ShieldKnockbackVector(IAttackHitbox hitbox, IShield shield) { float pushAngle = FlipAngle(0.0f, hitbox.GetOwner(), shield.GetOwner()); Vector2 dir = (Vector2)(Quaternion.Euler(0, 0, pushAngle) * Vector2.right); return(dir * ShieldKnockbackStrength(hitbox, shield)); }
//Event Functions public virtual void OnHitStun(IAttackHitbox hitbox, GameObject entity) { if (entity.Equals(this.gameObject)) { //Interrupt any movement status if (movementStatus != null) { statusManager.RemoveStatus(movementStatus); } //Remove Tumbled State if (IsTumbled) { TimerManager.instance.StopTimer(TumbleDurationTimer); UnTumble(); } //Remove Helplessness if (IsHelpless) { IsHelpless = false; statusManager.RemoveStatus(helplessStatus); } //Interrupt any grabbing state if (isGrabbing) { GrabReleasePushed(); } //Interrupt edge grabbing if (isGrabbingEdge) { ReleaseEdge(); } } }
public override void OnHitStun(IAttackHitbox hitbox, GameObject entity) { base.OnHitStun(hitbox, entity); if (entity.Equals(this.gameObject)) { //Allow use of side special again when hitstunned canUseSideSpecial = true; } }
public void SaveDamage(IAttackHitbox hitbox, IDamageable damageable) { if (hitbox.GetOwner().Equals(this.gameObject)) { if (hitbox.GetName() == "NeutralSpecial" || hitbox.GetName() == "SideSpecial1" || hitbox.GetName() == "SideSpecial2") { return; } damageDealt += hitbox.Stats.Damage; ConvertDamageToStaticCharge(); } }
public void ShieldStun(IAttackHitbox hitbox) { if (!hitbox.Stats.HitStun) { return; } if (!IsShieldStunned) //If not shield stunned before { IsShieldStunned = true; character.IgnoreInput(true); } shieldStunFrameLeft = SmashCalculator.ShieldStunFrame(hitbox, this); }
public void OnHit(IAttackHitbox hitbox, GameObject entity) { if (IsInvulnerable) { return; } if (entity.Equals(this.gameObject)) { TakeDamage(hitbox.Stats.Damage); Push(hitbox); ShieldStun(hitbox); Freeze(hitbox.Stats.FreezeFrame); } }
//Event Functions public void OnHitStun(IAttackHitbox hitbox, GameObject entity) { if (entity.Equals(owner)) { if (IsActive) { DeactivateShield(); } if (IsShieldBroken) { OnShieldBreakOver(); } } }
//IDamageable Implementations public void OnHit(IAttackHitbox hitbox, GameObject entity) { if (IsInvulnerable) { return; } if (entity.Equals(this.gameObject)) { TakeDamage(hitbox.Stats.Damage); lastDamagedBy = hitbox.GetOwner(); EventManager.instance.InvokeOnDamageEvent(hitbox, this); FaceHitbox(hitbox); HitStun(hitbox); Launch(hitbox); Freeze(hitbox.Stats.FreezeFrame); } }
public void Launch(IAttackHitbox hitbox) { Vector2 launchVector = SmashCalculator.LaunchVector(hitbox, this); IsLaunched = SmashCalculator.Tumble(hitbox, this); if (IsLaunched) { statusManager.AddStatus(launchStatus); } Debug.Log("Launched! " + launchVector); character.Velocity = launchVector; //Release from grab if launched with high enough velocity if (character.GetGrabber() != null && SmashCalculator.GrabRelease(hitbox, this)) { character.GetGrabber().GetComponent <ICharacter>().GrabRelease(); } }
public static Vector2 LaunchVector(IAttackHitbox hitbox, IDamageable damageable) { Vector2 dir; float knockback = KnockbackValue(hitbox, damageable); if (hitbox.Stats.Angle == 361) //Sakurai Angle { float sakuraiAngle; if (knockback <= LOW_KNOCKBACK_VALUE) //Does not lift off victim when knockback is low { sakuraiAngle = 0; } else if (knockback >= HIGH_KNOCKBACK_VALUE) //Launch at maximum sakurai angle if knockback is high { sakuraiAngle = MAXIMUM_SAKURAI_ANGLE; } else //Launch at angle between 0 and MAXIMUM_SAKURAI_ANGLE { sakuraiAngle = (knockback - LOW_KNOCKBACK_VALUE) * MAXIMUM_SAKURAI_ANGLE / (HIGH_KNOCKBACK_VALUE - LOW_KNOCKBACK_VALUE); } //Flip Angle based on the hitbox owner position and victim position sakuraiAngle = FlipAngle(sakuraiAngle, hitbox.GetOwner(), damageable.GetOwner()); dir = (Vector2)(Quaternion.Euler(0, 0, sakuraiAngle) * Vector2.right); } else if (hitbox.Stats.Angle == 366) //Autolink Angle that pulls opponents into the hitbox { float autolinkAngle; Vector2 attackerVelocity = hitbox.GetOwner().GetComponent <ICharacter>().Velocity; dir = attackerVelocity; return(dir); } else { float launchAngle = hitbox.Stats.Angle; launchAngle = FlipAngle(launchAngle, hitbox.GetOwner(), damageable.GetOwner()); dir = (Vector2)(Quaternion.Euler(0, 0, launchAngle) * Vector2.right); } return(dir * LaunchStrength(knockback)); }
public void HitStun(IAttackHitbox hitbox) { if (!hitbox.Stats.HitStun) { return; } EventManager.instance.InvokeOnHitStunEvent(hitbox, this.gameObject); if (!IsHitStunned) //If not hitstunned before { IsHitStunned = true; character.IgnoreInput(true); character.EnableAirDeceleration(false); character.UnPreventWalkOffLedge(); } hitStunFrameLeft = SmashCalculator.HitStunDuration(hitbox, this); if (character.IsTumbling) { character.StopTumbling(); } if (character.IsTumbled) { character.UnTumble(); } }
public static float ShieldKnockbackValue(IAttackHitbox hitbox, IShield shield) { return((((hitbox.Stats.Damage / 10.0f + hitbox.Stats.Damage * hitbox.Stats.Damage / 20) * 1.4f) + 18.0f) * hitbox.Stats.KnockbackGrowth * 0.01f + hitbox.Stats.BaseKnockback); }
public void InvokeOnHitStunEvent(IAttackHitbox hitbox, GameObject entity) { Debug.Log("OnHitStunEvent Invoked"); onHitStunEvent.Invoke(hitbox, entity); }
public void InvokeOnDamageEvent(IAttackHitbox hitbox, IDamageable damageable) { Debug.Log("OnDamageEvent Invoked"); onDamageEvent.Invoke(hitbox, damageable); }
public static bool GrabRelease(IAttackHitbox hitbox, IDamageable damageable) { return(hitbox.Stats.HitStun && KnockbackValue(hitbox, damageable) >= MINIMUM_KNOCKBACK_TO_GRAB_RELEASE); }
public static bool Tumble(IAttackHitbox hitbox, IDamageable damageable) { return(hitbox.Stats.HitStun && KnockbackValue(hitbox, damageable) >= MINIMUM_KNOCKBACK_TO_TUMBLE); }
public static float KnockbackValue(IAttackHitbox hitbox, IDamageable damageable) { return((((damageable.Percentage / 10.0f + damageable.Percentage * hitbox.Stats.Damage / 20) * (200 / (100 + damageable.Weight)) * 1.4f) + 18.0f) * hitbox.Stats.KnockbackGrowth * 0.01f + hitbox.Stats.BaseKnockback); }
public static float LaunchStrength(IAttackHitbox hitbox, IDamageable damageable) { return(KnockbackValue(hitbox, damageable) * KNOCKBACK_TO_UNIT_RATIO); }
public static int HitStunDuration(IAttackHitbox hitbox, IDamageable damageable) { return(Mathf.Max(Mathf.RoundToInt(LaunchStrength(hitbox, damageable) * KNOCKBACK_TO_HITSTUN_RATIO), hitbox.Stats.MinimumHitStunFrame)); }
public static float ShieldKnockbackStrength(IAttackHitbox hitbox, IShield shield) { return(ShieldKnockbackValue(hitbox, shield) * KNOCKBACK_TO_UNIT_RATIO); }
public static int ShieldStunFrame(IAttackHitbox hitbox, IShield shield) { return(Mathf.RoundToInt(hitbox.Stats.Damage * 0.8f * hitbox.Stats.ShieldStunMultiplier) + 2); }