public Caravan(int numTraders, CaravanTypeEnum caravanType, List <TileManager.Tile> spawnTiles, TileManager.Tile targetTile) { this.numTraders = numTraders; this.caravanType = caravanType; this.targetTile = targetTile; location = GameManager.caravanM.CreateLocation(); for (int i = 0; i < numTraders && spawnTiles.Count > 0; i++) { TileManager.Tile spawnTile = spawnTiles[UnityEngine.Random.Range(0, spawnTiles.Count)]; SpawnTrader(spawnTile); spawnTiles.Remove(spawnTile); } inventory = new ResourceManager.Inventory(this, int.MaxValue, int.MaxValue); resourceGroup = GameManager.resourceM.GetRandomResourceGroup(); foreach (ResourceManager.Resource resource in resourceGroup.resources.OrderBy(r => UnityEngine.Random.Range(0f, 1f))) // Randomize resource group list { int resourceGroupResourceCount = Mathf.Clamp(resourceGroup.resources.Count, minDistinctResources + 1, int.MaxValue); // Ensure minimum count of (minimumDistinctResources + 1) if (UnityEngine.Random.Range(0f, 1f) < Mathf.Clamp(((resourceGroupResourceCount - inventory.resources.Count) - minDistinctResources) / (float)(resourceGroupResourceCount - minDistinctResources), minDistinctResourceChance, 1f)) // Decrease chance of additional distinct resources on caravan as distinct resources on caravan increase { int resourceAvailableAmount = resource.GetAvailableAmount(); int caravanAmount = Mathf.RoundToInt(Mathf.Clamp(UnityEngine.Random.Range(resourceAvailableAmount * minAvailableAmountModifier, resourceAvailableAmount * maxAvailableAmountModifier), UnityEngine.Random.Range(minMinimumCaravanAmount, maxMinimumCaravanAmount), int.MaxValue)); // Ensure a minimum number of the resource on the caravan inventory.ChangeResourceAmount(resource, caravanAmount, false); } } }
public Human(TileManager.Tile spawnTile, float startingHealth) : base(spawnTile, startingHealth) { bodyIndices = GetBodyIndices(gender); moveSprites = GameManager.humanM.humanMoveSprites[bodyIndices[Appearance.Skin]]; inventory = new ResourceManager.Inventory(this, 50000, 50000); SetName(GameManager.humanM.GetName(gender)); humanObj = MonoBehaviour.Instantiate(GameManager.resourceM.humanPrefab, obj.transform, false); int appearanceIndex = 1; foreach (Appearance appearance in clothes.Keys) { humanObj.transform.Find(appearance.ToString()).GetComponent <SpriteRenderer>().sortingOrder = obj.GetComponent <SpriteRenderer>().sortingOrder + appearanceIndex; appearanceIndex += 1; } GameManager.humanM.humans.Add(this); }
public Caravan() { inventory = new ResourceManager.Inventory(this, int.MaxValue, int.MaxValue); }