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
+9 -4
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);
@@ -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);
// }
//}
}
}
@@ -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();
+32 -16
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;
}
}