Begin generalizing crates; only give firepower bonus to units with weapons
This commit is contained in:
@@ -62,7 +62,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public void OnCrush(Actor crusher)
|
public void OnCrush(Actor crusher)
|
||||||
{
|
{
|
||||||
var shares = self.traits.WithInterface<ICrateAction>().Select(a => Pair.New(a, a.SelectionShares));
|
var shares = self.traits.WithInterface<ICrateAction>().Select(a => Pair.New(a, a.GetSelectionShares(crusher)));
|
||||||
var totalShares = shares.Sum(a => a.Second);
|
var totalShares = shares.Sum(a => a.Second);
|
||||||
var n = self.World.SharedRandom.Next(totalShares);
|
var n = self.World.SharedRandom.Next(totalShares);
|
||||||
|
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public interface ICrateAction
|
public interface ICrateAction
|
||||||
{
|
{
|
||||||
int SelectionShares { get; }
|
int GetSelectionShares(Actor collector);
|
||||||
void Activate(Actor collector);
|
void Activate(Actor collector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||||
* This file is part of OpenRA.
|
* This file is part of OpenRA.
|
||||||
@@ -27,6 +27,8 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
public float Multiplier = 2.0f;
|
public float Multiplier = 2.0f;
|
||||||
public int SelectionShares = 10;
|
public int SelectionShares = 10;
|
||||||
|
public string Effect = null;
|
||||||
|
public string Notification = null;
|
||||||
public object Create(Actor self) { return new ArmorUpgradeCrateAction(self); }
|
public object Create(Actor self) { return new ArmorUpgradeCrateAction(self); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,19 +40,20 @@ namespace OpenRA.Mods.RA
|
|||||||
this.self = self;
|
this.self = self;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int SelectionShares
|
public int GetSelectionShares(Actor collector)
|
||||||
{
|
{
|
||||||
get { return self.Info.Traits.Get<ArmorUpgradeCrateActionInfo>().SelectionShares; }
|
return self.Info.Traits.Get<ArmorUpgradeCrateActionInfo>().SelectionShares;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Activate(Actor collector)
|
public void Activate(Actor collector)
|
||||||
{
|
{
|
||||||
Sound.PlayToPlayer(collector.Owner, "armorup1.aud");
|
Sound.PlayToPlayer(collector.Owner, self.Info.Traits.Get<ArmorUpgradeCrateActionInfo>().Notification);
|
||||||
|
|
||||||
collector.World.AddFrameEndTask(w =>
|
collector.World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
var multiplier = self.Info.Traits.Get<ArmorUpgradeCrateActionInfo>().Multiplier;
|
var multiplier = self.Info.Traits.Get<ArmorUpgradeCrateActionInfo>().Multiplier;
|
||||||
collector.traits.Add(new ArmorUpgrade(multiplier));
|
collector.traits.Add(new ArmorUpgrade(multiplier));
|
||||||
w.Add(new CrateEffect(collector, "armor"));
|
w.Add(new CrateEffect(collector, self.Info.Traits.Get<ArmorUpgradeCrateActionInfo>().Effect));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -11,7 +11,8 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
public string Weapon = null;
|
public string Weapon = null;
|
||||||
public int SelectionShares = 5;
|
public int SelectionShares = 5;
|
||||||
|
public string Effect = null;
|
||||||
|
public string Notification = null;
|
||||||
public object Create(Actor self) { return new ExplodeCrateAction(self, this); }
|
public object Create(Actor self) { return new ExplodeCrateAction(self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,13 +27,15 @@ namespace OpenRA.Mods.RA
|
|||||||
this.info = info;
|
this.info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int SelectionShares
|
public int GetSelectionShares(Actor collector)
|
||||||
{
|
{
|
||||||
get { return info.SelectionShares; }
|
return info.SelectionShares;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Activate(Actor collector)
|
public void Activate(Actor collector)
|
||||||
{
|
{
|
||||||
|
Sound.PlayToPlayer(collector.Owner, self.Info.Traits.Get<ExplodeCrateActionInfo>().Notification);
|
||||||
|
|
||||||
self.World.AddFrameEndTask(
|
self.World.AddFrameEndTask(
|
||||||
w => w.Add(new Bullet(info.Weapon, self.Owner,
|
w => w.Add(new Bullet(info.Weapon, self.Owner,
|
||||||
self, self.CenterLocation.ToInt2(), self.CenterLocation.ToInt2(),
|
self, self.CenterLocation.ToInt2(), self.CenterLocation.ToInt2(),
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||||
* This file is part of OpenRA.
|
* This file is part of OpenRA.
|
||||||
@@ -27,6 +27,8 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
public float Multiplier = 2.0f;
|
public float Multiplier = 2.0f;
|
||||||
public int SelectionShares = 10;
|
public int SelectionShares = 10;
|
||||||
|
public string Effect = null;
|
||||||
|
public string Notification = null;
|
||||||
public object Create(Actor self) { return new FirepowerUpgradeCrateAction(self); }
|
public object Create(Actor self) { return new FirepowerUpgradeCrateAction(self); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,19 +40,22 @@ namespace OpenRA.Mods.RA
|
|||||||
this.self = self;
|
this.self = self;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int SelectionShares
|
public int GetSelectionShares(Actor collector)
|
||||||
{
|
{
|
||||||
get { return self.Info.Traits.Get<FirepowerUpgradeCrateActionInfo>().SelectionShares; }
|
if (collector.GetPrimaryWeapon() == null && collector.GetSecondaryWeapon() == null)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return self.Info.Traits.Get<FirepowerUpgradeCrateActionInfo>().SelectionShares;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Activate(Actor collector)
|
public void Activate(Actor collector)
|
||||||
{
|
{
|
||||||
Sound.PlayToPlayer(collector.Owner, "firepo1.aud");
|
Sound.PlayToPlayer(collector.Owner, self.Info.Traits.Get<FirepowerUpgradeCrateActionInfo>().Notification);
|
||||||
collector.World.AddFrameEndTask(w =>
|
collector.World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
var multiplier = self.Info.Traits.Get<FirepowerUpgradeCrateActionInfo>().Multiplier;
|
var multiplier = self.Info.Traits.Get<FirepowerUpgradeCrateActionInfo>().Multiplier;
|
||||||
collector.traits.Add(new FirepowerUpgrade(multiplier));
|
collector.traits.Add(new FirepowerUpgrade(multiplier));
|
||||||
w.Add(new CrateEffect(collector, "fpower"));
|
w.Add(new CrateEffect(collector, self.Info.Traits.Get<FirepowerUpgradeCrateActionInfo>().Effect));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||||
* This file is part of OpenRA.
|
* This file is part of OpenRA.
|
||||||
@@ -27,6 +27,8 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
public int Amount = 2000;
|
public int Amount = 2000;
|
||||||
public int SelectionShares = 10;
|
public int SelectionShares = 10;
|
||||||
|
public string Effect = null;
|
||||||
|
public string Notification = null;
|
||||||
public object Create(Actor self) { return new GiveCashCrateAction(self); }
|
public object Create(Actor self) { return new GiveCashCrateAction(self); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,18 +40,20 @@ namespace OpenRA.Mods.RA
|
|||||||
this.self = self;
|
this.self = self;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int SelectionShares
|
public int GetSelectionShares(Actor collector)
|
||||||
{
|
{
|
||||||
get { return self.Info.Traits.Get<GiveCashCrateActionInfo>().SelectionShares; }
|
return self.Info.Traits.Get<GiveCashCrateActionInfo>().SelectionShares;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Activate(Actor collector)
|
public void Activate(Actor collector)
|
||||||
{
|
{
|
||||||
|
Sound.PlayToPlayer(collector.Owner, self.Info.Traits.Get<GiveCashCrateActionInfo>().Notification);
|
||||||
|
|
||||||
collector.World.AddFrameEndTask(w =>
|
collector.World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
var amount = self.Info.Traits.Get<GiveCashCrateActionInfo>().Amount;
|
var amount = self.Info.Traits.Get<GiveCashCrateActionInfo>().Amount;
|
||||||
collector.Owner.GiveCash(amount);
|
collector.Owner.GiveCash(amount);
|
||||||
w.Add(new CrateEffect(collector, "dollar"));
|
w.Add(new CrateEffect(collector, self.Info.Traits.Get<GiveCashCrateActionInfo>().Effect));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||||
* This file is part of OpenRA.
|
* This file is part of OpenRA.
|
||||||
@@ -27,6 +27,8 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
public float Multiplier = 1.7f;
|
public float Multiplier = 1.7f;
|
||||||
public int SelectionShares = 10;
|
public int SelectionShares = 10;
|
||||||
|
public string Effect = null;
|
||||||
|
public string Notification = null;
|
||||||
public object Create(Actor self) { return new SpeedUpgradeCrateAction(self); }
|
public object Create(Actor self) { return new SpeedUpgradeCrateAction(self); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,19 +40,20 @@ namespace OpenRA.Mods.RA
|
|||||||
this.self = self;
|
this.self = self;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int SelectionShares
|
public int GetSelectionShares(Actor collector)
|
||||||
{
|
{
|
||||||
get { return self.Info.Traits.Get<SpeedUpgradeCrateActionInfo>().SelectionShares; }
|
return self.Info.Traits.Get<SpeedUpgradeCrateActionInfo>().SelectionShares;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Activate(Actor collector)
|
public void Activate(Actor collector)
|
||||||
{
|
{
|
||||||
Sound.PlayToPlayer(collector.Owner, "unitspd1.aud");
|
Sound.PlayToPlayer(collector.Owner, self.Info.Traits.Get<SpeedUpgradeCrateActionInfo>().Notification);
|
||||||
|
|
||||||
collector.World.AddFrameEndTask(w =>
|
collector.World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
var multiplier = self.Info.Traits.Get<SpeedUpgradeCrateActionInfo>().Multiplier;
|
var multiplier = self.Info.Traits.Get<SpeedUpgradeCrateActionInfo>().Multiplier;
|
||||||
collector.traits.Add(new SpeedUpgrade(multiplier));
|
collector.traits.Add(new SpeedUpgrade(multiplier));
|
||||||
w.Add(new CrateEffect(collector, "speed"));
|
w.Add(new CrateEffect(collector, self.Info.Traits.Get<SpeedUpgradeCrateActionInfo>().Effect));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -637,15 +637,22 @@ CRATE:
|
|||||||
SpeedUpgradeCrateAction:
|
SpeedUpgradeCrateAction:
|
||||||
Multiplier: 1.7
|
Multiplier: 1.7
|
||||||
SelectionShares: 10
|
SelectionShares: 10
|
||||||
|
Notification: unitspd1.aud
|
||||||
|
Effect: speed
|
||||||
GiveCashCrateAction:
|
GiveCashCrateAction:
|
||||||
Amount: 2000
|
Amount: 2000
|
||||||
SelectionShares: 50
|
SelectionShares: 50
|
||||||
|
Effect: dollar
|
||||||
FirepowerUpgradeCrateAction:
|
FirepowerUpgradeCrateAction:
|
||||||
Multiplier: 2.0
|
Multiplier: 2.0
|
||||||
SelectionShares: 10
|
SelectionShares: 10
|
||||||
|
Notification: firepo1.aud
|
||||||
|
Effect: fpower
|
||||||
ArmorUpgradeCrateAction:
|
ArmorUpgradeCrateAction:
|
||||||
Multiplier: 2.0
|
Multiplier: 2.0
|
||||||
SelectionShares: 10
|
SelectionShares: 10
|
||||||
|
Notification: armorup1.aud
|
||||||
|
Effect: armor
|
||||||
ExplodeCrateAction@fire:
|
ExplodeCrateAction@fire:
|
||||||
Weapon: Napalm
|
Weapon: Napalm
|
||||||
SelectionShares: 80
|
SelectionShares: 80
|
||||||
|
|||||||
Reference in New Issue
Block a user