Finish theif logic. TODO: Determine amount to steal
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System;
|
||||
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 +13,20 @@ namespace OpenRa.Game.Traits
|
||||
this.self = self;
|
||||
}
|
||||
|
||||
public void OnSteal(Actor self, Actor thief)
|
||||
{
|
||||
var cashStolen = Math.Min(MaxStealAmount, self.Owner.Cash);
|
||||
self.Owner.TakeCash(cashStolen);
|
||||
thief.Owner.GiveCash(cashStolen);
|
||||
|
||||
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++)
|
||||
|
||||
Reference in New Issue
Block a user