Merge branch 'combat-mission'

This commit is contained in:
Regalis
2016-10-11 16:35:43 +03:00
7 changed files with 30 additions and 24 deletions
+7 -5
View File
@@ -240,7 +240,7 @@ namespace Barotrauma
break; break;
case "near": case "near":
case "close": case "close":
float closestDist = 0.0f; float closestDist = -1.0f;
foreach (WayPoint wp in WayPoint.WayPointList) foreach (WayPoint wp in WayPoint.WayPointList)
{ {
if (wp.Submarine != null) continue; if (wp.Submarine != null) continue;
@@ -250,25 +250,27 @@ namespace Barotrauma
float dist = Vector2.Distance(wp.WorldPosition, GameMain.GameScreen.Cam.WorldViewCenter); float dist = Vector2.Distance(wp.WorldPosition, GameMain.GameScreen.Cam.WorldViewCenter);
if (spawnPoint == null || dist < closestDist) if (closestDist < 0.0f || dist < closestDist)
{ {
spawnPoint = wp; spawnPoint = wp;
closestDist = dist; closestDist = dist;
} }
} }
break; break;
case "cursor":
spawnPosition = GameMain.GameScreen.Cam.ScreenToWorld(PlayerInput.MousePosition);
break;
default: default:
spawnPoint = WayPoint.GetRandom(commands[1].ToLowerInvariant()=="human" ? SpawnType.Human : SpawnType.Enemy); spawnPoint = WayPoint.GetRandom(commands[1].ToLowerInvariant() == "human" ? SpawnType.Human : SpawnType.Enemy);
break; break;
} }
} }
else else
{ {
spawnPoint = WayPoint.GetRandom(commands[1].ToLowerInvariant() == "human" ? SpawnType.Human : SpawnType.Enemy); spawnPoint = WayPoint.GetRandom(commands[1].ToLowerInvariant() == "human" ? SpawnType.Human : SpawnType.Enemy);
} }
spawnPosition = spawnPoint == null ? Vector2.Zero : spawnPoint.WorldPosition; if (spawnPoint != null) spawnPosition = spawnPoint.WorldPosition;
if (commands[1].ToLowerInvariant()=="human") if (commands[1].ToLowerInvariant()=="human")
{ {
@@ -164,15 +164,6 @@ namespace Barotrauma
foreach (Character character in Character.CharacterList) foreach (Character character in Character.CharacterList)
{ {
if (GameMain.NetworkMember != null && character == GameMain.NetworkMember.Character)
{
//ugly hack to switch the text in the mission popup to the team-specific description
if (GUIMessageBox.MessageBoxes.Count > 0 && GUIMessageBox.MessageBoxes.Peek().UserData as string == "missionstartmessage")
{
(GUIMessageBox.MessageBoxes.Peek() as GUIMessageBox).Text = Description;
}
}
if (character.TeamID == 1) if (character.TeamID == 1)
{ {
crews[0].Add(character); crews[0].Add(character);
@@ -209,7 +200,7 @@ namespace Barotrauma
} }
else else
{ {
if (subs[winner] != null && if (winner>=0 && subs[winner] != null &&
(winner == 0 && subs[winner].AtStartPosition) || (winner == 1 && subs[winner].AtEndPosition) && (winner == 0 && subs[winner].AtStartPosition) || (winner == 1 && subs[winner].AtEndPosition) &&
crews[winner].Any(c => !c.IsDead && c.Submarine == subs[winner])) crews[winner].Any(c => !c.IsDead && c.Submarine == subs[winner]))
{ {
@@ -220,6 +211,8 @@ namespace Barotrauma
if (teamDead[0] && teamDead[1]) if (teamDead[0] && teamDead[1])
{ {
GameMain.GameSession.CrewManager.WinningTeam = 0;
winner = -1;
if (GameMain.Server != null) GameMain.Server.EndGame(); if (GameMain.Server != null) GameMain.Server.EndGame();
} }
} }
@@ -75,6 +75,8 @@ namespace Barotrauma
isRunning = true; isRunning = true;
} }
public virtual void MsgBox() { }
public virtual void Update(float deltaTime) public virtual void Update(float deltaTime)
{ {
//if (!isRunning) return; //if (!isRunning) return;
@@ -29,10 +29,8 @@ namespace Barotrauma
mission = Mission.LoadRandom(locations, rand, param as string); mission = Mission.LoadRandom(locations, rand, param as string);
} }
public override void Start() public override void MsgBox()
{ {
base.Start();
if (mission == null) return; if (mission == null) return;
var missionMsg = new GUIMessageBox(mission.Name, mission.Description, 400, 400); var missionMsg = new GUIMessageBox(mission.Name, mission.Description, 400, 400);
@@ -170,6 +170,8 @@ namespace Barotrauma
TaskManager.StartShift(level); TaskManager.StartShift(level);
if (gameMode != null) gameMode.MsgBox();
GameMain.GameScreen.ColorFade(Color.Black, Color.TransparentBlack, 5.0f); GameMain.GameScreen.ColorFade(Color.Black, Color.TransparentBlack, 5.0f);
SoundPlayer.SwitchMusic(); SoundPlayer.SwitchMusic();
} }
+14 -4
View File
@@ -119,6 +119,7 @@ namespace Barotrauma
message.Write(items[i].Position.X); message.Write(items[i].Position.X);
message.Write(items[i].Position.Y); message.Write(items[i].Position.Y);
message.Write(items[i].Submarine != null ? items[i].Submarine.ID : (ushort)0);
} }
else else
{ {
@@ -144,6 +145,7 @@ namespace Barotrauma
ushort itemId = message.ReadUInt16(); ushort itemId = message.ReadUInt16();
Vector2 pos = Vector2.Zero; Vector2 pos = Vector2.Zero;
Submarine sub = null;
ushort inventoryId = message.ReadUInt16(); ushort inventoryId = message.ReadUInt16();
int inventorySlotIndex = -1; int inventorySlotIndex = -1;
@@ -155,13 +157,18 @@ namespace Barotrauma
else else
{ {
pos = new Vector2(message.ReadSingle(), message.ReadSingle()); pos = new Vector2(message.ReadSingle(), message.ReadSingle());
ushort subID = message.ReadUInt16();
if (subID > 0)
{
sub = Submarine.Loaded.Find(s => s.ID == subID);
}
} }
string tags = ""; string tags = "";
if (itemName == "ID Card") if (itemName == "ID Card")
{ {
tags = message.ReadString(); tags = message.ReadString();
} }
var prefab = MapEntityPrefab.list.Find(me => me.Name == itemName); var prefab = MapEntityPrefab.list.Find(me => me.Name == itemName);
if (prefab == null) continue; if (prefab == null) continue;
@@ -188,11 +195,14 @@ namespace Barotrauma
} }
} }
var item = new Item(itemPrefab, pos, null); var item = new Item(itemPrefab, pos, sub);
item.ID = itemId; item.ID = itemId;
item.CurrentHull = Hull.FindHull(pos, null, false); if (sub != null)
item.Submarine = item.CurrentHull == null ? null : item.CurrentHull.Submarine; {
item.CurrentHull = Hull.FindHull(pos + sub.Position, null, true);
item.Submarine = item.CurrentHull == null ? null : item.CurrentHull.Submarine;
}
if (!string.IsNullOrEmpty(tags)) item.Tags = tags; if (!string.IsNullOrEmpty(tags)) item.Tags = tags;
+1 -2
View File
@@ -950,8 +950,7 @@ namespace Barotrauma.Networking
teamClients[i].Character.TeamID = (byte)teamID; teamClients[i].Character.TeamID = (byte)teamID;
} }
//host plays in team 1
if (characterInfo != null && teamID == hostTeam) if (characterInfo != null && teamID == hostTeam)
{ {
myCharacter = Character.Create(characterInfo, assignedWayPoints[assignedWayPoints.Length - 1].WorldPosition, false, false); myCharacter = Character.Create(characterInfo, assignedWayPoints[assignedWayPoints.Length - 1].WorldPosition, false, false);