hack hack hack... working dog

This commit is contained in:
Chris Forbes
2010-05-06 22:15:02 +12:00
parent 888706befa
commit acf55f1bb0
8 changed files with 41 additions and 17 deletions

View File

@@ -23,8 +23,19 @@ namespace OpenRA.Traits.Activities
class Leap : IActivity
{
Actor target;
float2 initialLocation;
float t;
public Leap(Actor target) { this.target = target; }
const int delay = 6;
public Leap(Actor self, Actor target)
{
this.target = target;
initialLocation = self.CenterLocation;
self.traits.Get<RenderInfantry>().Attacking(self);
Sound.Play("dogg5p.aud");
}
public IActivity NextActivity { get; set; }
@@ -33,6 +44,17 @@ namespace OpenRA.Traits.Activities
if (target == null || !target.IsInWorld)
return NextActivity;
t += (1f / delay);
self.CenterLocation = float2.Lerp(initialLocation, target.CenterLocation, t);
if (t >= 1f)
{
self.traits.Get<Mobile>().TeleportTo(self, target.Location);
target.InflictDamage(self, target.Health, null); // kill it
return NextActivity;
}
return this;
}

View File

@@ -187,12 +187,15 @@ namespace OpenRA.Traits
ScheduleDelayedAction( FireDelay( self, self.Info.Traits.Get<AttackBaseInfo>() ), () =>
{
var projectile = args.weapon.Projectile.Create(args);
if (projectile != null)
self.World.Add(projectile);
if (args.weapon.Projectile != null)
{
var projectile = args.weapon.Projectile.Create(args);
if (projectile != null)
self.World.Add(projectile);
if (!string.IsNullOrEmpty(args.weapon.Report))
Sound.Play(args.weapon.Report + ".aud");
if (!string.IsNullOrEmpty(args.weapon.Report))
Sound.Play(args.weapon.Report + ".aud");
}
});
foreach (var na in self.traits.WithInterface<INotifyAttack>())

View File

@@ -37,12 +37,13 @@ namespace OpenRA.Traits
base.Tick(self);
if (target == null || !target.IsInWorld) return;
if (self.GetCurrentActivity() is Leap) return;
var weapon = self.GetPrimaryWeapon();
if (weapon.Range * weapon.Range < (target.Location - self.Location).LengthSquared) return;
self.CancelActivity();
self.QueueActivity(new Leap(target));
self.QueueActivity(new Leap(self, target));
}
}
}