public virtual void HitByVehicle(Vehicle v) { if (Dead || !Active) return; Health -= 1 + ((float)Math.Abs(v.linearSpeed)) / 2f; Speed = v.Speed; AudioController.PlaySFX("hit", 0.5f, -0.4f, 0.4f, Position); ParticleController.Instance.AddVehicleWound(this); }
public virtual void EnterVehicle(Map gameMap) { if (Dead || !Active) return; if (drivingVehicle == null) { foreach (Vehicle v in VehicleController.Instance.Vehicles) { if ((v.Position - Position).Length() < 200f) { drivingVehicle = v; break; } } } else { // Exit vehicle //bool found = false; if (drivingVehicle is Chopper && ((Chopper)drivingVehicle).Height > 0f) ((Chopper)drivingVehicle).Land(gameMap); else { for (float a = 0f; a < MathHelper.TwoPi; a += 0.5f) { Vector2 pos = Helper.PointOnCircle(ref drivingVehicle.Position, 200, a); if (!gameMap.CheckTileCollision(pos) && !Helper.IsPointInShape(pos, drivingVehicle.CollisionVerts)) { if (drivingVehicle is Boat || !LineCollision(pos, gameMap, true)) { Position = pos; drivingVehicle = null; break; } } } } } }