merged. may not actually work yet.

This commit is contained in:
Chris Forbes
2010-01-09 11:34:44 +13:00
10 changed files with 66 additions and 65 deletions

View File

@@ -122,7 +122,7 @@
<Compile Include="Smudge.cs" /> <Compile Include="Smudge.cs" />
<Compile Include="Sound.cs" /> <Compile Include="Sound.cs" />
<Compile Include="SupportPower.cs" /> <Compile Include="SupportPower.cs" />
<Compile Include="SupportPowers\Chronoshift.cs" /> <Compile Include="SupportPowers\ChronospherePower.cs" />
<Compile Include="SupportPowers\GpsSatellite.cs" /> <Compile Include="SupportPowers\GpsSatellite.cs" />
<Compile Include="SupportPowers\IronCurtainPower.cs" /> <Compile Include="SupportPowers\IronCurtainPower.cs" />
<Compile Include="SupportPowers\ISupportPowerImpl.cs" /> <Compile Include="SupportPowers\ISupportPowerImpl.cs" />

View File

@@ -1,19 +1,21 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using System.Drawing; using System.Drawing;
using OpenRa.Game.Traits; using OpenRa.Game.Traits;
using OpenRa.Game.SupportPowers;
namespace OpenRa.Game.Orders namespace OpenRa.Game.Orders
{ {
class ChronoshiftDestinationOrderGenerator : IOrderGenerator class ChronoshiftDestinationOrderGenerator : IOrderGenerator
{ {
public readonly Actor self; public readonly Actor self;
SupportPower power;
public ChronoshiftDestinationOrderGenerator(Actor self) public ChronoshiftDestinationOrderGenerator(Actor self, SupportPower power)
{ {
this.self = self; this.self = self;
this.power = power;
} }
public IEnumerable<Order> Order(int2 xy, MouseInput mi) public IEnumerable<Order> Order(int2 xy, MouseInput mi)
@@ -23,8 +25,8 @@ namespace OpenRa.Game.Orders
Game.controller.CancelInputMode(); Game.controller.CancelInputMode();
yield break; yield break;
} }
yield return new Order("Chronoshift", self, null, xy,
yield return new Order("Chronoshift", self, null, xy, null); power != null ? power.Name : null);
} }
public void Tick() {} public void Tick() {}

View File

@@ -1,14 +1,20 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using OpenRa.Game.GameRules; using OpenRa.Game.GameRules;
using OpenRa.Game.Traits; using OpenRa.Game.Traits;
using OpenRa.Game.SupportPowers;
namespace OpenRa.Game.Orders namespace OpenRa.Game.Orders
{ {
class ChronosphereSelectOrderGenerator : IOrderGenerator class ChronosphereSelectOrderGenerator : IOrderGenerator
{ {
ISupportPowerImpl chronospherePower;
public ChronosphereSelectOrderGenerator(ISupportPowerImpl chronospherePower)
{
this.chronospherePower = chronospherePower;
}
public IEnumerable<Order> Order(int2 xy, MouseInput mi) public IEnumerable<Order> Order(int2 xy, MouseInput mi)
{ {
if (mi.Button == MouseButton.Right) if (mi.Button == MouseButton.Right)
@@ -30,9 +36,7 @@ namespace OpenRa.Game.Orders
var unit = underCursor != null ? underCursor.Info as UnitInfo : null; var unit = underCursor != null ? underCursor.Info as UnitInfo : null;
if (unit != null) if (unit != null)
{ yield return new Order("ChronosphereSelect", underCursor, null, int2.Zero, "ChronoshiftPower");
yield return new Order("ChronosphereSelect", underCursor, null, int2.Zero, null);
}
} }
} }

View File

@@ -1,10 +1,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using OpenRa.Game.GameRules; using OpenRa.Game.GameRules;
using OpenRa.Game.Traits; using OpenRa.Game.Traits;
using OpenRa.Game.SupportPowers; using OpenRa.Game.SupportPowers;
namespace OpenRa.Game.Orders namespace OpenRa.Game.Orders
{ {
class IronCurtainOrderGenerator : IOrderGenerator class IronCurtainOrderGenerator : IOrderGenerator

View File

@@ -1,19 +0,0 @@
using OpenRa.Game.Orders;
namespace OpenRa.Game.SupportPowers
{
class Chronoshift : ISupportPowerImpl
{
public void Activate(SupportPower p)
{
// todo: someone has to call SupportPower.FinishActivate when we're done!
if (Game.controller.ToggleInputMode<ChronosphereSelectOrderGenerator>())
Sound.Play("slcttgt1.aud");
}
public void OnFireNotification(Actor target, int2 xy) {}
public void IsChargingNotification(SupportPower p) {}
public void IsReadyNotification(SupportPower p) {}
}
}

View File

@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Drawing;
using OpenRa.Game.Orders;
using OpenRa.Game.Traits;
namespace OpenRa.Game.SupportPowers
{
class ChronospherePower : ISupportPowerImpl
{
public void IsReadyNotification(SupportPower p) { Sound.Play("chrordy1.aud"); }
public void IsChargingNotification(SupportPower p) { Sound.Play("chrochr1.aud"); }
public void OnFireNotification(Actor target, int2 xy)
{
p.FinishActivate();
Game.controller.CancelInputMode();
Sound.Play("chrono2.aud");
foreach (var a in Game.world.Actors.Where(a => a.traits.Contains<ChronoshiftPaletteEffect>()))
a.traits.Get<ChronoshiftPaletteEffect>().DoChronoshift();
// Play chronosphere active anim
var chronosphere = Game.world.Actors.Where(a => a.Owner == p.Owner && a.traits.Contains<Chronosphere>()).FirstOrDefault();
if (chronosphere != null)
chronosphere.traits.Get<RenderBuilding>().PlayCustomAnim(chronosphere, "active");
}
SupportPower p;
public void Activate(SupportPower p)
{
this.p = p;
Game.controller.orderGenerator = new ChronosphereSelectOrderGenerator(this);
Sound.Play("slcttgt1.aud");
}
}
}

View File

@@ -1,15 +0,0 @@
using OpenRa.Game.Orders;
namespace OpenRa.Game.SupportPowers
{
class IronCurtain : ISupportPowerImpl
{
public void Activate(SupportPower p)
{
// todo: someone has to call SupportPower.FinishActivate when we're done!
if (Game.controller.ToggleInputMode<IronCurtainOrderGenerator>())
Sound.Play("slcttgt1.aud");
}
}
}

View File

@@ -2,7 +2,6 @@
using OpenRa.Game.Orders; using OpenRa.Game.Orders;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Drawing;
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {
@@ -40,7 +39,8 @@ namespace OpenRa.Game.Traits
{ {
if (order.OrderString == "ChronosphereSelect") if (order.OrderString == "ChronosphereSelect")
{ {
Game.controller.orderGenerator = new ChronoshiftDestinationOrderGenerator(self); var power = self.Owner.SupportPowers[order.TargetString];
Game.controller.orderGenerator = new ChronoshiftDestinationOrderGenerator(self, power);
} }
var movement = self.traits.WithInterface<IMovement>().FirstOrDefault(); var movement = self.traits.WithInterface<IMovement>().FirstOrDefault();
@@ -54,33 +54,23 @@ namespace OpenRa.Game.Traits
chronoshiftOrigin = self.Location; chronoshiftOrigin = self.Location;
chronoshiftReturnTicks = (int)(Rules.General.ChronoDuration * 60 * 25); chronoshiftReturnTicks = (int)(Rules.General.ChronoDuration * 60 * 25);
var chronosphere = Game.world.Actors.Where(a => a.Owner == order.Subject.Owner
&& a.traits.Contains<Chronosphere>()).FirstOrDefault();
// Kill cargo // Kill cargo
if (Rules.General.ChronoKillCargo && self.traits.Contains<Cargo>()) if (Rules.General.ChronoKillCargo && self.traits.Contains<Cargo>())
{ {
var cargo = self.traits.Get<Cargo>(); var cargo = self.traits.Get<Cargo>();
while (!cargo.IsEmpty(self)) while (!cargo.IsEmpty(self))
{ {
if (chronosphere != null) order.Player.Kills++;
chronosphere.Owner.Kills++;
cargo.Unload(self); cargo.Unload(self);
} }
} }
// Set up the teleport // Set up the teleport
Game.controller.CancelInputMode();
self.CancelActivity(); self.CancelActivity();
self.QueueActivity(new Activities.Teleport(order.TargetLocation)); self.QueueActivity(new Activities.Teleport(order.TargetLocation));
Sound.Play("chrono2.aud");
foreach (var a in Game.world.Actors.Where(a => a.traits.Contains<ChronoshiftPaletteEffect>())) var power = self.Owner.SupportPowers[order.TargetString].Impl;
a.traits.Get<ChronoshiftPaletteEffect>().DoChronoshift(); power.OnFireNotification(self, self.Location);
// Play chronosphere active anim
if (chronosphere != null)
chronosphere.traits.Get<RenderBuilding>().PlayCustomAnim(chronosphere, "active");
} }
} }

View File

@@ -861,7 +861,7 @@ LongDesc=Temporarily teleports a vehicle across \nthe map.
Prerequisite=PDOX Prerequisite=PDOX
Image=warpicon Image=warpicon
TechLevel=12 TechLevel=12
Impl=Chronoshift Impl=ChronospherePower
[SpyPlanePower] ; free with first AFLD [SpyPlanePower] ; free with first AFLD
ChargeTime=3 ChargeTime=3