Location hire

This commit is contained in:
Regalis11
2015-07-26 21:15:41 +03:00
parent 461547d949
commit 4238301ad3
13 changed files with 151 additions and 56 deletions
+27 -6
View File
@@ -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)
+11 -3
View File
@@ -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())
{
+3 -3
View File
@@ -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;