- option to select which location autopilot navigates towards

- generating "dummy locations" for the MP gamesessions (visible in sonar and mission descriptions)
- EndGame network message tells the clients if the mission was successful (because the message may arrive before the sub has reached the exit or before some character has died at the client's end)
This commit is contained in:
Regalis
2016-10-26 19:22:40 +03:00
parent 182cfb3451
commit 980f8e0d33
10 changed files with 184 additions and 61 deletions
+46 -6
View File
@@ -13,6 +13,9 @@ namespace Barotrauma
public readonly GameMode gameMode;
//two locations used as the start and end in the MP mode
private Location[] dummyLocations;
private InfoFrameTab selectedTab;
private GUIButton infoButton;
private GUIFrame infoFrame;
@@ -50,7 +53,37 @@ namespace Barotrauma
return (mode == null) ? null : mode.Map;
}
}
public Location StartLocation
{
get
{
if (Map != null) return Map.CurrentLocation;
if (dummyLocations==null)
{
CreateDummyLocations();
}
return dummyLocations[0];
}
}
public Location EndLocation
{
get
{
if (Map != null) return Map.SelectedLocation;
if (dummyLocations == null)
{
CreateDummyLocations();
}
return dummyLocations[1];
}
}
public Submarine Submarine
{
get { return submarine; }
@@ -79,12 +112,10 @@ namespace Barotrauma
this.saveFile = saveFile;
//guiRoot = new GUIFrame(new Rectangle(0,0,GameMain.GraphicsWidth,GameMain.GraphicsWidth), Color.Transparent);
infoButton = new GUIButton(new Rectangle(10, 10, 100, 20), "Info", GUI.Style, null);
infoButton.OnClicked = ToggleInfoFrame;
if (gameModePreset!=null) gameMode = gameModePreset.Instantiate(missionType);
if (gameModePreset != null) gameMode = gameModePreset.Instantiate(missionType);
this.submarine = submarine;
}
@@ -107,6 +138,17 @@ namespace Barotrauma
}
}
private void CreateDummyLocations()
{
dummyLocations = new Location[2];
MTRandom rand = new MTRandom(ToolBox.StringToInt(GameMain.NetLobbyScreen.LevelSeed));
for (int i = 0; i < 2; i++)
{
dummyLocations[i] = Location.CreateRandom(new Vector2((float)rand.NextDouble() * 10000.0f, (float)rand.NextDouble() * 10000.0f));
}
}
public void StartShift(string levelSeed, bool loadSecondSub = true)
{
Level level = Level.CreateRandom(levelSeed);
@@ -164,8 +206,6 @@ namespace Barotrauma
if (gameMode!=null) gameMode.Start();
Items.Components.Radar.StartMarker = "Start";
Items.Components.Radar.EndMarker = "End";
if (gameMode.Mission != null) Mission.Start(Level.Loaded);
TaskManager.StartShift(level);