Skip to content

Commit

Permalink
v0.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Regalis committed Feb 20, 2016
1 parent 619390a commit 308ae7a
Show file tree
Hide file tree
Showing 19 changed files with 109 additions and 78 deletions.
Binary file modified Subsurface/Content/Map/TutorialSub.sub
Binary file not shown.
4 changes: 2 additions & 2 deletions Subsurface/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.3.2.6")]
[assembly: AssemblyFileVersion("0.3.2.6")]
[assembly: AssemblyVersion("0.3.3.0")]
[assembly: AssemblyFileVersion("0.3.3.0")]
9 changes: 8 additions & 1 deletion Subsurface/Source/Characters/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,13 @@ public void ControlLocalPlayer(float deltaTime, Camera cam, bool moveCam = true)
}
}
}
else
{
if (selectedCharacter != null) DeselectCharacter();
selectedConstruction = null;
closestItem = null;
closestCharacter = null;
}

DisableControls = false;
}
Expand Down Expand Up @@ -1393,7 +1400,7 @@ public override bool FillNetworkData(NetworkEventType type, NetBuffer message, o
else
{
message.Write((byte)0);
message.WriteRangedInteger((int)lastAttackCauseOfDeath, 0, Enum.GetValues(typeof(CauseOfDeath)).Length);
message.WriteRangedInteger(0, Enum.GetValues(typeof(CauseOfDeath)).Length, (int)lastAttackCauseOfDeath);
}

if (AnimController.StunTimer<=0.0f && bleeding<=0.0f && oxygen>99.0f)
Expand Down
6 changes: 5 additions & 1 deletion Subsurface/Source/Characters/CharacterInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,11 @@ public virtual XElement Save(XElement parentElement)

public void Remove()
{
if (headSprite != null) headSprite.Remove();
//if (headSprite != null)
//{
// headSprite.Remove();
// headSprite = null;
//}
}
}
}
5 changes: 3 additions & 2 deletions Subsurface/Source/GUI/GUITextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,12 @@ public void ReceiveTextInput(string text)
}
public void ReceiveCommandInput(char command)
{
if (Text == null) Text = "";

switch (command)
{
case '\b': //backspace
if (Text.Length > 0)
Text = Text.Substring(0, Text.Length - 1);
if (Text.Length > 0) Text = Text.Substring(0, Text.Length - 1);
break;
//case '\r': //return
// if (OnEnterPressed != null)
Expand Down
80 changes: 67 additions & 13 deletions Subsurface/Source/GameSession/GameModes/TraitorMode.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Linq;
using Barotrauma.Networking;
using System.Collections.Generic;
using Microsoft.Xna.Framework;

namespace Barotrauma
{
Expand All @@ -10,46 +12,98 @@ class TraitorManager

public TraitorManager(GameServer server)
{
server.NewTraitor(out traitorCharacter, out targetCharacter);
Start(server);
}

private void Start(GameServer server)
{
if (server == null) return;

List<Character> characters = new List<Character>();
foreach (Client client in server.ConnectedClients)
{
if (!client.inGame || client.Character==null) continue;
characters.Add(client.Character);
}

if (server.Character!= null) characters.Add(server.Character);

if (characters.Count < 2)
{
traitorCharacter = null;
targetCharacter = null;
return;
}

int traitorIndex = Rand.Range(0, characters.Count);

int targetIndex = Rand.Range(0, characters.Count);
while (targetIndex == traitorIndex)
{
targetIndex = Rand.Range(0, characters.Count);
}

traitorCharacter = characters[traitorIndex];
targetCharacter = characters[targetIndex];

if (server.Character == null)
{
new GUIMessageBox("New traitor", traitorCharacter.Name + " is the traitor and the target is " + targetCharacter.Name+".");
}
else if (server.Character == traitorCharacter)
{
CreateStartPopUp(traitorCharacter.Name);
return;
}

server.NewTraitor(traitorCharacter, targetCharacter);
}

public static void CreateStartPopUp(string targetName)
{
new GUIMessageBox("You are the Traitor!",
"Your secret task is to assassinate " + targetName + "! Discretion is an utmost concern; sinking the submarine and killing the entire crew "
+ "will arouse suspicion amongst the Fleet. If possible, make the death look like an accident.", 400, 350);
}

public string GetEndMessage()
{
if (GameMain.Server == null || traitorCharacter == null || targetCharacter == null) return "";

if (targetCharacter.IsDead)
string endMessage = "";

if (targetCharacter.IsDead && !traitorCharacter.IsDead)
{
string endMessage = traitorCharacter.Name + " was a traitor! ";
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 (targetCharacter.IsDead && traitorCharacter.IsDead)
{
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, but luckily the bastard didn't make it out alive either.";
}
else if (traitorCharacter.IsDead)
{
string endMessage = traitorCharacter.Name + " was a traitor! ";
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
{
string endMessage = traitorCharacter.Name + " was a traitor! ";
endMessage = traitorCharacter.Name + " was a traitor! ";
endMessage += (traitorCharacter.Info.Gender == Gender.Male) ? "His" : "Her";
endMessage += " task was to assassinate " + targetCharacter.Name + ". ";
endMessage += (Submarine.Loaded.AtEndPosition) ?
"The task was unsuccessful - the has submarine reached its destination." :
"The task was unsuccessful.";

return endMessage;
}

return "";


return endMessage;
}

//public void CharacterLeft(Character character)
Expand Down
2 changes: 1 addition & 1 deletion Subsurface/Source/Items/Components/Machines/Pump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public override void ReceiveSignal(string signal, Connection connection, Item se

public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
{
message.WriteRangedInteger(-10,10,(int)(flowPercentage/10.0f));
message.WriteRangedInteger(-10, 10, (int)(flowPercentage / 10.0f));
message.Write(IsActive);
message.WritePadBits();

Expand Down
3 changes: 2 additions & 1 deletion Subsurface/Source/Items/Components/Signal/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public Connection(XElement element, Item item)
{
panelTexture = Sprite.LoadTexture("Content/Items/connectionpanel.png");

connector = new Sprite(panelTexture, new Rectangle(448, 80, 64, 64), new Vector2(-32.0f, -32.0f), 0.0f);
connector = new Sprite(panelTexture, new Rectangle(448, 80, 64, 64), Vector2.Zero, 0.0f);
connector.Origin = new Vector2(32.0f, 32.0f);
wireCorner = new Sprite(panelTexture, new Rectangle(448, 0, 64, 64), new Vector2(-32.0f, -32.0f), 0.0f);
wireVertical = new Sprite(panelTexture, new Rectangle(480, 64, 16, 16), new Vector2(-8.0f, -8.0f), 0.0f);
wireHorizontal = new Sprite(panelTexture, new Rectangle(496, 64, 16, 16), new Vector2(-8.0f, -8.0f), 0.0f);
Expand Down
9 changes: 7 additions & 2 deletions Subsurface/Source/Map/Hull.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ class Hull : MapEntity
float[] leftDelta;
float[] rightDelta;

float lastSentVolume;
private float lastSentVolume;
private float lastNetworkUpdate;

public List<Gap> ConnectedGaps;

Expand Down Expand Up @@ -705,7 +706,7 @@ public override bool FillNetworkData(Networking.NetworkEventType type, NetBuffer
message.WriteRangedSingle(MathHelper.Clamp(volume/FullVolume, 0.0f, 1.5f), 0.0f, 1.5f, 6);

message.Write((byte)fireSources.Count, 4);
for (int i = 0; i < Math.Min(fireSources.Count, 16) ;i++ )
for (int i = 0; i < Math.Min(fireSources.Count, 16); i++)
{
var fireSource = fireSources[i];

Expand All @@ -725,6 +726,8 @@ public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.N
{
data = null;

if (sendingTime < lastNetworkUpdate) return;

float newVolume = this.volume;

try
Expand Down Expand Up @@ -785,6 +788,8 @@ public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.N
toBeRemoved[i].Remove(true);
}
fireSources = newFireSources;

lastNetworkUpdate = sendingTime;
}


Expand Down
2 changes: 2 additions & 0 deletions Subsurface/Source/Map/Submarine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,8 @@ public void Load()
}

Vector2 center = (topLeft + bottomRight) / 2.0f;
center.X -= center.X % GridSize.X;
center.Y -= center.Y % GridSize.Y;

foreach (Item item in Item.ItemList)
{
Expand Down
2 changes: 1 addition & 1 deletion Subsurface/Source/Networking/GameClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ private void CheckServerMessages()
case (byte)PacketTypes.Traitor:
string targetName = inc.ReadString();

new GUIMessageBox("You are the Traitor!", "Your secret task is to assassinate " + targetName + "!");
TraitorManager.CreateStartPopUp(targetName);

break;
case (byte)PacketTypes.ResendRequest:
Expand Down
51 changes: 3 additions & 48 deletions Subsurface/Source/Networking/GameServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ private IEnumerable<object> StartGame(Submarine selectedSub, GameModePreset sele

UpdateCrewFrame();

if (TraitorsEnabled == YesNoMaybe.Yes || (TraitorsEnabled == YesNoMaybe.Maybe && Rand.Range(0.0f, 1.0f)<0.5f))
if (TraitorsEnabled == YesNoMaybe.Yes || (TraitorsEnabled == YesNoMaybe.Maybe && Rand.Range(0.0f, 1.0f) < 0.5f))
{
TraitorManager = new TraitorManager(this);
}
Expand Down Expand Up @@ -1022,15 +1022,6 @@ private void DisconnectClient(Client client, string msg = "", string targetmsg =

if (gameStarted && client.Character != null)
{
if (GameMain.GameSession!=null && GameMain.GameSession.gameMode!=null)
{
//TraitorMode traitorMode = GameMain.GameSession.gameMode as TraitorMode;
//if (traitorMode!=null)
//{
// traitorMode.CharacterLeft(client.Character);
//}
}

client.Character.ClearInputs();
}

Expand Down Expand Up @@ -1106,45 +1097,9 @@ private void KickClient(Client client, bool ban = false)
}
}

public void NewTraitor(out Character traitor, out Character target)
public void NewTraitor(Character traitor, Character target)
{
List<Character> characters = new List<Character>();
foreach (Client client in ConnectedClients)
{
if (!client.inGame || client.Character==null) continue;
characters.Add(client.Character);
}
if (myCharacter!= null) characters.Add(myCharacter);

if (characters.Count < 2)
{
traitor = null;
target = null;
return;
}

int traitorIndex = Rand.Range(0, characters.Count);

int targetIndex = Rand.Range(0, characters.Count);
while (targetIndex == traitorIndex)
{
targetIndex = Rand.Range(0, characters.Count);
}

traitor = characters[traitorIndex];
target = characters[targetIndex];

if (myCharacter==null)
{
new GUIMessageBox("New traitor", traitor.Info.Name + " is the traitor and the target is " + target.Info.Name+".");
}
else if (myCharacter == traitor)
{
new GUIMessageBox("You are the traitor!", "Your task is to assassinate " + target.Info.Name+".");
return;
}

Log(traitor.Info.Name + " is the traitor and the target is " + target.Info.Name, Color.Cyan);
Log(traitor.Name + " is the traitor and the target is " + target.Name, Color.Cyan);

Client traitorClient = null;
foreach (Client c in ConnectedClients)
Expand Down
4 changes: 2 additions & 2 deletions Subsurface/Source/Networking/NetworkEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ public bool FillData(NetBuffer message)
if (!e.FillNetworkData(eventType, message, data)) return false;
}

catch
catch (Exception exception)
{
#if DEBUG
DebugConsole.ThrowError("Failed to write network message for entity "+e.ToString());
DebugConsole.ThrowError("Failed to write network message for entity "+e.ToString(), exception);
#endif

return false;
Expand Down
8 changes: 4 additions & 4 deletions Subsurface/Source/Screens/MainMenuScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,17 @@ public MainMenuScreen(GameMain game)
}
if (Submarine.SavedSubmarines.Count > 0) mapList.Select(Submarine.SavedSubmarines[0]);

new GUITextBlock(new Rectangle((int)(mapList.Rect.Width + 30), 0, 100, 20),
new GUITextBlock(new Rectangle((int)(mapList.Rect.Width + 20), 0, 100, 20),
"Save name: ", GUI.Style, Alignment.Left, Alignment.Left, menuTabs[(int)Tab.NewGame]);

saveNameBox = new GUITextBox(new Rectangle((int)(mapList.Rect.Width + 20), 30, 180, 20),
saveNameBox = new GUITextBox(new Rectangle((int)(mapList.Rect.Width + 30), 30, 180, 20),
Alignment.TopLeft, GUI.Style, menuTabs[(int)Tab.NewGame]);
saveNameBox.Text = SaveUtil.CreateSavePath();

new GUITextBlock(new Rectangle((int)(mapList.Rect.Width + 30), 60, 100, 20),
new GUITextBlock(new Rectangle((int)(mapList.Rect.Width + 20), 60, 100, 20),
"Map Seed: ", GUI.Style, Alignment.Left, Alignment.Left, menuTabs[(int)Tab.NewGame]);

seedBox = new GUITextBox(new Rectangle((int)(mapList.Rect.Width + 20), 90, 180, 20),
seedBox = new GUITextBox(new Rectangle((int)(mapList.Rect.Width + 30), 90, 180, 20),
Alignment.TopLeft, GUI.Style, menuTabs[(int)Tab.NewGame]);
seedBox.Text = ToolBox.RandomSeed(8);

Expand Down
Binary file modified Subsurface/Submarines/Aegir Mark II.sub
Binary file not shown.
Binary file modified Subsurface/Submarines/Nehalennia.sub
Binary file not shown.
Binary file modified Subsurface/Submarines/Vellamo.sub
Binary file not shown.
2 changes: 2 additions & 0 deletions Subsurface/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ far away from the coordinates (0,0)
- character/inventory syncing bugfixes
- fixed spectators not seeing their own chat messages
- scrollable list of clients in the network statistics view
- small changes to the vanilla subs
- fixed the water brightness in Linux version

---------------------------------------------------------------------------------------------------------
v0.3.2.6
Expand Down
Binary file modified Subsurface_Solution.v12.suo
Binary file not shown.

0 comments on commit 308ae7a

Please sign in to comment.