Implement basic reinforcements for allies2

This commit is contained in:
Scott_NZ
2012-08-10 23:21:18 +12:00
parent 5f2ffc0508
commit 81e2c1d2d7
3 changed files with 44 additions and 10 deletions

View File

@@ -11,6 +11,7 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Traits; using OpenRA.Traits;
using OpenRA.Widgets; using OpenRA.Widgets;
@@ -37,12 +38,18 @@ namespace OpenRA.Mods.RA.Missions
Actor chinookHusk; Actor chinookHusk;
Actor allies2BasePoint; Actor allies2BasePoint;
Actor reinforcementsEntryPoint;
World world;
Player allies1; Player allies1;
Player allies2; Player allies2;
Player soviets; Player soviets;
CountdownTimerWidget reinfTimer; CountdownTimerWidget reinfTimer;
const int CountdownTicks = 18000;
static readonly string[] reinforcements = { "1tnk", "1tnk", "jeep", "mcv" };
void DisplayObjective() void DisplayObjective()
{ {
@@ -101,8 +108,31 @@ namespace OpenRA.Mods.RA.Missions
} }
} }
void StartReinforcementsTimer()
{
reinfTimer.IsVisible = () => true;
Sound.Play("timergo1.aud");
}
void TimerExpired()
{
reinfTimer.IsVisible = () => false;
SendReinforcements();
}
void SendReinforcements()
{
Sound.Play("reinfor1.aud");
foreach (var unit in reinforcements)
{
var actor = world.CreateActor(unit, new TypeDictionary { new LocationInit(reinforcementsEntryPoint.Location), new FacingInit(0), new OwnerInit(allies2) });
actor.QueueActivity(new Move.Move(allies2BasePoint.Location));
}
}
public void WorldLoaded(World w) public void WorldLoaded(World w)
{ {
world = w;
allies1 = w.Players.Single(p => p.InternalName == "Allies1"); allies1 = w.Players.Single(p => p.InternalName == "Allies1");
allies2 = w.Players.Single(p => p.InternalName == "Allies2"); allies2 = w.Players.Single(p => p.InternalName == "Allies2");
soviets = w.Players.Single(p => p.InternalName == "Soviets"); soviets = w.Players.Single(p => p.InternalName == "Soviets");
@@ -115,25 +145,20 @@ namespace OpenRA.Mods.RA.Missions
tanya = actors["Tanya"]; tanya = actors["Tanya"];
einstein = actors["Einstein"]; einstein = actors["Einstein"];
allies2BasePoint = actors["Allies2BasePoint"]; allies2BasePoint = actors["Allies2BasePoint"];
reinforcementsEntryPoint = actors["ReinforcementsEntryPoint"];
w.WorldActor.Trait<Shroud>().Explore(w, sam1.Location, 2); w.WorldActor.Trait<Shroud>().Explore(w, sam1.Location, 2);
w.WorldActor.Trait<Shroud>().Explore(w, sam2.Location, 2); w.WorldActor.Trait<Shroud>().Explore(w, sam2.Location, 2);
w.WorldActor.Trait<Shroud>().Explore(w, sam3.Location, 2); w.WorldActor.Trait<Shroud>().Explore(w, sam3.Location, 2);
w.WorldActor.Trait<Shroud>().Explore(w, sam4.Location, 2); w.WorldActor.Trait<Shroud>().Explore(w, sam4.Location, 2);
Game.MoveViewport(((w.LocalPlayer ?? allies1) == allies1 ? chinookHusk.Location : allies2BasePoint.Location).ToFloat2()); reinfTimer = new CountdownTimerWidget("Reinforcements arrive in", CountdownTicks)
StartReinforcementsTimer();
}
void StartReinforcementsTimer()
{
reinfTimer = new CountdownTimerWidget("Reinforcements arrive in", 3200)
{ {
IsVisible = () => false,
OnExpired = TimerExpired OnExpired = TimerExpired
}; };
Ui.Root.AddChild(reinfTimer); Ui.Root.AddChild(reinfTimer);
Sound.Play("timergo1.aud"); Game.MoveViewport(((w.LocalPlayer ?? allies1) == allies1 ? chinookHusk.Location : allies2BasePoint.Location).ToFloat2());
StartReinforcementsTimer();
} }
void TimerExpired() {}
} }
class CountdownTimerWidget : Widget class CountdownTimerWidget : Widget

Binary file not shown.

View File

@@ -1604,6 +1604,15 @@ Actors:
Actor475: pbox Actor475: pbox
Location: 33,88 Location: 33,88
Owner: Allies2 Owner: Allies2
ReinforcementsEntryPoint: waypoint
Location: 24,111
Owner: Neutral
Actor477: oilb
Location: 37,96
Owner: Allies2
Actor478: brl3
Location: 38,95
Owner: Allies2
Smudges: Smudges: