Traitor probability selection instead of separate traitor mode, stopping water ambience on round end, lobby sync after client has verified connection, WIP shiftsummary in multiplayer, "cleanbuild" command in debugconsole

This commit is contained in:
Regalis
2016-01-07 23:25:11 +02:00
parent e102154f5f
commit 03f569b161
19 changed files with 273 additions and 140 deletions

View File

@@ -187,7 +187,7 @@ namespace Barotrauma
new GUIImage(new Rectangle(-5, -5, 0, 0), character.AnimController.Limbs[0].sprite, Alignment.Left, characterButton);
var humanAi = character.AIController as HumanAIController;
if (humanAi.CurrentOrder != null)
if (humanAi != null && humanAi.CurrentOrder != null)
{
CreateCharacterOrderFrame(characterButton, humanAi.CurrentOrder, humanAi.CurrentOrderOption);
}

View File

@@ -1161,6 +1161,7 @@ namespace Barotrauma
GameMain.NetworkMember.AddChatMessage(chatMessage, ChatMessageType.Dead);
GameMain.LightManager.LosEnabled = false;
controlled = null;
new NetworkEvent(NetworkEventType.KillCharacter, ID, true, causeOfDeath);
}
@@ -1169,7 +1170,7 @@ namespace Barotrauma
{
new NetworkEvent(NetworkEventType.KillCharacter, ID, true, causeOfDeath);
}
//otherwise don't kill the Character unless received a message about the Character dying
//don't kill the Character unless received a message about the Character dying
else if (!isNetworkMessage)
{
return;

View File

@@ -423,6 +423,30 @@ namespace Barotrauma
GameMain.Server.ShowNetStats = !GameMain.Server.ShowNetStats;
break;
case "cleanbuild":
GameMain.Config.MusicVolume = 0.5f;
GameMain.Config.SoundVolume = 0.5f;
GameMain.Config.Save("config.xml");
DebugConsole.NewMessage("Set music and sound volume to 0.5", Color.Green);
var saveFiles = System.IO.Directory.GetFiles(SaveUtil.SaveFolder);
foreach (string saveFile in saveFiles)
{
System.IO.File.Delete(saveFile);
DebugConsole.NewMessage("Deleted "+saveFile, Color.Green);
}
if (System.IO.File.Exists("filelist.xml"))
{
System.IO.File.Delete("filelist.xml");
}
if (!System.IO.File.Exists("Content/Map/TutorialSub.sub"))
{
DebugConsole.ThrowError("TutorialSub.sub not found!");
}
break;
default:
NewMessage("Command not found", Color.Red);
break;

View File

@@ -86,7 +86,11 @@ namespace Barotrauma
characterInfos.Add(character.Info);
}
commander.UpdateCharacters();
if (character is AICharacter)
{
commander.UpdateCharacters();
}
character.Info.CreateCharacterFrame(listBox, character.Info.Name.Replace(' ', '\n'), character);
@@ -128,9 +132,10 @@ namespace Barotrauma
GUIComponent characterBlock = listBox.GetChild(killedCharacter) as GUIComponent;
if (characterBlock != null) characterBlock.Color = Color.DarkRed * 0.5f;
commander.UpdateCharacters();
if (killedCharacter is AICharacter)
{
commander.UpdateCharacters();
}
//if (characters.Find(c => !c.IsDead)==null)
//{
// Game1.GameSession.EndShift(null, null);

View File

@@ -43,10 +43,10 @@ namespace Barotrauma
var mode = new GameModePreset("SandBox", typeof(GameMode), false);
mode.Description = "A game mode with no specific objectives.";
mode = new GameModePreset("Traitor", typeof(TraitorMode), false);
mode.Description = "One of the players is selected as a traitor and given a secret objective. "
+ "The rest of the crew will win if they reach the end of the level or kill the traitor "
+ "before the objective is completed.";
//mode = new GameModePreset("Traitor", typeof(TraitorMode), false);
//mode.Description = "One of the players is selected as a traitor and given a secret objective. "
// + "The rest of the crew will win if they reach the end of the level or kill the traitor "
// + "before the objective is completed.";
mode = new GameModePreset("Mission", typeof(MissionMode), false);
mode.Description = "The crew must work together to complete a specific task, such as retrieving "

View File

@@ -18,8 +18,6 @@ namespace Barotrauma
private GUIButton endShiftButton;
public readonly CargoManager CargoManager;
private ShiftSummary shiftSummary;
public Map Map;
@@ -119,8 +117,6 @@ namespace Barotrauma
isRunning = true;
CrewManager.StartShift();
shiftSummary = new ShiftSummary(GameMain.GameSession);
}
public bool TryHireCharacter(HireManager hireManager, CharacterInfo characterInfo)
@@ -195,11 +191,6 @@ namespace Barotrauma
//if (endMessage != "" || this.endMessage == null) this.endMessage = endMessage;
GUIFrame summaryFrame = shiftSummary.CreateSummaryFrame();
GUIMessageBox.MessageBoxes.Enqueue(summaryFrame);
var okButton = new GUIButton(new Rectangle(0,0,100,30), "Ok", Alignment.BottomRight, GUI.Style, summaryFrame.children[0]);
okButton.OnClicked = (GUIButton button, object obj) => { GUIMessageBox.MessageBoxes.Dequeue(); return true; };
bool success = CrewManager.characters.Any(c => !c.IsDead);
if (success)

View File

@@ -4,84 +4,66 @@ using Barotrauma.Networking;
namespace Barotrauma
{
class TraitorMode : GameMode
class TraitorManager
{
private Character traitorCharacter, targetCharacter;
public TraitorMode(GameModePreset preset)
: base(preset)
public TraitorManager(GameServer server)
{
server.NewTraitor(out traitorCharacter, out targetCharacter);
}
public string GetEndMessage()
{
if (GameMain.Server == null || traitorCharacter == null || targetCharacter == null) return "";
if (targetCharacter == null || targetCharacter.IsDead)
{
string endMessage = traitorCharacter.Name + " was a traitor! ";
endMessage += (traitorCharacter.Info.Gender == Gender.Male) ? "His" : "Her";
endMessage += " task was to assassinate " + targetCharacter.Name + ". The task was successful.";
//End(endMessage);
}
else if (traitorCharacter == null || traitorCharacter.IsDead)
{
string endMessage = traitorCharacter.Name + " was a traitor! ";
endMessage += (traitorCharacter.Info.Gender == Gender.Male) ? "His" : "Her";
endMessage += " task was to assassinate " + targetCharacter.Name + ", but ";
endMessage += (traitorCharacter.Info.Gender == Gender.Male) ? "he" : "she";
endMessage += " got " + ((traitorCharacter.Info.Gender == Gender.Male) ? "himself" : "herself");
endMessage += " killed before completing it.";
return endMessage;
}
else if (Submarine.Loaded.AtEndPosition)
{
string endMessage = traitorCharacter.Name + " was a traitor! ";
endMessage += (traitorCharacter.Info.Gender == Gender.Male) ? "His" : "Her";
endMessage += " task was to assassinate " + targetCharacter.Name + ". ";
endMessage += "The task was unsuccessful - the has submarine reached its destination.";
return endMessage;
}
return "";
}
public override void Start()
{
base.Start();
//public void CharacterLeft(Character character)
//{
// if (character != traitorCharacter && character != targetCharacter) return;
traitorCharacter = null;
targetCharacter = null;
}
public override void Update(float deltaTime)
{
if (GameMain.Server == null) return;
base.Update(deltaTime);
if (!isRunning) return;
if (traitorCharacter == null || targetCharacter == null)
{
GameMain.Server.NewTraitor(out traitorCharacter, out targetCharacter);
}
else
{
if (targetCharacter == null || targetCharacter.IsDead)
{
string endMessage = traitorCharacter.Name + " was a traitor! ";
endMessage += (traitorCharacter.Info.Gender == Gender.Male) ? "His" : "Her";
endMessage += " task was to assassinate " + targetCharacter.Name + ". The task was successful.";
End(endMessage);
}
else if (traitorCharacter == null || traitorCharacter.IsDead)
{
string endMessage = traitorCharacter.Name + " was a traitor! ";
endMessage += (traitorCharacter.Info.Gender == Gender.Male) ? "His" : "Her";
endMessage += " task was to assassinate " + targetCharacter.Name + ", but ";
endMessage += (traitorCharacter.Info.Gender == Gender.Male) ? "he" : "she";
endMessage += " got " + ((traitorCharacter.Info.Gender == Gender.Male) ? "himself" : "herself");
endMessage += " killed before completing it.";
End(endMessage);
return;
}
else if (Submarine.Loaded.AtEndPosition)
{
string endMessage = traitorCharacter.Name + " was a traitor! ";
endMessage += (traitorCharacter.Info.Gender == Gender.Male) ? "His" : "Her";
endMessage += " task was to assassinate " + targetCharacter.Name + ". ";
endMessage += "The task was unsuccessful - the has submarine reached its destination.";
End(endMessage);
return;
}
}
}
public void CharacterLeft(Character character)
{
if (character != traitorCharacter && character != targetCharacter) return;
if (character == traitorCharacter)
{
string endMessage = "The traitor has disconnected from the server.";
End(endMessage);
}
else if (character == targetCharacter)
{
string endMessage = "The traitor's target has disconnected from the server.";
End(endMessage);
}
}
// if (character == traitorCharacter)
// {
// string endMessage = "The traitor has disconnected from the server.";
// End(endMessage);
// }
// else if (character == targetCharacter)
// {
// string endMessage = "The traitor's target has disconnected from the server.";
// End(endMessage);
// }
//}
}
}

View File

@@ -18,6 +18,8 @@ namespace Barotrauma
private Submarine submarine;
public CrewManager CrewManager;
private ShiftSummary shiftSummary;
public Mission Mission
{
@@ -54,6 +56,11 @@ namespace Barotrauma
get { return saveFile; }
}
public ShiftSummary ShiftSummary
{
get { return shiftSummary; }
}
public GameSession(Submarine submarine, string saveFile, GameModePreset gameModePreset = null)
{
GameMain.GameSession = this;
@@ -119,6 +126,8 @@ namespace Barotrauma
if (Mission!=null) Mission.Start(Level.Loaded);
shiftSummary = new ShiftSummary(this);
if (gameMode!=null) gameMode.Start();
TaskManager.StartShift(level);
@@ -139,6 +148,12 @@ namespace Barotrauma
GameMain.LobbyScreen.Select();
}
GUIFrame summaryFrame = shiftSummary.CreateSummaryFrame(endMessage);
GUIMessageBox.MessageBoxes.Enqueue(summaryFrame);
var okButton = new GUIButton(new Rectangle(0, 0, 100, 30), "Ok", Alignment.BottomRight, GUI.Style, summaryFrame.children[0]);
okButton.OnClicked = (GUIButton button, object obj) => { GUIMessageBox.MessageBoxes.Dequeue(); return true; };
TaskManager.EndShift();
//gameMode.End();

View File

@@ -37,8 +37,8 @@ namespace Barotrauma
{
this.gameSession = gameSession;
startLocation = gameSession.Map.CurrentLocation;
endLocation = gameSession.Map.SelectedLocation;
startLocation = gameSession.Map==null ? null : gameSession.Map.CurrentLocation;
endLocation = gameSession.Map==null ? null : gameSession.Map.SelectedLocation;
casualties = new List<Casualty>();
@@ -48,7 +48,6 @@ namespace Barotrauma
}
selectedMission = gameSession.Mission;
}
@@ -57,24 +56,36 @@ namespace Barotrauma
casualties.Add(new Casualty(character.Info, causeOfDeath, ""));
}
public GUIFrame CreateSummaryFrame()
public GUIFrame CreateSummaryFrame(string endMessage)
{
bool singleplayer = GameMain.NetworkMember == null;
bool gameOver = !gameSession.CrewManager.characters.Any(c => !c.IsDead);
bool progress = Submarine.Loaded.AtEndPosition;
GUIFrame frame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.8f);
int width = 760, height = 400;
GUIFrame innerFrame = new GUIFrame(new Rectangle(0, 0, width, height), null, Alignment.Center, GUI.Style, frame);
int y = 0;
string summaryText = InfoTextManager.GetInfoText(gameOver ? "gameover" :
(progress ? "progress" : "return"));
if (singleplayer)
{
string summaryText = InfoTextManager.GetInfoText(gameOver ? "gameover" :
(progress ? "progress" : "return"));
var infoText = new GUITextBlock(new Rectangle(0, y, 0, 50), summaryText, GUI.Style, innerFrame, true);
y += infoText.Rect.Height;
var infoText = new GUITextBlock(new Rectangle(0, y, 0, 50), summaryText, GUI.Style, innerFrame, true);
y += infoText.Rect.Height;
}
if (!string.IsNullOrWhiteSpace(endMessage))
{
var endText = new GUITextBlock(new Rectangle(0, y, 0, 30), endMessage, GUI.Style, innerFrame, true);
y += 30 + endText.Text.Split('\n').Length * 20;
}
new GUITextBlock(new Rectangle(0, y, 0, 20), "Crew status:", GUI.Style, innerFrame, GUI.LargeFont);
y += 30;
@@ -87,8 +98,11 @@ namespace Barotrauma
var characterFrame = new GUIFrame(new Rectangle(x, y, 170, 70), character.IsDead ? Color.DarkRed * 0.7f : Color.Transparent, GUI.Style, listBox);
characterFrame.OutlineColor = Color.Transparent;
characterFrame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
characterFrame.CanBeFocused = false;
character.Info.CreateCharacterFrame(characterFrame,
character.Info.Job != null ? (character.Info.Name + '\n' + "(" + character.Info.Job.Name + ")") : character.Info.Name, null);
string statusText;
Color statusColor;
@@ -103,7 +117,7 @@ namespace Barotrauma
else
{
statusText = (character.Health / character.MaxHealth > 0.8f) ? "OK" : "Injured";
statusColor = Color.DarkGreen;
statusColor = (character.Health / character.MaxHealth > 0.8f) ? Color.DarkGreen : Color.DarkOrange;
}
new GUITextBlock(new Rectangle(0, 0, 0, 20), statusText,
@@ -122,10 +136,12 @@ namespace Barotrauma
new GUITextBlock(new Rectangle(0, y, 0, 30),
(GameMain.GameSession.Mission.Completed) ? GameMain.GameSession.Mission.SuccessMessage : GameMain.GameSession.Mission.FailureMessage,
GUI.Style, innerFrame);
y += 40;
if (GameMain.GameSession.Mission.Completed)
if (GameMain.GameSession.Mission.Completed && singleplayer)
{
new GUITextBlock(new Rectangle(0, y + 40, 0, 30), "Reward: " + GameMain.GameSession.Mission.Reward, GUI.Style, innerFrame);
new GUITextBlock(new Rectangle(0, y, 0, 30), "Reward: " + GameMain.GameSession.Mission.Reward, GUI.Style, innerFrame);
y += 30;
}
}

View File

@@ -30,7 +30,8 @@ namespace Barotrauma.Items.Components
set
{
if (expression == value) return;
expression = value;
expression = value;
previousReceivedSignal = "";
try
{
@@ -55,12 +56,13 @@ namespace Barotrauma.Items.Components
{
if (string.IsNullOrWhiteSpace(expression) || regex==null) return;
if (receivedSignal!=previousReceivedSignal)
if (receivedSignal != previousReceivedSignal)
{
try
{
Match match = regex.Match(receivedSignal);
previousResult = match.Success;
previousReceivedSignal = receivedSignal;
}
catch

View File

@@ -243,6 +243,10 @@ namespace Barotrauma.Networking
GameMain.NetLobbyScreen.AddPlayer(name);
CanStart = true;
NetOutgoingMessage lobbyUpdateRequest = client.CreateMessage();
lobbyUpdateRequest.Write((byte)PacketTypes.RequestNetLobbyUpdate);
client.SendMessage(lobbyUpdateRequest, NetDeliveryMethod.ReliableUnordered);
}
else if (packetType == (byte)PacketTypes.KickedOut)
{
@@ -588,15 +592,18 @@ namespace Barotrauma.Networking
public IEnumerable<object> EndGame(string endMessage)
{
var messageBox = new GUIMessageBox("The round has ended", endMessage, 400, 300);
GameMain.GameSession.gameMode.End(endMessage);
//var messageBox = new GUIMessageBox("The round has ended", endMessage, 400, 300);
if (!gameStarted) yield return CoroutineStatus.Success;
gameStarted = false;
Character.Controlled = null;
GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
GameMain.LightManager.LosEnabled = false;
float endPreviewLength = 10.0f;
var cinematic = new TransitionCinematic(Submarine.Loaded, GameMain.GameScreen.Cam, endPreviewLength);
@@ -615,7 +622,7 @@ namespace Barotrauma.Networking
//GameMain.GameScreen.Cam.TargetPos = Submarine.Loaded.Position + offset * 0.8f;
//Game1.GameScreen.Cam.MoveCamera((float)deltaTime);
messageBox.Text = endMessage + "\nReturning to lobby in " + (int)secondsLeft + " s";
//messageBox.Text = endMessage + "\nReturning to lobby in " + (int)secondsLeft + " s";
yield return CoroutineStatus.Running;
} while (secondsLeft > 0.0f);
@@ -641,13 +648,13 @@ namespace Barotrauma.Networking
// yield return CoroutineStatus.Running;
//} while (secondsLeft > 0.0f);
messageBox.Close(null,null);
//messageBox.Close(null,null);
Submarine.Unload();
GameMain.NetLobbyScreen.Select();
if (GameMain.GameSession!=null) GameMain.GameSession.EndShift("");
//if (GameMain.GameSession!=null) GameMain.GameSession.EndShift("");
myCharacter = null;
foreach (Client c in otherClients)
@@ -776,6 +783,9 @@ namespace Barotrauma.Networking
}
Character character = Character.Create(ch, position, !isMyCharacter, false);
GameMain.GameSession.CrewManager.characters.Add(character);
character.OnDeath = GameMain.GameSession.ShiftSummary.AddCasualty;
character.ID = ID;

View File

@@ -32,6 +32,8 @@ namespace Barotrauma.Networking
private bool masterServerResponded;
public TraitorManager TraitorManager;
public GameServer(string name, int port, bool isPublic = false, string password = "", bool attemptUPnP = false, int maxPlayers = 10)
{
var endRoundButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170, 20, 150, 25), "End round", Alignment.TopLeft, GUI.Style, inGameHUD);
@@ -401,8 +403,6 @@ namespace Barotrauma.Networking
SendMessage(outmsg, NetDeliveryMethod.ReliableUnordered, inc.SenderConnection);
AddChatMessage(sender.name + " has joined the server", ChatMessageType.Server);
UpdateNetLobby(null, null);
}
}
else if (inc.SenderConnection.Status == NetConnectionStatus.Disconnected)
@@ -470,6 +470,9 @@ namespace Barotrauma.Networking
case (byte)PacketTypes.Vote:
Voting.RegisterVote(inc, ConnectedClients);
break;
case (byte)PacketTypes.RequestNetLobbyUpdate:
UpdateNetLobby(null, null);
break;
case (byte)PacketTypes.SpectateRequest:
if (gameStarted && allowSpectating)
{
@@ -772,6 +775,9 @@ namespace Barotrauma.Networking
ConnectedClients[i].Character = Character.Create(
ConnectedClients[i].characterInfo, assignedWayPoints[i].WorldPosition, true, false);
ConnectedClients[i].Character.GiveJobItems(assignedWayPoints[i]);
GameMain.GameSession.CrewManager.characters.Add(ConnectedClients[i].Character);
ConnectedClients[i].Character.OnDeath = GameMain.GameSession.ShiftSummary.AddCasualty;
}
if (characterInfo != null)
@@ -780,6 +786,9 @@ namespace Barotrauma.Networking
Character.Controlled = myCharacter;
myCharacter.GiveJobItems(assignedWayPoints[assignedWayPoints.Length - 1]);
GameMain.GameSession.CrewManager.characters.Add(myCharacter);
myCharacter.OnDeath = GameMain.GameSession.ShiftSummary.AddCasualty;
}
var startMessage = CreateStartMessage(roundStartSeed, Submarine.Loaded, GameMain.GameSession.gameMode.Preset);
@@ -790,6 +799,11 @@ namespace Barotrauma.Networking
UpdateCrewFrame();
if (TraitorsEnabled == YesNoMaybe.Yes || (TraitorsEnabled == YesNoMaybe.Maybe && Rand.Range(0.0f, 1.0f)<0.5f))
{
TraitorManager = new TraitorManager(this);
}
//give some time for the clients to load the map
yield return new WaitForSeconds(2.0f);
@@ -838,7 +852,14 @@ namespace Barotrauma.Networking
private bool EndButtonHit(GUIButton button, object obj)
{
GameMain.GameSession.gameMode.End("Server admin has ended the round");
string endMessage = "The round has ended." + '\n';
if (TraitorManager!=null)
{
endMessage += TraitorManager.GetEndMessage();
}
GameMain.GameSession.gameMode.End(endMessage);
if (autoRestart) AutoRestartTimer = 20.0f;
@@ -847,7 +868,7 @@ namespace Barotrauma.Networking
public IEnumerable<object> EndGame(string endMessage)
{
var messageBox = new GUIMessageBox("The round has ended", endMessage, 400, 300);
//var messageBox = new GUIMessageBox("The round has ended", endMessage, 400, 300);
Character.Controlled = null;
myCharacter = null;
@@ -893,14 +914,14 @@ namespace Barotrauma.Networking
//GameMain.GameScreen.Cam.TargetPos = Submarine.Loaded.Position + offset * 0.8f;
//Game1.GameScreen.Cam.MoveCamera((float)deltaTime);
messageBox.Text = endMessage + "\nReturning to lobby in " + (int)secondsLeft + " s";
//messageBox.Text = endMessage + "\nReturning to lobby in " + (int)secondsLeft + " s";
yield return CoroutineStatus.Running;
} while (secondsLeft > 0.0f);
Submarine.Unload();
messageBox.Close(null, null);
//messageBox.Close(null, null);
GameMain.NetLobbyScreen.Select();
@@ -922,11 +943,11 @@ namespace Barotrauma.Networking
{
if (GameMain.GameSession!=null && GameMain.GameSession.gameMode!=null)
{
TraitorMode traitorMode = GameMain.GameSession.gameMode as TraitorMode;
if (traitorMode!=null)
{
traitorMode.CharacterLeft(client.Character);
}
//TraitorMode traitorMode = GameMain.GameSession.gameMode as TraitorMode;
//if (traitorMode!=null)
//{
// traitorMode.CharacterLeft(client.Character);
//}
}
client.Character.ClearInputs();

View File

@@ -6,11 +6,16 @@ using System.Text;
namespace Barotrauma.Networking
{
enum SelectionMode
enum SelectionMode : int
{
Manual = 0, Random = 1, Vote = 2
}
enum YesNoMaybe : int
{
No = 0, Maybe = 1, Yes = 2
}
partial class GameServer : NetworkMember
{
public bool ShowNetStats;
@@ -47,6 +52,12 @@ namespace Barotrauma.Networking
}
}
public YesNoMaybe TraitorsEnabled
{
get;
set;
}
public SelectionMode SubSelectionMode
{
get { return subSelectionMode; }

View File

@@ -15,6 +15,8 @@ namespace Barotrauma.Networking
PlayerJoined, PlayerLeft, KickedOut,
RequestNetLobbyUpdate,
StartGame, EndGame,
CharacterInfo,

View File

@@ -18,6 +18,9 @@ namespace Barotrauma
private GUIListBox playerList;
private GUIListBox subList, modeList, chatBox;
private GUIButton[] traitorProbabilityButtons;
private GUITextBlock traitorProbabilityText;
private GUIListBox jobList;
@@ -31,8 +34,6 @@ namespace Barotrauma
private GUITickBox autoRestartBox;
private float camAngle;
public bool IsServer;
public string ServerName, ServerMessage;
@@ -260,6 +261,21 @@ namespace Barotrauma
var restartText = new GUITextBlock(new Rectangle(columnX, 210, 20, 20), "", GUI.Style, infoFrame);
restartText.TextGetter = AutoRestartText;
//traitor probability ------------------------------------------------------------------
var traitorText = new GUITextBlock(new Rectangle(columnX, 230, 20, 20), "Traitors:", GUI.Style, infoFrame);
traitorProbabilityButtons = new GUIButton[2];
traitorProbabilityButtons[0] = new GUIButton(new Rectangle(columnX, 260, 20, 20), "<", GUI.Style, infoFrame);
traitorProbabilityButtons[0].UserData = -1;
traitorProbabilityText = new GUITextBlock(new Rectangle(columnX+20, 260, 150, 20), "No", null,null, Alignment.TopCenter, GUI.Style, infoFrame);
traitorProbabilityButtons[1] = new GUIButton(new Rectangle(columnX + 150, 260, 20, 20), ">", GUI.Style, infoFrame);
traitorProbabilityButtons[1].UserData = 1;
//server info ------------------------------------------------------------------
var serverName = new GUITextBox(new Rectangle(0, 0, 200, 20), null, null, Alignment.TopLeft, Alignment.TopLeft, GUI.Style, infoFrame);
@@ -296,6 +312,10 @@ namespace Barotrauma
seedBox.Enabled = GameMain.Server != null;
serverMessage.Enabled = GameMain.Server != null;
autoRestartBox.Enabled = GameMain.Server != null;
traitorProbabilityButtons[0].Enabled = GameMain.Server != null;
traitorProbabilityButtons[1].Enabled = GameMain.Server != null;
ServerName = (GameMain.Server==null) ? "Server" : GameMain.Server.Name;
infoFrame.RemoveChild(infoFrame.children.Find(c => c.UserData as string == "startButton"));
@@ -307,9 +327,12 @@ namespace Barotrauma
if (IsServer && GameMain.Server != null)
{
modeList.OnSelected = VotableClicked;
modeList.OnSelected += SelectMode;
modeList.OnSelected = SelectMode;
subList.OnSelected = VotableClicked;
subList.OnSelected += SelectMap;
subList.OnSelected = SelectMap;
traitorProbabilityButtons[0].OnClicked = ToggleTraitorsEnabled;
traitorProbabilityButtons[1].OnClicked = ToggleTraitorsEnabled;
GUIButton startButton = new GUIButton(new Rectangle(0, 0, 80, 30), "Start", Alignment.BottomRight, GUI.Style, infoFrame);
startButton.OnClicked = GameMain.Server.StartGameClicked;
@@ -461,6 +484,29 @@ namespace Barotrauma
return true;
}
public bool ToggleTraitorsEnabled(GUIButton button, object userData)
{
if (GameMain.Server == null) return false;
int dir = (int)userData;
int index = (int)GameMain.Server.TraitorsEnabled + dir;
if (index < 0) index = 2;
if (index > 2) index = 0;
SetTraitorsEnabled((YesNoMaybe)index);
return true;
}
private void SetTraitorsEnabled(YesNoMaybe enabled)
{
if (GameMain.Server != null) GameMain.Server.TraitorsEnabled = enabled;
(traitorProbabilityText as GUITextBlock).Text = enabled.ToString();
}
private bool SelectMap(GUIComponent component, object obj)
{
if (GameMain.Server != null) GameMain.Server.UpdateNetLobby(obj);
@@ -884,6 +930,8 @@ namespace Barotrauma
msg.Write(ServerName);
msg.Write(ServerMessage);
msg.WriteRangedInteger(0, 2, (int)GameMain.Server.TraitorsEnabled);
//msg.Write(AllowSubVoting);
//msg.Write(AllowModeVoting);
@@ -914,6 +962,8 @@ namespace Barotrauma
float restartTimer = 0.0f;
YesNoMaybe traitorsEnabled;
try
{
mapName = msg.ReadString();
@@ -922,6 +972,8 @@ namespace Barotrauma
ServerName = msg.ReadString();
ServerMessage = msg.ReadString();
traitorsEnabled = (YesNoMaybe)msg.ReadRangedInteger(0, 2);
//AllowSubVoting = msg.ReadBoolean();
//AllowModeVoting = msg.ReadBoolean();
@@ -952,6 +1004,8 @@ namespace Barotrauma
if (!GameMain.NetworkMember.Voting.AllowModeVoting) modeList.Select(modeIndex, true);
SetTraitorsEnabled(traitorsEnabled);
autoRestartBox.Selected = autoRestart;
autoRestartTimer = restartTimer;

View File

@@ -1,4 +1,5 @@
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace Barotrauma
{
@@ -19,6 +20,8 @@ namespace Barotrauma
{
if (selected != null && selected!=this) selected.Deselect();
selected = this;
GUI.ScreenOverlayColor = Color.Transparent;
}
public virtual void Update(double deltaTime)

View File

@@ -173,17 +173,13 @@ namespace Barotrauma
if (Submarine.Loaded==null)
{
if (waterAmbienceIndexes[0] > 0)
for (int i = 0; i < waterAmbienceIndexes.Length; i++)
{
SoundManager.Stop(waterAmbienceIndexes[0]);
SoundManager.Stop(waterAmbienceIndexes[1]);
waterAmbienceIndexes[0] = 0;
waterAmbienceIndexes[1] = 0;
}
if (waterAmbienceIndexes[i] <= 0) continue;
SoundManager.Stop(waterAmbienceIndexes[i]);
waterAmbienceIndexes[i] = 0;
}
return;
}

View File

@@ -10,7 +10,7 @@ namespace Barotrauma
{
public class SaveUtil
{
private static string SaveFolder = "Data"+Path.DirectorySeparatorChar+"Saves";
public static string SaveFolder = "Data"+Path.DirectorySeparatorChar+"Saves";
public delegate void ProgressDelegate(string sMessage);

Binary file not shown.