Merge commit 'pchote/master'; commit 'alzeih/master'

This commit is contained in:
Chris Forbes
2010-01-08 21:55:43 +13:00
10 changed files with 196 additions and 14 deletions

View File

@@ -0,0 +1,33 @@
using System.Collections.Generic;
using OpenRa.Game.Graphics;
using OpenRa.Game.Traits;
namespace OpenRa.Game.Effects
{
class GpsSatellite : IEffect
{
readonly float heightPerTick = 10;
float2 offset;
Animation anim = new Animation("sputnik");
public GpsSatellite(float2 offset)
{
this.offset = offset;
anim.PlayRepeating("idle");
}
public void Tick()
{
anim.Tick();
offset.Y -= heightPerTick;
if (offset.Y < 0)
Game.world.AddFrameEndTask(w => w.Remove(this));
}
public IEnumerable<Renderable> Render()
{
yield return new Renderable(anim.Image,offset, PaletteType.Gold);
}
}
}

View File

@@ -0,0 +1,37 @@
using System.Collections.Generic;
using OpenRa.Game.Graphics;
using OpenRa.Game.Traits;
namespace OpenRa.Game.Effects
{
class SatelliteLaunch : IEffect
{
int frame = 0;
Actor a;
Animation doors = new Animation("atek");
float2 doorOffset = new float2(-4,0);
public SatelliteLaunch(Actor a)
{
this.a = a;
doors.PlayThen("active",
() => Game.world.AddFrameEndTask(w => w.Remove(this)));
}
public void Tick()
{
doors.Tick();
if (++frame == 19)
{
Game.world.AddFrameEndTask(w => w.Add(new GpsSatellite(a.CenterLocation - .5f * doors.Image.size + doorOffset)));
}
}
public IEnumerable<Renderable> Render()
{
yield return new Renderable(doors.Image,
a.CenterLocation - .5f * doors.Image.size + doorOffset, PaletteType.Gold);
}
}
}

View File

@@ -83,10 +83,12 @@
<Compile Include="Effects\Corpse.cs" />
<Compile Include="Effects\DelayedAction.cs" />
<Compile Include="Effects\FlashTarget.cs" />
<Compile Include="Effects\GpsSatellite.cs" />
<Compile Include="Effects\InvulnEffect.cs" />
<Compile Include="Effects\MoveFlash.cs" />
<Compile Include="Effects\PowerDownIndicator.cs" />
<Compile Include="Effects\RepairIndicator.cs" />
<Compile Include="Effects\SatelliteLaunch.cs" />
<Compile Include="Effects\Smoke.cs" />
<Compile Include="Effects\TeslaZap.cs" />
<Compile Include="Exts.cs" />
@@ -165,6 +167,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\Teleport.cs" />
<Compile Include="BuildingInfluenceMap.cs" />
<Compile Include="Orders\IOrderGenerator.cs" />
@@ -219,6 +222,7 @@
<Compile Include="Traits\Explodes.cs" />
<Compile Include="Traits\ChronoshiftDeploy.cs" />
<Compile Include="Traits\Fake.cs" />
<Compile Include="Traits\GpsSatellite.cs" />
<Compile Include="Traits\Harvester.cs" />
<Compile Include="Traits\Helicopter.cs" />
<Compile Include="Traits\InvisibleToOthers.cs" />
@@ -258,6 +262,7 @@
<Compile Include="Traits\StoresOre.cs" />
<Compile Include="Traits\Submarine.cs" />
<Compile Include="Traits\TakeCover.cs" />
<Compile Include="Traits\ThiefSteal.cs" />
<Compile Include="Traits\TraitsInterfaces.cs" />
<Compile Include="Traits\Tree.cs" />
<Compile Include="Traits\Turreted.cs" />

View File

@@ -86,6 +86,7 @@ namespace OpenRa.Game.Orders
case "Infiltrate": return Cursor.Enter;
case "Capture": return Cursor.Capture;
case "Harvest": return Cursor.AttackMove;
case "Steal" : return Cursor.Enter;
default:
return null;
}

View File

@@ -13,10 +13,21 @@ namespace OpenRa.Game
Sprite[] shadowBits = SpriteSheetBuilder.LoadAllSprites("shadow");
Sprite[,] sprites = new Sprite[128, 128];
bool dirty;
public bool IsExplored(int2 xy)
bool hasGPS = false;
public bool HasGPS
{
return explored[ xy.X, xy.Y ];
get { return hasGPS; }
set { hasGPS = value; dirty = true;}
}
public bool IsExplored(int2 xy) { return IsExplored(xy.X, xy.Y); }
public bool IsExplored(int x, int y)
{
if (hasGPS)
return true;
return explored[ x, y ];
}
public void Explore(Actor a)
@@ -51,11 +62,11 @@ namespace OpenRa.Game
{
// bits are for exploredness: left, right, up, down, self
var v = 0;
if (explored[i - 1, j]) v |= 1;
if (explored[i + 1, j]) v |= 2;
if (explored[i, j - 1]) v |= 4;
if (explored[i, j + 1]) v |= 8;
if (explored[i, j]) v |= 16;
if (IsExplored(i - 1, j)) v |= 1;
if (IsExplored(i + 1, j)) v |= 2;
if (IsExplored(i, j - 1)) v |= 4;
if (IsExplored(i, j + 1)) v |= 8;
if (IsExplored(i, j)) v |= 16;
var x = ShroudTiles[v];
if (x != 0)
@@ -63,10 +74,10 @@ namespace OpenRa.Game
// bits are for exploredness: TL, TR, BR, BL
var u = 0;
if (explored[i - 1, j - 1]) u |= 1;
if (explored[i + 1, j - 1]) u |= 2;
if (explored[i + 1, j + 1]) u |= 4;
if (explored[i - 1, j + 1]) u |= 8;
if (IsExplored(i - 1, j - 1)) u |= 1;
if (IsExplored(i + 1, j - 1)) u |= 2;
if (IsExplored(i + 1, j + 1)) u |= 4;
if (IsExplored(i - 1, j + 1)) u |= 8;
return shadowBits[ExtraShroudTiles[u]];
}

View 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; }
}
}

View File

@@ -0,0 +1,29 @@
using OpenRa.Game.Effects;
namespace OpenRa.Game.Traits
{
class GpsSatellite : ITick
{
int frame = 0;
int revealTicks = 30 * 25; // 30 second delay between launch and reveal
bool fired = false;
public GpsSatellite(Actor self) {}
public void Tick(Actor self)
{
// HACK: Launch after 5 seconds
if (++frame == 150)
Activate(self);
if (fired && --revealTicks == 0)
{
self.Owner.Shroud.HasGPS = true;
}
}
public void Activate(Actor self)
{
Game.world.AddFrameEndTask(w => w.Add(new SatelliteLaunch(self)));
fired = true;
}
}
}

View 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));
}
}
}
}

View File

@@ -94,6 +94,7 @@
<sequence name="idle" start="0" />
<sequence name="damaged-idle" start="1" />
<sequence name="make" start="0" length="*" src="atekmake" />
<sequence name="active" start="0" length="*" src="sputdoor" />
</unit>
<!-- soviet tech center -->
<unit name="stek">
@@ -1030,7 +1031,7 @@
<sequence name="left-normal" start="0" length="1" />
<sequence name="left-pressed" start="1" length="1" />
</unit>
<unit name="dd-crnr">
<unit name="sputnik"> <sequence name="idle" start="0" length="4" /> </unit> <unit name="dd-crnr"> <sequence name="idle" start="0" length="4" />
<sequence name="top-left" start="0" length="1" />
<sequence name="top-right" start="1" length="1" />
<sequence name="bottom-left" start="2" length="1" />

View File

@@ -348,7 +348,7 @@ MINV
; `Produces` is a category of objects that this building can produce.
[ATEK]
Description=Allied Tech Center
Traits=Building, RenderBuilding, IronCurtainable
Traits=Building, RenderBuilding, IronCurtainable, GpsSatellite
Dimensions=2,2
Footprint=xx xx
SelectionPriority=3