Lots of stuff
This commit is contained in:
+14
-2
@@ -17,15 +17,22 @@ namespace EvilSatellites
|
||||
public IGameObject Target;
|
||||
public IScreen Screen;
|
||||
public ISoundEffect RadarNoise;
|
||||
public ObjectType Filter;
|
||||
public Radar(IGameObject owner, IScreen screen)
|
||||
{
|
||||
Owner = owner;
|
||||
Screen = screen;
|
||||
RadarNoise = Screen.Manager.Sound.Load(@"sfx/ui/radar/pingEnemy.wav", false);
|
||||
RadarNoise.Loop = true;
|
||||
Filter = ObjectType.Satellite;
|
||||
Active = false;
|
||||
}
|
||||
|
||||
public void SetObjectType(ObjectType type)
|
||||
{
|
||||
Filter = type;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
RadarNoise.Reset();
|
||||
@@ -43,9 +50,10 @@ namespace EvilSatellites
|
||||
{
|
||||
if (objects.Count < 1) return;
|
||||
float minDistance = 1000;
|
||||
Target = null;
|
||||
foreach (var obj in objects)
|
||||
{
|
||||
if (obj.Type != ObjectType.Satellite) continue;
|
||||
if (obj.Type != Filter) continue;
|
||||
float distance = Vector3.Distance(obj.Position, Owner.Position);
|
||||
if (distance < minDistance)
|
||||
{
|
||||
@@ -53,7 +61,11 @@ namespace EvilSatellites
|
||||
Target = obj;
|
||||
}
|
||||
}
|
||||
if (Target == null) return;
|
||||
if (Target == null)
|
||||
{
|
||||
RadarNoise.Pitch = 0.1;
|
||||
return;
|
||||
}
|
||||
Vector3 radarTarget = (Target.Position - Owner.Position);
|
||||
radarTarget.Normalize();
|
||||
RadarNoise.Pitch = MathHelper.Clamp(0.1f / Vector3.Distance(Owner.Rotation.Forward, radarTarget) * 3f, 0, 1);
|
||||
|
||||
Reference in New Issue
Block a user