private void AttackPlayer(PlayerUnitController player) { PlayerVulnerability vulnerability = player.di.vulnerability; Vector2 lookVector = new Vector2(physics.flip.Direction.ToFloat(), 1); if (vulnerability.IsGuardingInOpposingDirection(physics.flip.Direction)) { float recoilTileForce; if (IsFullAssembly(player)) { stateMachine.attack.StartStagger(); recoilTileForce = data.guardFullAssemblyRecoilTileForce; // TODO: short stagger? } else { recoilTileForce = data.guardPartialAssemblyRecoilTileForce; Vector2 playerRecoil = RecoilHelpers.GetRecoilFromTo(player.transform, controller.transform, recoilTileForce); player.di.stateMachine.SetRecoilState(playerRecoil); } } else if (vulnerability.IsVulnerable()) { PlayerDamageModule damage = player.di.damage; Vector2 collisionRecoil = RecoilHelpers.GetRecoilNormalFromTo(player.transform, controller.transform); if (IsFullAssembly(player)) { damage.TakeDamage(data.attackDamage, TileHelpers.TileToWorld(data.attackFullAssemblyRecoilTileForce) * collisionRecoil); } else { damage.TakeDamage(data.attackDamage, TileHelpers.TileToWorld(data.attackPartialAssemblyRecoilTileForce) * collisionRecoil); } } }
public void StartState() { physics.force.SetForce(value: pushForce, duration: paralyzeDuration, curve: hitForceCurve.Evaluate); AudioSingleton.PlaySound(AudioSingleton.Instance.clips.playerHit); if (vulnerability.IsVulnerable()) { vulnerability.SetInvulnerable(invulnerableTime); } }
private void ReceieveDamageFrom(EnemyCollider enemy) { // TODO: move to player damage? Vector2 pushVector = enemy.attack.GetRecoilFor(controller); if (vulnerability.IsVulnerable()) { damage.TakeDamage(enemy.attack.GetDamage(), pushVector); } else { damage.TakeDamage(0, pushVector); } enemy.attack.HandleCollisionAttack(controller); }