diff --git a/OpenRA.Game/Player.cs b/OpenRA.Game/Player.cs index d25c7e21be..9cf4f2cf8f 100644 --- a/OpenRA.Game/Player.cs +++ b/OpenRA.Game/Player.cs @@ -49,6 +49,7 @@ namespace OpenRA Index = index; Palette = "player"+index; + Color = pr.Color; Color2 = pr.Color2; ClientIndex = 0; /* it's a map player, "owned" by host */ diff --git a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs index c14186573c..f2d7c6c28e 100755 --- a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs @@ -174,7 +174,7 @@ namespace OpenRA.Widgets.Delegates } // hk is hue in the range [0,1] instead of [0,360] - Color ColorFromHSL(float hk, float s, float l) + public static Color ColorFromHSL(float hk, float s, float l) { // Convert from HSL to RGB var q = (l < 0.5f) ? l * (1 + s) : l + s - (l * s); diff --git a/OpenRA.Mods.RA/CreateMPPlayers.cs b/OpenRA.Mods.RA/CreateMPPlayers.cs index a7ec278c5e..0c196ec669 100644 --- a/OpenRA.Mods.RA/CreateMPPlayers.cs +++ b/OpenRA.Mods.RA/CreateMPPlayers.cs @@ -10,7 +10,8 @@ using System.Linq; using OpenRA.Network; -using OpenRA.Traits; +using OpenRA.Traits; +using OpenRA.Widgets.Delegates; namespace OpenRA.Mods.RA { @@ -47,6 +48,14 @@ namespace OpenRA.Mods.RA else if (slot.Bot != null) { /* spawn a bot in this slot, "owned" by the host */ + + /* pick a random color for the bot */ + var hue = (float)w.SharedRandom.NextDouble(); + w.Map.Players[slot.MapPlayer].Color = LobbyDelegate.ColorFromHSL(hue, 1.0f, 0.7f); + w.Map.Players[slot.MapPlayer].Color2 = LobbyDelegate.ColorFromHSL(hue, 1.0f, 0.2f); + + /* todo: pick a random name from the pool */ + var player = new Player(w, w.Map.Players[slot.MapPlayer], playerIndex++); w.AddPlayer(player);