A "suicide button" which can be used if the character is unconscious and the player doesn't want to wait for help, fixed submarine staying loaded when clicking the "load previous" button mid-round, main path waypoint generation bugfix

This commit is contained in:
Regalis
2016-04-20 17:22:22 +03:00
parent e33f30dad1
commit 188220c464
4 changed files with 80 additions and 26 deletions

View File

@@ -14,6 +14,8 @@ namespace Barotrauma
private static GUIButton cprButton;
private static GUIButton suicideButton;
private static GUIProgressBar drowningBar, healthBar;
private static float damageOverlayTimer;
@@ -36,6 +38,8 @@ namespace Barotrauma
if (cprButton != null && cprButton.Visible) cprButton.Update(deltaTime);
if (GameMain.NetworkMember != null && suicideButton != null && suicideButton.Visible) suicideButton.Update(deltaTime);
if (damageOverlayTimer > 0.0f) damageOverlayTimer -= deltaTime;
}
@@ -144,8 +148,6 @@ namespace Barotrauma
}
}
if (Screen.Selected == GameMain.EditMapScreen) return;
if (character.IsUnconscious || (character.Oxygen < 80.0f && !character.IsDead))
@@ -159,6 +161,11 @@ namespace Barotrauma
noiseOverlay.DrawTiled(spriteBatch, Vector2.Zero - offset, new Vector2(GameMain.GraphicsWidth, GameMain.GraphicsHeight) + offset,
Vector2.Zero,
Color.White * alpha);
}
else
{
if (suicideButton != null) suicideButton.Visible = false;
}
if (damageOverlayTimer>0.0f)
@@ -166,6 +173,26 @@ namespace Barotrauma
damageOverlay.Draw(spriteBatch, Vector2.Zero, Color.White * damageOverlayTimer, Vector2.Zero, 0.0f,
new Vector2(GameMain.GraphicsWidth / damageOverlay.size.X, GameMain.GraphicsHeight / damageOverlay.size.Y));
}
if (character.IsUnconscious && GameMain.NetworkMember!=null)
{
if (suicideButton == null)
{
suicideButton = new GUIButton(
new Rectangle(new Point(GameMain.GraphicsWidth / 2 - 60, 20), new Point(120, 20)), "Give in", GUI.Style);
suicideButton.ToolTip = "Let go of your character and enter spectator mode (other players will now longer be able to revive you)";
suicideButton.OnClicked = (button, userData) =>
{
character.Kill(character.CauseOfDeath);
return true;
};
}
suicideButton.Visible = true;
suicideButton.Draw(spriteBatch);
}
}
private static void DrawStatusIcons(SpriteBatch spriteBatch, Character character)

View File

@@ -188,6 +188,8 @@ namespace Barotrauma
public bool LoadPrevious(GUIButton button, object obj)
{
Submarine.Unload();
SaveUtil.LoadGame(saveFile);
GameMain.LobbyScreen.Select();

View File

@@ -75,8 +75,8 @@ namespace Barotrauma
character.Info.Job != null ? (character.Info.Name + '\n' + "(" + character.Info.Job.Name + ")") : character.Info.Name, null);
string statusText;
Color statusColor;
string statusText = "OK";
Color statusColor = Color.DarkGreen;
if (character.IsDead)
{
@@ -85,8 +85,18 @@ namespace Barotrauma
}
else
{
statusText = (character.Health / character.MaxHealth > 0.8f) ? "OK" : "Injured";
statusColor = (character.Health / character.MaxHealth > 0.8f) ? Color.DarkGreen : Color.DarkOrange;
if (character.IsUnconscious)
{
statusText = "Unconscious";
statusColor = Color.DarkOrange;
}
else if (character.Health / character.MaxHealth < 0.8f)
{
statusText = "Injured";
statusColor = Color.DarkOrange;
}
}
new GUITextBlock(new Rectangle(0, 0, 0, 20), statusText,

View File

@@ -359,9 +359,9 @@ namespace Barotrauma
pathCells.AddRange(cavePathCells);
for (int j = cavePathCells.Count / 2; j < cavePathCells.Count; j+=10)
for (int j = cavePathCells.Count / 2; j < cavePathCells.Count; j += 10)
{
positionsOfInterest.Add(new InterestingPosition(cavePathCells[i].Center, false));
positionsOfInterest.Add(new InterestingPosition(cavePathCells[j].Center, false));
}
}
@@ -423,12 +423,12 @@ namespace Barotrauma
ShaftBodies = new Body[2];
for (int i = 0; i < 2; i++)
{
ShaftBodies[i] = BodyFactory.CreateRectangle(GameMain.World, 100.0f, 10.0f, 5.0f);
ShaftBodies[i] = BodyFactory.CreateRectangle(GameMain.World, 200.0f, 10.0f, 5.0f);
ShaftBodies[i].BodyType = BodyType.Static;
ShaftBodies[i].CollisionCategories = Physics.CollisionLevel;
Vector2 shaftPos = (i == 0) ? startPosition : endPosition;
shaftPos.Y = borders.Height;
shaftPos.Y = borders.Height + 150.0f;
ShaftBodies[i].SetTransform(ConvertUnits.ToSimUnits(shaftPos), 0.0f);
bodies.Add(ShaftBodies[i]);
@@ -489,39 +489,54 @@ namespace Barotrauma
private void EnlargeMainPath(List<VoronoiCell> pathCells, float minWidth)
{
List<WayPoint> wayPoints = new List<WayPoint>();
WayPoint newWaypoint = new WayPoint(new Rectangle((int)pathCells[0].Center.X, (int)(borders.Height + shaftHeight), 10, 10), null);
var newWaypoint = new WayPoint(new Rectangle((int)pathCells[0].Center.X, (int)(borders.Height + shaftHeight), 10, 10), null);
newWaypoint.MoveWithLevel = true;
wayPoints.Add(newWaypoint);
WayPoint prevWaypoint = newWaypoint;
//WayPoint prevWaypoint = newWaypoint;
for (int i = 0; i < pathCells.Count; i++)
{
//clean "loops" from the path
for (int n = 0; n < i; n++)
{
if (pathCells[n] != pathCells[i]) continue;
////clean "loops" from the path
//for (int n = 0; n < i; n++)
//{
// if (pathCells[n] != pathCells[i]) continue;
pathCells.RemoveRange(n + 1, i - n);
break;
}
if (i >= pathCells.Count) break;
// pathCells.RemoveRange(n + 1, i - n);
// break;
//}
//if (i >= pathCells.Count) break;
pathCells[i].CellType = CellType.Path;
newWaypoint = new WayPoint(new Rectangle((int)pathCells[i].Center.X, (int)pathCells[i].Center.Y, 10, 10), null);
newWaypoint.MoveWithLevel = true;
if (prevWaypoint != null)
wayPoints.Add(newWaypoint);
wayPoints[wayPoints.Count-2].linkedTo.Add(newWaypoint);
newWaypoint.linkedTo.Add(wayPoints[wayPoints.Count - 2]);
for (int n = 0; n < wayPoints.Count; n++)
{
prevWaypoint.linkedTo.Add(newWaypoint);
newWaypoint.linkedTo.Add(prevWaypoint);
if (wayPoints[n].Position != newWaypoint.Position) continue;
wayPoints[n].linkedTo.Add(newWaypoint);
newWaypoint.linkedTo.Add(wayPoints[n]);
break;
}
prevWaypoint = newWaypoint;
//prevWaypoint = newWaypoint;
}
newWaypoint = new WayPoint(new Rectangle((int)pathCells[pathCells.Count - 1].Center.X, (int)(borders.Height + shaftHeight), 10, 10), null);
newWaypoint.MoveWithLevel = true;
wayPoints.Add(newWaypoint);
prevWaypoint.linkedTo.Add(newWaypoint);
newWaypoint.linkedTo.Add(prevWaypoint);
wayPoints[wayPoints.Count - 2].linkedTo.Add(newWaypoint);
newWaypoint.linkedTo.Add(wayPoints[wayPoints.Count - 2]);
if (minWidth > 0.0f)
{