MP campaign additions/fixes:
- Store tab & cargo spawning - Sub & shuttle lists and level seed box are disabled when a campaign is active. - Campaign UI is recreated if a new campaign is started while another one is active.
This commit is contained in:
@@ -142,7 +142,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private bool OnClicked(GUIComponent component, object obj)
|
private bool OnClicked(GUIComponent component, object obj)
|
||||||
{
|
{
|
||||||
if (wasOpened) return false;
|
if (wasOpened || !Enabled) return false;
|
||||||
|
|
||||||
wasOpened = true;
|
wasOpened = true;
|
||||||
Dropped = !Dropped;
|
Dropped = !Dropped;
|
||||||
|
|||||||
@@ -80,7 +80,11 @@ namespace Barotrauma
|
|||||||
public bool Enabled
|
public bool Enabled
|
||||||
{
|
{
|
||||||
get { return enabled; }
|
get { return enabled; }
|
||||||
set { enabled = value; }
|
set
|
||||||
|
{
|
||||||
|
enabled = value;
|
||||||
|
scrollBar.Enabled = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Color Color
|
public override Color Color
|
||||||
@@ -280,7 +284,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
UpdateChildrenRect(deltaTime);
|
UpdateChildrenRect(deltaTime);
|
||||||
|
|
||||||
//base.Update(deltaTime);
|
if (!enabled) return;
|
||||||
|
|
||||||
if (scrollBarEnabled && !scrollBarHidden) scrollBar.Update(deltaTime);
|
if (scrollBarEnabled && !scrollBarHidden) scrollBar.Update(deltaTime);
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,11 @@ namespace Barotrauma
|
|||||||
public bool Enabled
|
public bool Enabled
|
||||||
{
|
{
|
||||||
get { return enabled; }
|
get { return enabled; }
|
||||||
set { enabled = value; }
|
set
|
||||||
|
{
|
||||||
|
enabled = value;
|
||||||
|
bar.Enabled = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public float BarScroll
|
public float BarScroll
|
||||||
@@ -161,6 +165,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
base.Update(deltaTime);
|
base.Update(deltaTime);
|
||||||
|
|
||||||
|
if (!enabled) return;
|
||||||
|
|
||||||
if (MouseOn == frame)
|
if (MouseOn == frame)
|
||||||
{
|
{
|
||||||
if (PlayerInput.LeftButtonClicked())
|
if (PlayerInput.LeftButtonClicked())
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
@@ -39,6 +40,11 @@ namespace Barotrauma
|
|||||||
get { return selectedLevel; }
|
get { return selectedLevel; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CampaignMode Campaign
|
||||||
|
{
|
||||||
|
get { return campaign; }
|
||||||
|
}
|
||||||
|
|
||||||
private string CostTextGetter()
|
private string CostTextGetter()
|
||||||
{
|
{
|
||||||
return "Cost: " + selectedItemCost.ToString() + " credits";
|
return "Cost: " + selectedItemCost.ToString() + " credits";
|
||||||
@@ -112,13 +118,16 @@ namespace Barotrauma
|
|||||||
storeItemList = new GUIListBox(new Rectangle(0, 30, sellColumnWidth, tabs[(int)Tab.Store].Rect.Height - 80), Color.White * 0.7f, Alignment.TopRight, "", tabs[(int)Tab.Store]);
|
storeItemList = new GUIListBox(new Rectangle(0, 30, sellColumnWidth, tabs[(int)Tab.Store].Rect.Height - 80), Color.White * 0.7f, Alignment.TopRight, "", tabs[(int)Tab.Store]);
|
||||||
storeItemList.OnSelected = SelectItem;
|
storeItemList.OnSelected = SelectItem;
|
||||||
|
|
||||||
int x = selectedItemList.Rect.Width + 40;
|
int x = storeItemList.Rect.X - storeItemList.Parent.Rect.X;
|
||||||
foreach (MapEntityCategory category in Enum.GetValues(typeof(MapEntityCategory)))
|
|
||||||
{
|
|
||||||
var items = MapEntityPrefab.list.FindAll(ep => ep.Price > 0.0f && ep.Category.HasFlag(category));
|
|
||||||
if (!items.Any()) continue;
|
|
||||||
|
|
||||||
var categoryButton = new GUIButton(new Rectangle(x, 0, 100, 20), category.ToString(), "", tabs[(int)Tab.Store]);
|
List<MapEntityCategory> itemCategories = Enum.GetValues(typeof(MapEntityCategory)).Cast<MapEntityCategory>().ToList();
|
||||||
|
//don't show categories with no buyable items
|
||||||
|
itemCategories.RemoveAll(c => !MapEntityPrefab.list.Any(ep => ep.Price > 0.0f && ep.Category.HasFlag(c)));
|
||||||
|
|
||||||
|
int buttonWidth = Math.Min(sellColumnWidth / itemCategories.Count, 100);
|
||||||
|
foreach (MapEntityCategory category in itemCategories)
|
||||||
|
{
|
||||||
|
var categoryButton = new GUIButton(new Rectangle(x, 0, buttonWidth, 20), category.ToString(), "", tabs[(int)Tab.Store]);
|
||||||
categoryButton.UserData = category;
|
categoryButton.UserData = category;
|
||||||
categoryButton.OnClicked = SelectItemCategory;
|
categoryButton.OnClicked = SelectItemCategory;
|
||||||
|
|
||||||
@@ -126,7 +135,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
SelectItemCategory(categoryButton, category);
|
SelectItemCategory(categoryButton, category);
|
||||||
}
|
}
|
||||||
x += 110;
|
x += buttonWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectTab(Tab.Map);
|
SelectTab(Tab.Map);
|
||||||
@@ -294,15 +303,13 @@ namespace Barotrauma
|
|||||||
new GUITextBlock(new Rectangle(0, titleText.Rect.Height + 70, 0, 0), mission.Description, "", Alignment.TopLeft, Alignment.TopLeft, locationPanel, true, GUI.SmallFont);
|
new GUITextBlock(new Rectangle(0, titleText.Rect.Height + 70, 0, 0), mission.Description, "", Alignment.TopLeft, Alignment.TopLeft, locationPanel, true, GUI.SmallFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
startButton.Enabled = true;
|
if (startButton != null) startButton.Enabled = true;
|
||||||
|
|
||||||
selectedLevel = connection.Level;
|
selectedLevel = connection.Level;
|
||||||
|
|
||||||
OnLocationSelected?.Invoke(location, connection);
|
OnLocationSelected?.Invoke(location, connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private bool BuyItems(GUIButton button, object obj)
|
private bool BuyItems(GUIButton button, object obj)
|
||||||
{
|
{
|
||||||
int cost = selectedItemCost;
|
int cost = selectedItemCost;
|
||||||
|
|||||||
@@ -225,9 +225,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
campaignContainer = new GUIFrame(new Rectangle(0, 20, 0, 0), null, infoFrame);
|
campaignContainer = new GUIFrame(new Rectangle(0, 20, 0, 0), null, infoFrame);
|
||||||
campaignContainer.Visible = false;
|
campaignContainer.Visible = false;
|
||||||
var backButton = new GUIButton(new Rectangle(0, -20, 100, 30), "Back", "", campaignContainer);
|
|
||||||
backButton.OnClicked += (btn, obj) => { ToggleCampaignView(false); return true; };
|
|
||||||
|
|
||||||
|
|
||||||
//submarine list ------------------------------------------------------------------
|
//submarine list ------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -409,7 +406,9 @@ namespace Barotrauma
|
|||||||
|
|
||||||
InfoFrame.FindChild("showlog").Visible = GameMain.Server != null;
|
InfoFrame.FindChild("showlog").Visible = GameMain.Server != null;
|
||||||
|
|
||||||
//playerList.Parent.RemoveChild(playerList.Parent.children.Find(c => c.UserData as string == "banListButton"));
|
campaignViewButton = new GUIButton(new Rectangle(0, 0, 130, 30), "Campaign view", Alignment.BottomRight, "", defaultModeContainer);
|
||||||
|
campaignViewButton.OnClicked = (btn, obj) => { ToggleCampaignView(true); return true; };
|
||||||
|
campaignViewButton.Visible = false;
|
||||||
|
|
||||||
if (IsServer && GameMain.Server != null)
|
if (IsServer && GameMain.Server != null)
|
||||||
{
|
{
|
||||||
@@ -437,9 +436,6 @@ namespace Barotrauma
|
|||||||
StartButton = new GUIButton(new Rectangle(0, 0, 80, 30), "Start", Alignment.BottomRight, "", defaultModeContainer);
|
StartButton = new GUIButton(new Rectangle(0, 0, 80, 30), "Start", Alignment.BottomRight, "", defaultModeContainer);
|
||||||
StartButton.OnClicked = GameMain.Server.StartGameClicked;
|
StartButton.OnClicked = GameMain.Server.StartGameClicked;
|
||||||
|
|
||||||
campaignViewButton = new GUIButton(new Rectangle(0, 0, 130, 30), "Campaign view", Alignment.BottomRight, "", defaultModeContainer);
|
|
||||||
campaignViewButton.OnClicked = (btn, obj) => { ToggleCampaignView(true); return true; };
|
|
||||||
campaignViewButton.Visible = false;
|
|
||||||
|
|
||||||
GUIButton settingsButton = new GUIButton(new Rectangle(-110, 0, 80, 20), "Settings", Alignment.TopRight, "", infoFrame);
|
GUIButton settingsButton = new GUIButton(new Rectangle(-110, 0, 80, 20), "Settings", Alignment.TopRight, "", infoFrame);
|
||||||
settingsButton.OnClicked = GameMain.Server.ToggleSettingsFrame;
|
settingsButton.OnClicked = GameMain.Server.ToggleSettingsFrame;
|
||||||
@@ -1096,16 +1092,20 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public void SelectMode(int modeIndex)
|
public void SelectMode(int modeIndex)
|
||||||
{
|
{
|
||||||
if (modeIndex < 0 || modeIndex >= modeList.children.Count) return;
|
if (modeIndex < 0 || modeIndex >= modeList.children.Count || modeList.SelectedIndex == modeIndex) return;
|
||||||
|
|
||||||
if (GameMain.Server != null)
|
if (((GameModePreset)modeList.children[modeIndex].UserData).Name == "Campaign")
|
||||||
{
|
{
|
||||||
if (((GameModePreset)modeList.children[modeIndex].UserData).Name == "Campaign")
|
if (GameMain.Server != null)
|
||||||
{
|
{
|
||||||
MultiplayerCampaign.StartCampaignSetup();
|
MultiplayerCampaign.StartCampaignSetup();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ToggleCampaignMode(false);
|
||||||
|
}
|
||||||
|
|
||||||
modeList.Select(modeIndex, true);
|
modeList.Select(modeIndex, true);
|
||||||
missionTypeBlock.Visible = SelectedMode != null && SelectedMode.Name == "Mission";
|
missionTypeBlock.Visible = SelectedMode != null && SelectedMode.Name == "Mission";
|
||||||
@@ -1113,23 +1113,27 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private bool SelectMode(GUIComponent component, object obj)
|
private bool SelectMode(GUIComponent component, object obj)
|
||||||
{
|
{
|
||||||
if (GameMain.NetworkMember == null) return false;
|
if (GameMain.NetworkMember == null || obj == modeList.SelectedData) return false;
|
||||||
|
|
||||||
GameModePreset modePreset = obj as GameModePreset;
|
GameModePreset modePreset = obj as GameModePreset;
|
||||||
if (modePreset == null) return false;
|
if (modePreset == null) return false;
|
||||||
|
|
||||||
missionTypeBlock.Visible = modePreset.Name == "Mission";
|
missionTypeBlock.Visible = modePreset.Name == "Mission";
|
||||||
|
|
||||||
if (GameMain.Server != null)
|
if (modePreset.Name == "Campaign")
|
||||||
{
|
{
|
||||||
//campaign selected and the campaign view has not been set up yet
|
//campaign selected and the campaign view has not been set up yet
|
||||||
// -> don't select the mode yet and start campaign setup
|
// -> don't select the mode yet and start campaign setup
|
||||||
if (modePreset.Name == "Campaign" && !campaignContainer.Visible)
|
if (GameMain.Server != null && !campaignContainer.Visible)
|
||||||
{
|
{
|
||||||
MultiplayerCampaign.StartCampaignSetup();
|
MultiplayerCampaign.StartCampaignSetup();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ToggleCampaignMode(false);
|
||||||
|
}
|
||||||
|
|
||||||
lastUpdateID++;
|
lastUpdateID++;
|
||||||
return true;
|
return true;
|
||||||
@@ -1139,22 +1143,43 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
campaignContainer.Visible = enabled;
|
campaignContainer.Visible = enabled;
|
||||||
defaultModeContainer.Visible = !enabled;
|
defaultModeContainer.Visible = !enabled;
|
||||||
if (StartButton != null)
|
|
||||||
{
|
|
||||||
StartButton.Visible = !enabled;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ToggleCampaignMode(bool enabled)
|
public void ToggleCampaignMode(bool enabled)
|
||||||
{
|
{
|
||||||
ToggleCampaignView(enabled);
|
ToggleCampaignView(enabled);
|
||||||
|
|
||||||
|
subList.Enabled = !enabled;
|
||||||
|
shuttleList.Enabled = !enabled;
|
||||||
|
seedBox.Enabled = !enabled;
|
||||||
|
|
||||||
|
if (campaignViewButton != null) campaignViewButton.Visible = enabled;
|
||||||
|
if (StartButton != null) StartButton.Visible = !enabled;
|
||||||
|
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
if (campaignUI == null)
|
if (campaignUI == null || campaignUI.Campaign != GameMain.GameSession.GameMode)
|
||||||
{
|
{
|
||||||
|
campaignContainer.ClearChildren();
|
||||||
|
|
||||||
campaignUI = new CampaignUI(GameMain.GameSession.GameMode as CampaignMode, campaignContainer);
|
campaignUI = new CampaignUI(GameMain.GameSession.GameMode as CampaignMode, campaignContainer);
|
||||||
campaignUI.StartRound = () => { GameMain.Server.StartGame(); };
|
campaignUI.StartRound = () => { GameMain.Server.StartGame(); };
|
||||||
|
|
||||||
|
var backButton = new GUIButton(new Rectangle(0, -20, 100, 30), "Back", "", campaignContainer);
|
||||||
|
backButton.OnClicked += (btn, obj) => { ToggleCampaignView(false); return true; };
|
||||||
|
|
||||||
|
int buttonX = backButton.Rect.Width + 50;
|
||||||
|
List<CampaignUI.Tab> tabTypes = new List<CampaignUI.Tab>() { CampaignUI.Tab.Map, CampaignUI.Tab.Store };
|
||||||
|
foreach (CampaignUI.Tab tab in tabTypes)
|
||||||
|
{
|
||||||
|
var tabButton = new GUIButton(new Rectangle(buttonX, -10, 100, 20), tab.ToString(), "", campaignContainer);
|
||||||
|
tabButton.OnClicked += (btn, obj) =>
|
||||||
|
{
|
||||||
|
campaignUI.SelectTab(tab);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
buttonX += 110;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
modeList.Select(2, true);
|
modeList.Select(2, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
WayPoint wp = WayPoint.GetRandom(SpawnType.Cargo, null, Submarine.MainSub);
|
WayPoint wp = WayPoint.GetRandom(SpawnType.Cargo, null, Submarine.MainSub);
|
||||||
|
|
||||||
if (wp==null)
|
if (wp == null)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("The submarine must have a waypoint marked as Cargo for bought items to be placed correctly!");
|
DebugConsole.ThrowError("The submarine must have a waypoint marked as Cargo for bought items to be placed correctly!");
|
||||||
return;
|
return;
|
||||||
@@ -41,7 +41,15 @@ namespace Barotrauma
|
|||||||
Rand.Range(cargoRoom.Rect.X + 20, cargoRoom.Rect.Right - 20),
|
Rand.Range(cargoRoom.Rect.X + 20, cargoRoom.Rect.Right - 20),
|
||||||
cargoRoom.Rect.Y - cargoRoom.Rect.Height + prefab.Size.Y/2);
|
cargoRoom.Rect.Y - cargoRoom.Rect.Height + prefab.Size.Y/2);
|
||||||
|
|
||||||
new Item(prefab, position, wp.Submarine);
|
if (GameMain.Server != null)
|
||||||
|
{
|
||||||
|
Entity.Spawner.AddToSpawnQueue(prefab, position, wp.Submarine);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
new Item(prefab, position, wp.Submarine);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
purchasedItems.Clear();
|
purchasedItems.Clear();
|
||||||
|
|||||||
@@ -112,6 +112,11 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
base.Start();
|
base.Start();
|
||||||
|
|
||||||
|
if (GameMain.Server != null)
|
||||||
|
{
|
||||||
|
CargoManager.CreateItems();
|
||||||
|
}
|
||||||
|
|
||||||
lastUpdateID++;
|
lastUpdateID++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -197,21 +197,16 @@ namespace Barotrauma
|
|||||||
submarine.SetPosition(submarine.FindSpawnPos(level.StartPosition - new Vector2(0.0f, 2000.0f)));
|
submarine.SetPosition(submarine.FindSpawnPos(level.StartPosition - new Vector2(0.0f, 2000.0f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameMode.Mission != null)
|
Entity.Spawner = new EntitySpawner();
|
||||||
{
|
|
||||||
currentMission = GameMode.Mission;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameMode!=null) GameMode.Start();
|
|
||||||
|
|
||||||
|
if (GameMode.Mission != null) currentMission = GameMode.Mission;
|
||||||
|
if (GameMode != null) GameMode.Start();
|
||||||
if (GameMode.Mission != null) Mission.Start(Level.Loaded);
|
if (GameMode.Mission != null) Mission.Start(Level.Loaded);
|
||||||
|
|
||||||
EventManager.StartRound(level);
|
EventManager.StartRound(level);
|
||||||
|
|
||||||
if (GameMode != null) GameMode.MsgBox();
|
if (GameMode != null) GameMode.MsgBox();
|
||||||
|
|
||||||
Entity.Spawner = new EntitySpawner();
|
|
||||||
|
|
||||||
#if CLIENT
|
#if CLIENT
|
||||||
roundSummary = new RoundSummary(this);
|
roundSummary = new RoundSummary(this);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user