Location hire
This commit is contained in:
@@ -81,6 +81,11 @@ namespace Subsurface
|
||||
}
|
||||
}
|
||||
|
||||
public static JobPrefab Random()
|
||||
{
|
||||
return List[Rand.Int(List.Count)];
|
||||
}
|
||||
|
||||
private void LoadSkills(XElement element)
|
||||
{
|
||||
foreach (XElement subElement in element.Elements())
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
</None>
|
||||
|
||||
<City
|
||||
commonness="3">
|
||||
commonness="3"
|
||||
hireablecharacters="true">
|
||||
<nameformats
|
||||
f0="The City of [name]"
|
||||
f1="[name] City"
|
||||
@@ -18,7 +19,8 @@
|
||||
</City>
|
||||
|
||||
<Military
|
||||
commonness="1">
|
||||
commonness="1"
|
||||
hireablecharacters="true">
|
||||
<nameformats
|
||||
f0="[name] Outpost"
|
||||
f1="[name] Facility"
|
||||
@@ -27,7 +29,8 @@
|
||||
</Military>
|
||||
|
||||
<Research
|
||||
commonness="1">
|
||||
commonness="1"
|
||||
hireablecharacters="true">
|
||||
<nameformats
|
||||
f0="[name] Research Facility"
|
||||
f1="[name] Research Center"
|
||||
|
||||
@@ -159,8 +159,10 @@ namespace Subsurface
|
||||
private float loadState = 0.0f;
|
||||
private IEnumerable<Status> Load()
|
||||
{
|
||||
GUI.Font = Content.Load<SpriteFont>("SpriteFont1");
|
||||
GUI.SmallFont = Content.Load<SpriteFont>("SmallFont");
|
||||
GUI.Font = ToolBox.TryLoadFont("SpriteFont1", Content);
|
||||
GUI.SmallFont = ToolBox.TryLoadFont("SmallFont", Content);
|
||||
|
||||
sw = new Stopwatch();
|
||||
|
||||
LightManager = new Lights.LightManager(GraphicsDevice);
|
||||
|
||||
@@ -246,7 +248,7 @@ namespace Subsurface
|
||||
double deltaTime = gameTime.ElapsedGameTime.TotalSeconds;
|
||||
PlayerInput.Update(deltaTime);
|
||||
|
||||
if (loadState>=100.0f && !titleScreenOpen)
|
||||
if (loadState >= 100.0f && !titleScreenOpen)
|
||||
{
|
||||
//if (PlayerInput.KeyDown(Keys.Escape)) Quit();
|
||||
|
||||
@@ -289,14 +291,21 @@ namespace Subsurface
|
||||
titleScreenOpen = false;
|
||||
}
|
||||
}
|
||||
else if (loadState>=100.0f)
|
||||
else if (loadState >= 100.0f)
|
||||
{
|
||||
Screen.Selected.Draw(deltaTime, GraphicsDevice, spriteBatch);
|
||||
}
|
||||
//renderTimeElapsed = (int)renderTimer.Elapsed.Ticks;
|
||||
//renderTimer.Stop();
|
||||
if (sw.Elapsed.TotalSeconds < Physics.step)
|
||||
{
|
||||
System.Threading.Thread.Sleep((int)((Physics.step - sw.Elapsed.TotalSeconds)*1000.0));
|
||||
}
|
||||
sw.Restart();
|
||||
}
|
||||
|
||||
Stopwatch sw;
|
||||
|
||||
protected override void OnExiting(object sender, EventArgs args)
|
||||
{
|
||||
if (NetworkMember != null) NetworkMember.Disconnect();
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace Subsurface
|
||||
|
||||
public void GenerateCharacters(string file, int amount)
|
||||
{
|
||||
|
||||
for (int i = 0 ; i<amount ; i++)
|
||||
{
|
||||
availableCharacters.Add(new CharacterInfo(file));
|
||||
|
||||
@@ -10,8 +10,10 @@ namespace Subsurface
|
||||
{
|
||||
class SinglePlayerMode : GameMode
|
||||
{
|
||||
private const int StartCharacterAmount = 3;
|
||||
|
||||
public readonly CrewManager crewManager;
|
||||
public readonly HireManager hireManager;
|
||||
//public readonly HireManager hireManager;
|
||||
|
||||
private GUIButton endShiftButton;
|
||||
|
||||
@@ -29,23 +31,26 @@ namespace Subsurface
|
||||
|
||||
private bool savedOnStart;
|
||||
|
||||
public SinglePlayerMode(GameModePreset preset)
|
||||
public SinglePlayerMode(GameModePreset preset, bool generateCrew=true)
|
||||
: base(preset)
|
||||
{
|
||||
crewManager = new CrewManager();
|
||||
hireManager = new HireManager();
|
||||
|
||||
endShiftButton = new GUIButton(new Rectangle(Game1.GraphicsWidth - 220, 20, 200, 25), "End shift", Alignment.TopLeft, GUI.style);
|
||||
endShiftButton.OnClicked = EndShift;
|
||||
|
||||
hireManager.GenerateCharacters(Character.HumanConfigFile, 10);
|
||||
|
||||
for (int i = 0; i < StartCharacterAmount; i++)
|
||||
{
|
||||
CharacterInfo characterInfo =
|
||||
new CharacterInfo(Character.HumanConfigFile, "", Gender.None, JobPrefab.Random());
|
||||
crewManager.characterInfos.Add(characterInfo);
|
||||
}
|
||||
|
||||
//day = 1;
|
||||
}
|
||||
|
||||
public SinglePlayerMode(XElement element)
|
||||
: this(GameModePreset.list.Find(gm => gm.Name == "Single Player"))
|
||||
: this(GameModePreset.list.Find(gm => gm.Name == "Single Player"), false)
|
||||
{
|
||||
//day = ToolBox.GetAttributeInt(element,"day",1);
|
||||
|
||||
@@ -85,7 +90,7 @@ namespace Subsurface
|
||||
crewManager.StartShift();
|
||||
}
|
||||
|
||||
public bool TryHireCharacter(CharacterInfo characterInfo)
|
||||
public bool TryHireCharacter(HireManager hireManager, CharacterInfo characterInfo)
|
||||
{
|
||||
if (crewManager.Money < characterInfo.Salary) return false;
|
||||
|
||||
|
||||
@@ -9,13 +9,15 @@ namespace Subsurface
|
||||
|
||||
class Location
|
||||
{
|
||||
string name;
|
||||
private string name;
|
||||
|
||||
Vector2 mapPosition;
|
||||
private Vector2 mapPosition;
|
||||
|
||||
LocationType type;
|
||||
private LocationType type;
|
||||
|
||||
public List<LocationConnection> connections;
|
||||
private HireManager hireManager;
|
||||
|
||||
public List<LocationConnection> Connections;
|
||||
|
||||
public string Name
|
||||
{
|
||||
@@ -27,13 +29,32 @@ namespace Subsurface
|
||||
get { return mapPosition; }
|
||||
}
|
||||
|
||||
|
||||
public LocationType Type
|
||||
{
|
||||
get { return type; }
|
||||
}
|
||||
|
||||
public HireManager HireManager
|
||||
{
|
||||
get { return hireManager; }
|
||||
}
|
||||
|
||||
public Location(Vector2 mapPosition)
|
||||
{
|
||||
this.name = RandomName(LocationType.Random());
|
||||
this.type = LocationType.Random();
|
||||
|
||||
this.name = RandomName(type);
|
||||
|
||||
this.mapPosition = mapPosition;
|
||||
|
||||
connections = new List<LocationConnection>();
|
||||
if (type.HasHireableCharacters)
|
||||
{
|
||||
hireManager = new HireManager();
|
||||
hireManager.GenerateCharacters(Character.HumanConfigFile, 10);
|
||||
}
|
||||
|
||||
Connections = new List<LocationConnection>();
|
||||
}
|
||||
|
||||
public static Location CreateRandom(Vector2 position)
|
||||
|
||||
@@ -13,17 +13,23 @@ namespace Subsurface
|
||||
//sum of the commonness-values of each location type
|
||||
private static int totalWeight;
|
||||
|
||||
string name;
|
||||
private string name;
|
||||
|
||||
private int commonness;
|
||||
|
||||
List<string> nameFormats;
|
||||
private List<string> nameFormats;
|
||||
|
||||
public bool HasHireableCharacters
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
}
|
||||
|
||||
|
||||
public List<string> NameFormats
|
||||
{
|
||||
get { return nameFormats; }
|
||||
@@ -36,6 +42,8 @@ namespace Subsurface
|
||||
commonness = ToolBox.GetAttributeInt(element, "commonness", 1);
|
||||
totalWeight += commonness;
|
||||
|
||||
HasHireableCharacters = ToolBox.GetAttributeBool(element, "hireablecharacters", false);
|
||||
|
||||
nameFormats = new List<string>();
|
||||
foreach (XAttribute nameFormat in element.Element("nameformats").Attributes())
|
||||
{
|
||||
|
||||
@@ -145,8 +145,8 @@ namespace Subsurface
|
||||
|
||||
foreach (LocationConnection connection in connections)
|
||||
{
|
||||
connection.Locations[0].connections.Add(connection);
|
||||
connection.Locations[1].connections.Add(connection);
|
||||
connection.Locations[0].Connections.Add(connection);
|
||||
connection.Locations[1].Connections.Add(connection);
|
||||
}
|
||||
|
||||
for (int i = connections.Count - 1; i >= 0; i--)
|
||||
@@ -181,7 +181,7 @@ namespace Subsurface
|
||||
currDifficulty += Rand.Range(difficultyIncrease.X, difficultyIncrease.Y, false);
|
||||
if (currDifficulty > Rand.Range(difficultyCutoff.X, difficultyCutoff.Y, false)) currDifficulty = 10.0f;
|
||||
|
||||
foreach (LocationConnection connection in start.connections)
|
||||
foreach (LocationConnection connection in start.Connections)
|
||||
{
|
||||
if (!locations.Contains(connection)) continue;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Subsurface
|
||||
{
|
||||
class LobbyScreen : Screen
|
||||
{
|
||||
enum PanelTab { Crew = 0, Map = 1, Hire = 2 }
|
||||
enum PanelTab { Crew = 0, Map = 1, CurrentLocation = 2 }
|
||||
|
||||
GUIFrame leftPanel;
|
||||
GUIFrame[] rightPanel;
|
||||
@@ -52,8 +52,8 @@ namespace Subsurface
|
||||
button.UserData = PanelTab.Crew;
|
||||
button.OnClicked = SelectRightPanel;
|
||||
|
||||
button = new GUIButton(new Rectangle(0, 140, 100, 30), "Hire", null, Alignment.Left, GUI.style, leftPanel);
|
||||
button.UserData = PanelTab.Hire;
|
||||
button = new GUIButton(new Rectangle(0, 140, 100, 30), "Location", null, Alignment.Left, GUI.style, leftPanel);
|
||||
button.UserData = PanelTab.CurrentLocation;
|
||||
button.OnClicked = SelectRightPanel;
|
||||
|
||||
//---------------------------------------------------------------
|
||||
@@ -87,11 +87,15 @@ namespace Subsurface
|
||||
|
||||
//---------------------------------------
|
||||
|
||||
rightPanel[(int)PanelTab.Hire] = new GUIFrame(panelRect, GUI.style);
|
||||
rightPanel[(int)PanelTab.CurrentLocation] = new GUIFrame(panelRect, GUI.style);
|
||||
//rightPanel[(int)PanelTab.Hire].Padding = GUI.style.smallPadding;
|
||||
|
||||
hireList = new GUIListBox(new Rectangle(0, 30, 300, 0), GUI.style, Alignment.Left, rightPanel[(int)PanelTab.Hire]);
|
||||
hireList.OnSelected = HireCharacter;
|
||||
|
||||
//new GUITextBlock(new Rectangle(0, 0, 200, 25), "Location: ", Color.Transparent, Color.White, Alignment.Left, GUI.style, rightPanel[(int)PanelTab.CurrentLocation]);
|
||||
|
||||
|
||||
//hireList = new GUIListBox(new Rectangle(0, 30, 300, 0), GUI.style, Alignment.Left, rightPanel[(int)PanelTab.CurrentLocation]);
|
||||
//hireList.OnSelected = HireCharacter;
|
||||
}
|
||||
|
||||
public override void Select()
|
||||
@@ -105,6 +109,45 @@ namespace Subsurface
|
||||
UpdateCharacterLists();
|
||||
}
|
||||
|
||||
private void UpdateLocationTab(Location location)
|
||||
{
|
||||
rightPanel[(int)PanelTab.CurrentLocation] = new GUIFrame(rightPanel[(int)PanelTab.CurrentLocation].Rect, GUI.style);
|
||||
rightPanel[(int)PanelTab.CurrentLocation].UserData = location;
|
||||
//rightPanel[(int)PanelTab.Hire].Padding = GUI.style.smallPadding;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 0, 200, 25),
|
||||
"Location: "+location.Name, GUI.style, rightPanel[(int)PanelTab.CurrentLocation]);
|
||||
new GUITextBlock(new Rectangle(0, 0, 200, 25),
|
||||
"("+location.Type+")", GUI.style, rightPanel[(int)PanelTab.CurrentLocation]);
|
||||
|
||||
if (location.HireManager != null)
|
||||
{
|
||||
hireList = new GUIListBox(new Rectangle(0, 30, 300, 0), GUI.style, Alignment.Left, rightPanel[(int)PanelTab.CurrentLocation]);
|
||||
hireList.OnSelected = HireCharacter;
|
||||
|
||||
hireList.ClearChildren();
|
||||
foreach (CharacterInfo c in location.HireManager.availableCharacters)
|
||||
{
|
||||
//GUIFrame frame = new GUIFrame(
|
||||
// new Rectangle(0, 0, 0, 25), Color.Transparent, null, hireList);
|
||||
//frame.UserData = c;
|
||||
//frame.Padding = new Vector4(10.0f, 0.0f, 10.0f, 0.0f);
|
||||
|
||||
GUITextBlock textBlock = new GUITextBlock(
|
||||
new Rectangle(0, 0, 0, 25),
|
||||
c.Name + " (" + c.Job.Name + ")", GUI.style, hireList);
|
||||
textBlock.UserData = c;
|
||||
|
||||
textBlock = new GUITextBlock(
|
||||
new Rectangle(0, 0, 0, 25),
|
||||
c.Salary.ToString(),
|
||||
null, null,
|
||||
Alignment.TopRight, GUI.style, textBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void Deselect()
|
||||
{
|
||||
base.Deselect();
|
||||
@@ -192,25 +235,6 @@ namespace Subsurface
|
||||
textBlock.UserData = c;
|
||||
}
|
||||
|
||||
hireList.ClearChildren();
|
||||
foreach (CharacterInfo c in gameMode.hireManager.availableCharacters)
|
||||
{
|
||||
//GUIFrame frame = new GUIFrame(
|
||||
// new Rectangle(0, 0, 0, 25), Color.Transparent, null, hireList);
|
||||
//frame.UserData = c;
|
||||
//frame.Padding = new Vector4(10.0f, 0.0f, 10.0f, 0.0f);
|
||||
|
||||
GUITextBlock textBlock = new GUITextBlock(
|
||||
new Rectangle(0, 0, 0, 25),
|
||||
c.Name + " (" + c.Job.Name + ")", GUI.style, hireList);
|
||||
textBlock.UserData = c;
|
||||
|
||||
textBlock = new GUITextBlock(
|
||||
new Rectangle(0, 0, 0, 25),
|
||||
c.Salary.ToString(),
|
||||
null, null,
|
||||
Alignment.TopRight, GUI.style, textBlock);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
@@ -225,8 +249,7 @@ namespace Subsurface
|
||||
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
|
||||
{
|
||||
|
||||
if (characterList.CountChildren != gameMode.crewManager.characterInfos.Count
|
||||
|| hireList.CountChildren != gameMode.hireManager.availableCharacters.Count)
|
||||
if (characterList.CountChildren != gameMode.crewManager.characterInfos.Count)
|
||||
{
|
||||
UpdateCharacterLists();
|
||||
}
|
||||
@@ -247,7 +270,12 @@ namespace Subsurface
|
||||
rightPanel[selectedRightPanel].Rect.Right - 20 - 400,
|
||||
rightPanel[selectedRightPanel].Rect.Y + 20,
|
||||
400, 400));
|
||||
}
|
||||
}
|
||||
|
||||
if (rightPanel[(int)selectedRightPanel].UserData as Location != Game1.GameSession.Map.CurrentLocation)
|
||||
{
|
||||
UpdateLocationTab(Game1.GameSession.Map.CurrentLocation);
|
||||
}
|
||||
|
||||
GUI.Draw((float)deltaTime, spriteBatch, null);
|
||||
|
||||
@@ -350,7 +378,7 @@ namespace Subsurface
|
||||
CharacterInfo characterInfo = selection as CharacterInfo;
|
||||
if (characterInfo == null) return false;
|
||||
|
||||
gameMode.TryHireCharacter(characterInfo);
|
||||
gameMode.TryHireCharacter(Game1.GameSession.Map.CurrentLocation.HireManager, characterInfo);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@
|
||||
<Compile Include="Screens\NetLobbyScreen.cs" />
|
||||
<Compile Include="Screens\SettingsScreen.cs" />
|
||||
<Compile Include="Screens\Screen.cs" />
|
||||
<Compile Include="Settings.cs" />
|
||||
<Compile Include="GameSettings.cs" />
|
||||
<Compile Include="Sounds\OggSound.cs" />
|
||||
<Compile Include="Sounds\SoundManager.cs" />
|
||||
<Compile Include="Sounds\OggStream.cs" />
|
||||
|
||||
@@ -29,6 +29,21 @@ namespace Subsurface
|
||||
return doc;
|
||||
}
|
||||
|
||||
public static SpriteFont TryLoadFont(string file, Microsoft.Xna.Framework.Content.ContentManager contentManager)
|
||||
{
|
||||
SpriteFont font = null;
|
||||
try
|
||||
{
|
||||
font = contentManager.Load<SpriteFont>(file);
|
||||
}
|
||||
catch
|
||||
{
|
||||
DebugConsole.ThrowError("Loading font ''"+file+"'' failed");
|
||||
}
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
public static object GetAttributeObject(XElement element, string name)
|
||||
{
|
||||
if (element.Attribute(name) == null) return null;
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user