Make Infiltrates grant player experience

This commit is contained in:
Oliver Brakmann
2016-07-10 14:03:01 +02:00
parent 1e86326cbc
commit ac07c81e08
3 changed files with 12 additions and 3 deletions

View File

@@ -21,13 +21,15 @@ namespace OpenRA.Mods.RA.Activities
readonly Stance validStances; readonly Stance validStances;
readonly Cloak cloak; readonly Cloak cloak;
readonly string notification; readonly string notification;
readonly int experience;
public Infiltrate(Actor self, Actor target, EnterBehaviour enterBehaviour, Stance validStances, string notification) public Infiltrate(Actor self, Actor target, EnterBehaviour enterBehaviour, Stance validStances, string notification, int experience)
: base(self, target, enterBehaviour) : base(self, target, enterBehaviour)
{ {
this.target = target; this.target = target;
this.validStances = validStances; this.validStances = validStances;
this.notification = notification; this.notification = notification;
this.experience = experience;
cloak = self.TraitOrDefault<Cloak>(); cloak = self.TraitOrDefault<Cloak>();
} }
@@ -46,6 +48,10 @@ namespace OpenRA.Mods.RA.Activities
foreach (var t in target.TraitsImplementing<INotifyInfiltrated>()) foreach (var t in target.TraitsImplementing<INotifyInfiltrated>())
t.Infiltrated(target, self); t.Infiltrated(target, self);
var exp = self.Owner.PlayerActor.TraitOrDefault<PlayerExperience>();
if (exp != null)
exp.GiveExperience(experience);
if (!string.IsNullOrEmpty(notification)) if (!string.IsNullOrEmpty(notification))
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech",
notification, self.Owner.Faction.InternalName); notification, self.Owner.Faction.InternalName);

View File

@@ -30,7 +30,7 @@ namespace OpenRA.Mods.RA.Scripting
[Desc("Infiltrate the target actor.")] [Desc("Infiltrate the target actor.")]
public void Infiltrate(Actor target) public void Infiltrate(Actor target)
{ {
Self.QueueActivity(new Infiltrate(Self, target, info.EnterBehaviour, info.ValidStances, info.Notification)); Self.QueueActivity(new Infiltrate(Self, target, info.EnterBehaviour, info.ValidStances, info.Notification, info.PlayerExperience));
} }
} }
} }

View File

@@ -37,6 +37,9 @@ namespace OpenRA.Mods.RA.Traits
[Desc("Notification to play when a building is infiltrated.")] [Desc("Notification to play when a building is infiltrated.")]
public readonly string Notification = "BuildingInfiltrated"; public readonly string Notification = "BuildingInfiltrated";
[Desc("Experience to grant to the infiltrating player.")]
public readonly int PlayerExperience = 0;
public object Create(ActorInitializer init) { return new Infiltrates(this); } public object Create(ActorInitializer init) { return new Infiltrates(this); }
} }
@@ -112,7 +115,7 @@ namespace OpenRA.Mods.RA.Traits
self.CancelActivity(); self.CancelActivity();
self.SetTargetLine(target, Color.Red); self.SetTargetLine(target, Color.Red);
self.QueueActivity(new Infiltrate(self, target.Actor, info.EnterBehaviour, info.ValidStances, info.Notification)); self.QueueActivity(new Infiltrate(self, target.Actor, info.EnterBehaviour, info.ValidStances, info.Notification, info.PlayerExperience));
} }
} }