bots choose random colors

This commit is contained in:
Chris Forbes
2010-10-07 07:41:14 +13:00
parent c85503811c
commit 5af8f5e2d9
3 changed files with 12 additions and 2 deletions

View File

@@ -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);