Merge pull request #8710 from GraionDilach/victory-music
Implements victory and defeat music.
This commit is contained in:
@@ -352,6 +352,8 @@ namespace OpenRA.Traits
|
||||
void OnObjectiveFailed(Player player, int objectiveID);
|
||||
}
|
||||
|
||||
public interface IGameOver { void GameOver(World world); }
|
||||
|
||||
public interface IWarhead
|
||||
{
|
||||
int Delay { get; }
|
||||
|
||||
@@ -17,14 +17,31 @@ namespace OpenRA.Traits
|
||||
[Desc("Trait for music handling. Attach this to the world actor.")]
|
||||
public class MusicPlaylistInfo : ITraitInfo
|
||||
{
|
||||
[Desc("Music to play when the map starts.", "Plays the first song on the playlist when undefined.")]
|
||||
public readonly string StartingMusic = null;
|
||||
|
||||
[Desc("Should the starting music loop?")]
|
||||
public readonly bool LoopStartingMusic = false;
|
||||
|
||||
[Desc("Music to play when the game has been won.")]
|
||||
public readonly string VictoryMusic = null;
|
||||
|
||||
[Desc("Should the victory music loop?")]
|
||||
public readonly bool LoopVictoryMusic = false;
|
||||
|
||||
[Desc("Music to play when the game has been lost.")]
|
||||
public readonly string DefeatMusic = null;
|
||||
|
||||
[Desc("Should the defeat music loop?")]
|
||||
public readonly bool LoopDefeatMusic = false;
|
||||
|
||||
public object Create(ActorInitializer init) { return new MusicPlaylist(init.World, this); }
|
||||
}
|
||||
|
||||
public class MusicPlaylist : INotifyActorDisposing
|
||||
public class MusicPlaylist : INotifyActorDisposing, IGameOver
|
||||
{
|
||||
readonly MusicPlaylistInfo info;
|
||||
|
||||
readonly MusicInfo[] random;
|
||||
readonly MusicInfo[] playlist;
|
||||
|
||||
@@ -35,6 +52,8 @@ namespace OpenRA.Traits
|
||||
|
||||
public MusicPlaylist(World world, MusicPlaylistInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
|
||||
IsMusicAvailable = world.Map.Rules.InstalledMusic.Any();
|
||||
|
||||
playlist = world.Map.Rules.InstalledMusic.Select(a => a.Value).ToArray();
|
||||
@@ -71,6 +90,40 @@ namespace OpenRA.Traits
|
||||
return playlist;
|
||||
}
|
||||
|
||||
public void GameOver(World world)
|
||||
{
|
||||
if (!IsMusicAvailable)
|
||||
return;
|
||||
|
||||
var playedSong = currentSong;
|
||||
|
||||
if (world.LocalPlayer.WinState == WinState.Won)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(info.VictoryMusic)
|
||||
&& world.Map.Rules.Music.ContainsKey(info.VictoryMusic)
|
||||
&& world.Map.Rules.Music[info.VictoryMusic].Exists)
|
||||
{
|
||||
currentSong = world.Map.Rules.Music[info.VictoryMusic];
|
||||
repeat = info.LoopVictoryMusic;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Most RTS treats observers losing the game,
|
||||
// no need for a special handling involving them here.
|
||||
if (!string.IsNullOrEmpty(info.DefeatMusic)
|
||||
&& world.Map.Rules.Music.ContainsKey(info.DefeatMusic)
|
||||
&& world.Map.Rules.Music[info.DefeatMusic].Exists)
|
||||
{
|
||||
currentSong = world.Map.Rules.Music[info.DefeatMusic];
|
||||
repeat = info.LoopDefeatMusic;
|
||||
}
|
||||
}
|
||||
|
||||
if (playedSong != currentSong)
|
||||
Play();
|
||||
}
|
||||
|
||||
void Play()
|
||||
{
|
||||
if (currentSong == null || !IsMusicAvailable)
|
||||
|
||||
@@ -58,6 +58,10 @@ namespace OpenRA
|
||||
if (!gameOver)
|
||||
{
|
||||
gameOver = true;
|
||||
|
||||
foreach (var t in WorldActor.TraitsImplementing<IGameOver>())
|
||||
t.GameOver(this);
|
||||
|
||||
GameOver();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,9 +37,15 @@ trouble2: In Trouble (Voiced)
|
||||
Filename: trouble
|
||||
Extension: var
|
||||
justdoit: Just Do it Up
|
||||
justdoit2: Just Do it Up (Voiced)
|
||||
Filename: justdoit
|
||||
Extension: var
|
||||
map1: Map Theme
|
||||
march: March to Doom
|
||||
nomercy: No Mercy
|
||||
nomercy2: No Mercy (Voiced)
|
||||
Filename: nomercy
|
||||
Extension: var
|
||||
otp: On the Prowl
|
||||
prp: Prepare for Battle
|
||||
radio: Radio
|
||||
@@ -52,3 +58,6 @@ target: Target (Mechanical Man)
|
||||
j1: Untamed Land
|
||||
valkyrie: Ride of the Valkyries
|
||||
voic226m: Voice Rhythm
|
||||
outtakes: Outtakes
|
||||
nod_map1: Nod Map Theme
|
||||
nod_win1: Nod Win Theme
|
||||
@@ -72,9 +72,6 @@ WorldLoaded = function()
|
||||
|
||||
Trigger.OnPlayerWon(player, function()
|
||||
Media.PlaySpeechNotification(player, "Win")
|
||||
Trigger.AfterDelay(DateTime.Seconds(1), function()
|
||||
Media.PlayMusic("win1")
|
||||
end)
|
||||
end)
|
||||
|
||||
Trigger.OnPlayerLost(player, function()
|
||||
|
||||
@@ -291,6 +291,7 @@ Rules:
|
||||
PanelName: MISSION_OBJECTIVES
|
||||
MusicPlaylist:
|
||||
StartingMusic: nomercy
|
||||
VictoryMusic: nod_win1
|
||||
C10:
|
||||
Tooltip:
|
||||
Name: Nikoomba
|
||||
|
||||
@@ -228,6 +228,7 @@ Rules:
|
||||
Scripts: nod02a.lua
|
||||
MusicPlaylist:
|
||||
StartingMusic: ind2
|
||||
VictoryMusic: nod_win1
|
||||
^Vehicle:
|
||||
Tooltip:
|
||||
GenericVisibility: Enemy
|
||||
|
||||
@@ -270,6 +270,7 @@ Rules:
|
||||
Scripts: nod02b.lua
|
||||
MusicPlaylist:
|
||||
StartingMusic: ind2
|
||||
VictoryMusic: nod_win1
|
||||
^Vehicle:
|
||||
Tooltip:
|
||||
GenericVisibility: Enemy
|
||||
|
||||
@@ -469,6 +469,7 @@ Rules:
|
||||
PanelName: MISSION_OBJECTIVES
|
||||
MusicPlaylist:
|
||||
StartingMusic: chrg226m
|
||||
VictoryMusic: nod_win1
|
||||
^Vehicle:
|
||||
Tooltip:
|
||||
GenericVisibility: Enemy
|
||||
|
||||
@@ -513,6 +513,7 @@ Rules:
|
||||
PanelName: MISSION_OBJECTIVES
|
||||
MusicPlaylist:
|
||||
StartingMusic: chrg226m
|
||||
VictoryMusic: nod_win1
|
||||
^Vehicle:
|
||||
Tooltip:
|
||||
GenericVisibility: Enemy
|
||||
|
||||
@@ -570,6 +570,7 @@ Rules:
|
||||
PanelName: MISSION_OBJECTIVES
|
||||
MusicPlaylist:
|
||||
StartingMusic: valkyrie
|
||||
VictoryMusic: nod_win1
|
||||
^Vehicle:
|
||||
Tooltip:
|
||||
GenericVisibility: Enemy
|
||||
|
||||
@@ -509,6 +509,7 @@ Rules:
|
||||
Scripts: nod04b.lua
|
||||
MusicPlaylist:
|
||||
StartingMusic: warfare
|
||||
VictoryMusic: nod_win1
|
||||
^Vehicle:
|
||||
Tooltip:
|
||||
GenericVisibility: Enemy
|
||||
|
||||
@@ -404,6 +404,7 @@ Rules:
|
||||
Scripts: nod05.lua
|
||||
MusicPlaylist:
|
||||
StartingMusic: airstrik
|
||||
VictoryMusic: nod_win1
|
||||
^Vehicle:
|
||||
Tooltip:
|
||||
GenericVisibility: Enemy
|
||||
|
||||
@@ -677,6 +677,7 @@ Rules:
|
||||
Scripts: nod06a.lua
|
||||
MusicPlaylist:
|
||||
StartingMusic: rout
|
||||
VictoryMusic: nod_win1
|
||||
^Vehicle:
|
||||
Tooltip:
|
||||
GenericVisibility: Enemy
|
||||
|
||||
@@ -619,6 +619,7 @@ Rules:
|
||||
Scripts: nod06b.lua
|
||||
MusicPlaylist:
|
||||
StartingMusic: rout
|
||||
VictoryMusic: nod_win1
|
||||
^Vehicle:
|
||||
Tooltip:
|
||||
GenericVisibility: Enemy
|
||||
|
||||
@@ -505,6 +505,7 @@ Rules:
|
||||
Scripts: nod06c.lua
|
||||
MusicPlaylist:
|
||||
StartingMusic: rout
|
||||
VictoryMusic: nod_win1
|
||||
^Vehicle:
|
||||
Tooltip:
|
||||
GenericVisibility: Enemy
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
ScreenMap:
|
||||
ActorMap:
|
||||
MusicPlaylist:
|
||||
VictoryMusic: win1
|
||||
DefeatMusic: nod_map1
|
||||
TerrainGeometryOverlay:
|
||||
ShroudRenderer:
|
||||
ShroudVariants: typea, typeb, typec, typed
|
||||
|
||||
@@ -126,7 +126,7 @@ Rules:
|
||||
LuaScript:
|
||||
Scripts: shellmap.lua
|
||||
MusicPlaylist:
|
||||
StartingMusic: score
|
||||
StartingMusic: waitgame
|
||||
GlobalLightingPaletteEffect:
|
||||
rockettower:
|
||||
Power:
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
ScreenMap:
|
||||
ActorMap:
|
||||
MusicPlaylist:
|
||||
VictoryMusic: score
|
||||
DefeatMusic: options
|
||||
TerrainGeometryOverlay:
|
||||
ShroudRenderer:
|
||||
ShroudVariants: typea, typeb, typec, typed
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
ActorMap:
|
||||
ScreenMap:
|
||||
MusicPlaylist:
|
||||
VictoryMusic: score
|
||||
DefeatMusic: map
|
||||
TerrainGeometryOverlay:
|
||||
LoadWidgetAtGameStart:
|
||||
ShroudRenderer:
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
ScreenMap:
|
||||
ActorMap:
|
||||
MusicPlaylist:
|
||||
VictoryMusic: score
|
||||
DefeatMusic: maps
|
||||
LoadWidgetAtGameStart:
|
||||
ShroudRenderer:
|
||||
Index: 255, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 20, 40, 56, 65, 97, 130, 148, 194, 24, 33, 66, 132, 28, 41, 67, 134, 1, 2, 4, 8, 3, 6, 12, 9, 7, 14, 13, 11, 5, 10, 15, 255
|
||||
|
||||
Reference in New Issue
Block a user