public void FaceHitbox(IAttackHitbox hitbox) { if (hitbox.Stats.FaceOwnerWhenHit) { character.Face(hitbox.GetOwner()); } }
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)); }
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 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)); }
//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); } }