some of Thief Steal
This commit is contained in:
@@ -162,6 +162,7 @@
|
|||||||
<Compile Include="Traits\Activities\Repair.cs" />
|
<Compile Include="Traits\Activities\Repair.cs" />
|
||||||
<Compile Include="Traits\Activities\ReturnToBase.cs" />
|
<Compile Include="Traits\Activities\ReturnToBase.cs" />
|
||||||
<Compile Include="Traits\Activities\Sell.cs" />
|
<Compile Include="Traits\Activities\Sell.cs" />
|
||||||
|
<Compile Include="Traits\Activities\StealOre.cs" />
|
||||||
<Compile Include="Traits\Activities\Teleport.cs" />
|
<Compile Include="Traits\Activities\Teleport.cs" />
|
||||||
<Compile Include="BuildingInfluenceMap.cs" />
|
<Compile Include="BuildingInfluenceMap.cs" />
|
||||||
<Compile Include="Orders\IOrderGenerator.cs" />
|
<Compile Include="Orders\IOrderGenerator.cs" />
|
||||||
@@ -255,6 +256,7 @@
|
|||||||
<Compile Include="Traits\StoresOre.cs" />
|
<Compile Include="Traits\StoresOre.cs" />
|
||||||
<Compile Include="Traits\Submarine.cs" />
|
<Compile Include="Traits\Submarine.cs" />
|
||||||
<Compile Include="Traits\TakeCover.cs" />
|
<Compile Include="Traits\TakeCover.cs" />
|
||||||
|
<Compile Include="Traits\ThiefSteal.cs" />
|
||||||
<Compile Include="Traits\TraitsInterfaces.cs" />
|
<Compile Include="Traits\TraitsInterfaces.cs" />
|
||||||
<Compile Include="Traits\Tree.cs" />
|
<Compile Include="Traits\Tree.cs" />
|
||||||
<Compile Include="Traits\Turreted.cs" />
|
<Compile Include="Traits\Turreted.cs" />
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ namespace OpenRa.Game.Orders
|
|||||||
case "Infiltrate": return Cursor.Enter;
|
case "Infiltrate": return Cursor.Enter;
|
||||||
case "Capture": return Cursor.Capture;
|
case "Capture": return Cursor.Capture;
|
||||||
case "Harvest": return Cursor.AttackMove;
|
case "Harvest": return Cursor.AttackMove;
|
||||||
|
case "Steal" : return Cursor.Enter;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
35
OpenRa.Game/Traits/Activities/StealOre.cs
Normal file
35
OpenRa.Game/Traits/Activities/StealOre.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenRa.Game.Traits.Activities
|
||||||
|
{
|
||||||
|
class StealOre : IActivity
|
||||||
|
{
|
||||||
|
Actor target;
|
||||||
|
public const int CashStolen = 100; //todo: push this out to Rules
|
||||||
|
|
||||||
|
public StealOre(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));
|
||||||
|
|
||||||
|
return NextActivity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Cancel(Actor self) { target = null; NextActivity = null; }
|
||||||
|
}
|
||||||
|
}
|
||||||
30
OpenRa.Game/Traits/ThiefSteal.cs
Normal file
30
OpenRa.Game/Traits/ThiefSteal.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using OpenRa.Game.Traits.Activities;
|
||||||
|
|
||||||
|
namespace OpenRa.Game.Traits
|
||||||
|
{
|
||||||
|
class ThiefSteal : IOrder
|
||||||
|
{
|
||||||
|
public ThiefSteal(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
|
||||||
|
|
||||||
|
return new Order("Steal", self, underCursor, int2.Zero, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ResolveOrder(Actor self, Order order)
|
||||||
|
{
|
||||||
|
if (order.OrderString == "Steal")
|
||||||
|
{
|
||||||
|
self.CancelActivity();
|
||||||
|
self.QueueActivity(new Move(order.TargetActor, 1));
|
||||||
|
self.QueueActivity(new StealOre(order.TargetActor));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user