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 CastRay(Vector2 origin) { Vector2 rayVector = Vector2.down; float skinWidth = Constants.SKIN_WIDTH; float rayLength = this.rayLength + skinWidth; if (debug) { Debug.DrawLine(origin, origin + (rayVector * rayLength), Color.red); } RaycastHit2D hit = Physics2D.Raycast(origin, rayVector, rayLength, layerMask); if (hit) { PlayerUnitController player = InteractiveHelpers.GetPlayer(hit.collider); if (player) { float collideDistance = 1f; float allowedMove = player.di.physics.movement.GetAllowedMovement(collideDistance, Dir4.down); if (allowedMove < collideDistance) { PlayerDamageModule damage = player.di.damage; damage.TakeFullDamage(); } } } }
public void Inject(PlayerUnitDI di) { hp = di.hp; damage = di.damage; PlayerBaseStats stats = di.stats; OnStatsChange(stats); if (stats.OnChange != null) { stats.OnChange += OnStatsChange; } }
public void Inject(PlayerUnitDI di) { physics = di.physics; damage = di.damage; }