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

View File

@@ -240,7 +240,7 @@ namespace Barotrauma
break;
case "near":
case "close":
float closestDist = 0.0f;
float closestDist = -1.0f;
foreach (WayPoint wp in WayPoint.WayPointList)
{
if (wp.Submarine != null) continue;
@@ -250,25 +250,27 @@ namespace Barotrauma
float dist = Vector2.Distance(wp.WorldPosition, GameMain.GameScreen.Cam.WorldViewCenter);
if (spawnPoint == null || dist < closestDist)
if (closestDist < 0.0f || dist < closestDist)
{
spawnPoint = wp;
closestDist = dist;
}
}
break;
case "cursor":
spawnPosition = GameMain.GameScreen.Cam.ScreenToWorld(PlayerInput.MousePosition);
break;
default:
spawnPoint = WayPoint.GetRandom(commands[1].ToLowerInvariant()=="human" ? SpawnType.Human : SpawnType.Enemy);
spawnPoint = WayPoint.GetRandom(commands[1].ToLowerInvariant() == "human" ? SpawnType.Human : SpawnType.Enemy);
break;
}
}
else
{
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")
{

View File

@@ -164,15 +164,6 @@ namespace Barotrauma
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)
{
crews[0].Add(character);
@@ -209,7 +200,7 @@ namespace Barotrauma
}
else
{
if (subs[winner] != null &&
if (winner>=0 && subs[winner] != null &&
(winner == 0 && subs[winner].AtStartPosition) || (winner == 1 && subs[winner].AtEndPosition) &&
crews[winner].Any(c => !c.IsDead && c.Submarine == subs[winner]))
{
@@ -220,6 +211,8 @@ namespace Barotrauma
if (teamDead[0] && teamDead[1])
{
GameMain.GameSession.CrewManager.WinningTeam = 0;
winner = -1;
if (GameMain.Server != null) GameMain.Server.EndGame();
}
}

View File

@@ -75,6 +75,8 @@ namespace Barotrauma
isRunning = true;
}
public virtual void MsgBox() { }
public virtual void Update(float deltaTime)
{
//if (!isRunning) return;

View File

@@ -29,10 +29,8 @@ namespace Barotrauma
mission = Mission.LoadRandom(locations, rand, param as string);
}
public override void Start()
public override void MsgBox()
{
base.Start();
if (mission == null) return;
var missionMsg = new GUIMessageBox(mission.Name, mission.Description, 400, 400);

View File

@@ -170,6 +170,8 @@ namespace Barotrauma
TaskManager.StartShift(level);
if (gameMode != null) gameMode.MsgBox();
GameMain.GameScreen.ColorFade(Color.Black, Color.TransparentBlack, 5.0f);
SoundPlayer.SwitchMusic();
}

View File

@@ -119,6 +119,7 @@ namespace Barotrauma
message.Write(items[i].Position.X);
message.Write(items[i].Position.Y);
message.Write(items[i].Submarine != null ? items[i].Submarine.ID : (ushort)0);
}
else
{
@@ -144,6 +145,7 @@ namespace Barotrauma
ushort itemId = message.ReadUInt16();
Vector2 pos = Vector2.Zero;
Submarine sub = null;
ushort inventoryId = message.ReadUInt16();
int inventorySlotIndex = -1;
@@ -155,13 +157,18 @@ namespace Barotrauma
else
{
pos = new Vector2(message.ReadSingle(), message.ReadSingle());
ushort subID = message.ReadUInt16();
if (subID > 0)
{
sub = Submarine.Loaded.Find(s => s.ID == subID);
}
}
string tags = "";
if (itemName == "ID Card")
{
tags = message.ReadString();
}
}
var prefab = MapEntityPrefab.list.Find(me => me.Name == itemName);
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.CurrentHull = Hull.FindHull(pos, null, false);
item.Submarine = item.CurrentHull == null ? null : item.CurrentHull.Submarine;
if (sub != null)
{
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;

View File

@@ -950,8 +950,7 @@ namespace Barotrauma.Networking
teamClients[i].Character.TeamID = (byte)teamID;
}
//host plays in team 1
if (characterInfo != null && teamID == hostTeam)
{
myCharacter = Character.Create(characterInfo, assignedWayPoints[assignedWayPoints.Length - 1].WorldPosition, false, false);