Speech bubble icon next to the character when speaking in multiplayer, fixed clients sending every message through radio when wearing a headset

This commit is contained in:
Regalis
2016-04-20 20:31:10 +03:00
parent eae35d139b
commit de2af7f973
5 changed files with 27 additions and 8 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 17 KiB

+9 -4
View File
@@ -113,8 +113,7 @@ namespace Barotrauma
{ {
get; get;
private set; private set;
} }
private CharacterInfo info; private CharacterInfo info;
@@ -157,6 +156,8 @@ namespace Barotrauma
get { return inventory; } get { return inventory; }
} }
public float SpeechBubbleTimer;
private float lockHandsTimer; private float lockHandsTimer;
public bool LockHands public bool LockHands
{ {
@@ -955,6 +956,8 @@ namespace Barotrauma
{ {
if (!Enabled) return; if (!Enabled) return;
SpeechBubbleTimer = Math.Max(0.0f, SpeechBubbleTimer - deltaTime);
obstructVisionAmount = Math.Max(obstructVisionAmount - deltaTime, 0.0f); obstructVisionAmount = Math.Max(obstructVisionAmount - deltaTime, 0.0f);
if (inventory!=null) if (inventory!=null)
@@ -1133,8 +1136,10 @@ namespace Barotrauma
GUI.DrawProgressBar(spriteBatch, healthBarPos, new Vector2(100.0f, 15.0f), health / maxHealth, Color.Lerp(Color.Red, Color.Green, health / maxHealth) * 0.8f); GUI.DrawProgressBar(spriteBatch, healthBarPos, new Vector2(100.0f, 15.0f), health / maxHealth, Color.Lerp(Color.Red, Color.Green, health / maxHealth) * 0.8f);
//GUI.DrawRectangle(spriteBatch, new Rectangle((int)healthBarPos.X - 2, (int)healthBarPos.Y - 2, 100 + 4, 15 + 4), Color.Black, false); if (SpeechBubbleTimer > 0.0f)
//GUI.DrawRectangle(spriteBatch, new Rectangle((int)healthBarPos.X, (int)healthBarPos.Y, (int)(100.0f * (health / maxHealth)), 15), Color.Red, true); {
GUI.SpeechBubbleIcon.Draw(spriteBatch, pos - Vector2.UnitY * 100.0f, Color.White * Math.Min(SpeechBubbleTimer, 1.0f));
}
} }
public void PlaySound(AIController.AiState state) public void PlaySound(AIController.AiState state)
+9
View File
@@ -52,6 +52,12 @@ namespace Barotrauma
get { return submarineIcon; } get { return submarineIcon; }
} }
public static Sprite SpeechBubbleIcon
{
get;
private set;
}
public static Sprite Arrow public static Sprite Arrow
{ {
get { return arrow; } get { return arrow; }
@@ -94,6 +100,9 @@ namespace Barotrauma
arrow = new Sprite("Content/UI/uiIcons.png", new Rectangle(80, 240, 16, 16), null); arrow = new Sprite("Content/UI/uiIcons.png", new Rectangle(80, 240, 16, 16), null);
arrow.Origin = arrow.size / 2; arrow.Origin = arrow.size / 2;
SpeechBubbleIcon = new Sprite("Content/UI/uiIcons.png", new Rectangle(0, 129, 65, 61), null);
SpeechBubbleIcon.Origin = SpeechBubbleIcon.size / 2;
Style = new GUIStyle("Content/UI/style.xml"); Style = new GUIStyle("Content/UI/style.xml");
} }
+1 -1
View File
@@ -977,7 +977,7 @@ namespace Barotrauma.Networking
{ {
string command = ChatMessage.GetChatMessageCommand(message, out message).ToLower(); string command = ChatMessage.GetChatMessageCommand(message, out message).ToLower();
if (CanUseRadio(Character.Controlled)) type = ChatMessageType.Radio; if (command=="r" || command=="radio" && CanUseRadio(Character.Controlled)) type = ChatMessageType.Radio;
} }
var chatMessage = ChatMessage.Create( var chatMessage = ChatMessage.Create(
@@ -243,10 +243,15 @@ namespace Barotrauma.Networking
string displayedText = message.Text; string displayedText = message.Text;
if (message.Type == ChatMessageType.Default && myCharacter != null && message.Sender != null) if (message.Sender != null)
{ {
displayedText = message.ApplyDistanceEffect(myCharacter); if (message.Type == ChatMessageType.Default && myCharacter != null)
if (string.IsNullOrWhiteSpace(displayedText)) return; {
displayedText = message.ApplyDistanceEffect(myCharacter);
if (string.IsNullOrWhiteSpace(displayedText)) return;
}
message.Sender.SpeechBubbleTimer = Math.Max(message.Sender.SpeechBubbleTimer, 2.0f);
} }
GameMain.NetLobbyScreen.NewChatMessage(message); GameMain.NetLobbyScreen.NewChatMessage(message);