Convert Allies 02 over to enum objectives

This commit is contained in:
Scott_NZ
2012-09-21 01:21:05 +12:00
parent 8dd7bfdb67
commit 1803b412c3
2 changed files with 56 additions and 24 deletions

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA.Missions
class Allies01Script : IWorldLoaded, ITick
{
[Flags]
enum Objectives
enum Allies01Objectives
{
None = 0,
FindEinstein = 1,
@@ -36,17 +36,19 @@ namespace OpenRA.Mods.RA.Missions
IEnumerable<string> GetObjectiveText()
{
var objectives = new List<string>();
if (MissionUtils.HasFlag(currentObjectives, Objectives.FindEinstein))
if (MissionUtils.HasFlag(currentObjectives, Allies01Objectives.FindEinstein))
{
objectives.Add("Find Einstein. Tanya and Einstein must survive.");
}
if (MissionUtils.HasFlag(currentObjectives, Objectives.WaitForHelicopter))
if (MissionUtils.HasFlag(currentObjectives, Allies01Objectives.WaitForHelicopter))
{
objectives.Add("Wait for the helicopter and extract Einstein. Tanya and Einstein must survive.");
}
return objectives;
}
Allies01Objectives currentObjectives = Allies01Objectives.FindEinstein;
void DisplayObjective(string objective)
{
Game.AddChatLine(Color.LimeGreen, "Objective", objective);
@@ -67,8 +69,6 @@ namespace OpenRA.Mods.RA.Missions
}
}
Objectives currentObjectives = Objectives.FindEinstein;
Player allies;
Player soviets;
@@ -145,7 +145,7 @@ namespace OpenRA.Mods.RA.Missions
{
Sound.Play(Taunts[world.SharedRandom.Next(Taunts.Length)]);
}
if (MissionUtils.HasFlag(currentObjectives, Objectives.FindEinstein))
if (MissionUtils.HasFlag(currentObjectives, Allies01Objectives.FindEinstein))
{
if (AlliesControlLab())
{
@@ -153,7 +153,8 @@ namespace OpenRA.Mods.RA.Missions
Sound.Play("flaren1.aud");
SpawnEinsteinAtLab();
SendShips();
currentObjectives = Objectives.WaitForHelicopter;
currentObjectives = MissionUtils.RemoveFlag(currentObjectives, Allies01Objectives.FindEinstein);
currentObjectives = MissionUtils.AddFlag(currentObjectives, Allies01Objectives.WaitForHelicopter);
DisplayObjectives();
currentAttackWaveFrameNumber = world.FrameNumber;
}
@@ -162,7 +163,7 @@ namespace OpenRA.Mods.RA.Missions
MissionFailed("Einstein was killed.");
}
}
else if (MissionUtils.HasFlag(currentObjectives, Objectives.WaitForHelicopter))
else if (MissionUtils.HasFlag(currentObjectives, Allies01Objectives.WaitForHelicopter))
{
if (world.FrameNumber >= currentAttackWaveFrameNumber + 600)
{

View File

@@ -28,13 +28,49 @@ namespace OpenRA.Mods.RA.Missions
class Allies02Script : IWorldLoaded, ITick
{
static readonly string[] Objectives =
[Flags]
enum Allies02Objectives
{
"Hold off the Soviet forces and destroy the SAM sites. Tanya and Einstein must survive.",
"Wait for the helicopter and extract Einstein. Tanya and Einstein must survive."
};
None = 0,
DestroySamSites = 1,
WaitForHelicopter = 2
}
int currentObjective;
IEnumerable<string> GetObjectiveText()
{
var objectives = new List<string>();
if (MissionUtils.HasFlag(currentObjectives, Allies02Objectives.DestroySamSites))
{
objectives.Add("Hold off the Soviet forces and destroy the SAM sites. Tanya and Einstein must survive.");
}
if (MissionUtils.HasFlag(currentObjectives, Allies02Objectives.WaitForHelicopter))
{
objectives.Add("Wait for the helicopter and extract Einstein. Tanya and Einstein must survive.");
}
return objectives;
}
Allies02Objectives currentObjectives = Allies02Objectives.DestroySamSites;
void DisplayObjective(string objective)
{
Game.AddChatLine(Color.LimeGreen, "Objective", objective);
Sound.Play("bleep6.aud");
}
void DisplayHint(string objective)
{
Game.AddChatLine(Color.Yellow, "Hint", objective);
Sound.Play("bleep6.aud");
}
void DisplayObjectives()
{
foreach (var objective in GetObjectiveText())
{
DisplayObjective(objective);
}
}
Actor sam1;
Actor sam2;
@@ -92,12 +128,6 @@ namespace OpenRA.Mods.RA.Missions
const string SignalFlareName = "flare";
const int EngineerSafeRange = 5;
void DisplayObjective()
{
Game.AddChatLine(Color.LimeGreen, "Objective", Objectives[currentObjective]);
Sound.Play("bleep6.aud");
}
void MissionFailed(string text)
{
if (allies1.WinState != WinState.Undefined)
@@ -140,7 +170,7 @@ namespace OpenRA.Mods.RA.Missions
}
if (world.FrameNumber % 3500 == 1)
{
DisplayObjective();
DisplayObjectives();
}
if (world.FrameNumber % 50 == 1)
{
@@ -174,18 +204,19 @@ namespace OpenRA.Mods.RA.Missions
{
RescueEngineer();
}
if (currentObjective == 0)
if (MissionUtils.HasFlag(currentObjectives, Allies02Objectives.DestroySamSites))
{
if (sam1.Destroyed && sam2.Destroyed && sam3.Destroyed && sam4.Destroyed)
{
currentObjective++;
DisplayObjective();
currentObjectives = MissionUtils.RemoveFlag(currentObjectives, Allies02Objectives.DestroySamSites);
currentObjectives = MissionUtils.AddFlag(currentObjectives, Allies02Objectives.WaitForHelicopter);
DisplayObjectives();
SpawnSignalFlare();
Sound.Play("flaren1.aud");
ExtractEinsteinAtLZ();
}
}
else if (currentObjective == 1 && einsteinChinook != null)
else if (MissionUtils.HasFlag(currentObjectives, Allies02Objectives.WaitForHelicopter) && einsteinChinook != null)
{
if (einsteinChinook.Destroyed)
{