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
@@ -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 "
@@ -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)
@@ -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);
// }
//}
}
}