Merge commit 'pchote/master'
This commit is contained in:
@@ -9,7 +9,10 @@ namespace OpenRa.Game.Effects
|
||||
Actor a;
|
||||
Building b;
|
||||
Animation anim = new Animation("powerdown");
|
||||
|
||||
bool removeNextFrame = false;
|
||||
bool indicatorState = true;
|
||||
int stateTicks = 0;
|
||||
|
||||
public PowerDownIndicator(Actor a)
|
||||
{
|
||||
this.a = a;
|
||||
@@ -19,8 +22,19 @@ namespace OpenRa.Game.Effects
|
||||
|
||||
public void Tick()
|
||||
{
|
||||
if (!b.Disabled || a.IsDead)
|
||||
if (removeNextFrame == true)
|
||||
Game.world.AddFrameEndTask(w => w.Remove(this));
|
||||
|
||||
// Fix off-by one frame bug with undisabling causing low-power
|
||||
if (!b.Disabled || a.IsDead)
|
||||
removeNextFrame = true;
|
||||
|
||||
// Flash power icon
|
||||
if (++stateTicks == 15)
|
||||
{
|
||||
stateTicks = 0;
|
||||
indicatorState = !indicatorState;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
@@ -28,7 +42,7 @@ namespace OpenRa.Game.Effects
|
||||
foreach (var r in a.Render())
|
||||
yield return r.WithPalette(PaletteType.Disabled);
|
||||
|
||||
if (b.ManuallyDisabled)
|
||||
if (b.ManuallyDisabled && indicatorState)
|
||||
yield return new Renderable(anim.Image,
|
||||
a.CenterLocation - .5f * anim.Image.size, PaletteType.Chrome);
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@
|
||||
<Compile Include="Traits\Activities\Repair.cs" />
|
||||
<Compile Include="Traits\Activities\ReturnToBase.cs" />
|
||||
<Compile Include="Traits\Activities\Sell.cs" />
|
||||
<Compile Include="Traits\Activities\StealOre.cs" />
|
||||
<Compile Include="Traits\Activities\Steal.cs" />
|
||||
<Compile Include="Traits\Activities\Teleport.cs" />
|
||||
<Compile Include="BuildingInfluenceMap.cs" />
|
||||
<Compile Include="Orders\IOrderGenerator.cs" />
|
||||
@@ -263,7 +263,7 @@
|
||||
<Compile Include="Traits\StoresOre.cs" />
|
||||
<Compile Include="Traits\Submarine.cs" />
|
||||
<Compile Include="Traits\TakeCover.cs" />
|
||||
<Compile Include="Traits\ThiefSteal.cs" />
|
||||
<Compile Include="Traits\Thief.cs" />
|
||||
<Compile Include="Traits\TraitsInterfaces.cs" />
|
||||
<Compile Include="Traits\Tree.cs" />
|
||||
<Compile Include="Traits\Turreted.cs" />
|
||||
|
||||
@@ -5,27 +5,21 @@ using System.Text;
|
||||
|
||||
namespace OpenRa.Game.Traits.Activities
|
||||
{
|
||||
class StealOre : IActivity
|
||||
class Steal : IActivity
|
||||
{
|
||||
Actor target;
|
||||
public const int CashStolen = 100; //todo: push this out to Rules
|
||||
|
||||
public StealOre(Actor target) { this.target = target; }
|
||||
|
||||
public Steal(Actor target) { this.target = target; }
|
||||
|
||||
public IActivity NextActivity { get; set; }
|
||||
|
||||
public IActivity Tick(Actor self)
|
||||
{
|
||||
if (target == null || target.IsDead) return NextActivity;
|
||||
|
||||
if (target.Owner == self.Owner) return NextActivity;
|
||||
|
||||
target.Owner.TakeCash(CashStolen);
|
||||
self.Owner.GiveCash(CashStolen);
|
||||
|
||||
// the thief is sacrificed.
|
||||
self.Health = 0;
|
||||
Game.world.AddFrameEndTask(w => w.Remove(self));
|
||||
|
||||
foreach (var t in target.traits.WithInterface<IAcceptThief>())
|
||||
t.OnSteal(target, self);
|
||||
|
||||
return NextActivity;
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System;
|
||||
using OpenRa.Game.GameRules;
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class StoresOre : IPips
|
||||
class StoresOre : IPips, IAcceptThief
|
||||
{
|
||||
public const int MaxStealAmount = 100; //todo: How is cash stolen determined?
|
||||
|
||||
readonly Actor self;
|
||||
|
||||
public StoresOre(Actor self)
|
||||
@@ -11,6 +14,21 @@ namespace OpenRa.Game.Traits
|
||||
this.self = self;
|
||||
}
|
||||
|
||||
public void OnSteal(Actor self, Actor thief)
|
||||
{
|
||||
// Steal half the ore the building holds
|
||||
var toSteal = (self.Info as BuildingInfo).Storage/2;
|
||||
self.Owner.TakeCash(toSteal);
|
||||
thief.Owner.GiveCash(toSteal);
|
||||
|
||||
if (Game.LocalPlayer == thief.Owner)
|
||||
Sound.Play("credit1.aud");
|
||||
|
||||
// the thief is sacrificed.
|
||||
thief.Health = 0;
|
||||
Game.world.AddFrameEndTask(w => w.Remove(thief));
|
||||
}
|
||||
|
||||
public IEnumerable<PipType> GetPips(Actor self)
|
||||
{
|
||||
for (int i = 0; i < self.Info.OrePips; i++)
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
using OpenRa.Game.Traits.Activities;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class ThiefSteal : IOrder
|
||||
class Thief : IOrder
|
||||
{
|
||||
public ThiefSteal(Actor self) { }
|
||||
public Thief(Actor self) { }
|
||||
|
||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||
{
|
||||
if (mi.Button != MouseButton.Right) return null;
|
||||
if (underCursor == null) return null;
|
||||
if (!underCursor.traits.Contains<Building>()) return null;
|
||||
|
||||
// todo: other bits
|
||||
|
||||
if (!underCursor.traits.WithInterface<IAcceptThief>().Any()) return null;
|
||||
|
||||
return new Order("Steal", self, underCursor, int2.Zero, null);
|
||||
}
|
||||
|
||||
@@ -23,7 +22,7 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new Move(order.TargetActor, 1));
|
||||
self.QueueActivity(new StealOre(order.TargetActor));
|
||||
self.QueueActivity(new Steal(order.TargetActor));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ namespace OpenRa.Game.Traits
|
||||
interface INotifyDamage { void Damaged(Actor self, AttackInfo e); }
|
||||
interface INotifyBuildComplete { void BuildingComplete (Actor self); }
|
||||
interface INotifyProduction { void UnitProduced(Actor self, Actor other); }
|
||||
interface IAcceptThief { void OnSteal(Actor self, Actor thief); }
|
||||
interface IOrder
|
||||
{
|
||||
Order IssueOrder( Actor self, int2 xy, MouseInput mi, Actor underCursor );
|
||||
|
||||
@@ -594,7 +594,7 @@ SelectionSize=12,17,0,-9
|
||||
[THF]
|
||||
Description=Thief
|
||||
Voice=ThiefVoice
|
||||
Traits=Unit, Mobile, RenderInfantry, TakeCover, SquishByTank, Passenger
|
||||
Traits=Unit, Mobile, RenderInfantry, TakeCover, SquishByTank, Passenger, Thief
|
||||
LongDesc=Infiltrates enemy refineries & \nsilos, and steals money stored there.\n Unarmed
|
||||
SelectionSize=12,17,0,-9
|
||||
[E7]
|
||||
|
||||
Reference in New Issue
Block a user