This commit is contained in:
j.mei7
2022-03-16 18:16:19 +01:00
parent eb71cdbc9d
commit 2e92ba6ea4
41 changed files with 596 additions and 449 deletions

View File

@@ -0,0 +1,64 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AreaManager : MonoBehaviour
{
[SerializeField] int areaHeight;
[SerializeField] int areaWidth;
List<AreaObject> areaObjects;
[SerializeField] GameObject testPrefab;
void Start()
{
//int gridWidth = GridBuildingSystem.instance.buildingGrid.GetWidth();
//int gridHeight = GridBuildingSystem.instance.buildingGrid.GetWidth();
int areaWidthCount = GridBuildingSystem.instance.buildingGrid.GetWidth() / areaWidth;
int areaHeightCount = GridBuildingSystem.instance.buildingGrid.GetHeight() / areaHeight;
for(int heightCounter = 0; heightCounter < areaHeightCount; heightCounter++)
{
Debug.Log("---- New Row -----");
for (int widthCounter = 0; widthCounter < areaWidthCount; widthCounter++)
{
Debug.Log("---- New Area -----");
List<GameObject> testGameObjs = new List<GameObject>();
for (int x = 0; x < areaWidth; x++)
{
for (int y = 0; y < areaHeight; y++)
{
Debug.Log((x + widthCounter * areaWidth).ToString() + "," + (y + heightCounter * areaHeight).ToString());
GameObject testObj = Instantiate(testPrefab);
testObj.transform.position = GridBuildingSystem.instance.buildingGrid.GetWorldPosition((x + widthCounter * areaWidth), (y + heightCounter * areaHeight));
testObj.transform.name = widthCounter + " - " + heightCounter;
testGameObjs.Add(testObj);
}
}
Color color = Random.ColorHSV();
foreach (GameObject testObj in testGameObjs)
{
testObj.GetComponent<SpriteRenderer>().color = color;
}
}
}
}
public class AreaObject
{
public int[,] tileArray;
public AreaObject(int[,] _tileArray) {
tileArray = _tileArray;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2be9f8a208335fe43bb797bec633e029
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,36 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PersonManager : MonoBehaviour
{
City city;
[SerializeField] GameObject personPrefab;
void Start()
{
city = GetComponent<City>();
TimeManager.OnDayUpdate += OnDayUpdate;
}
void OnDayUpdate()
{
int avaiableSpace = city.GetAvaiableHousingSpace();
if (avaiableSpace > 5)
{
SpawnPerson(5);
}
else
{
SpawnPerson(avaiableSpace);
}
}
public void SpawnPerson(int count = 1)
{
for(int i = 0; i < count; i++)
{
Instantiate(personPrefab);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7a66523eed61c5b44af39762a8d6e476
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -31,7 +31,7 @@ public class TimeManager : MonoBehaviour
int minutesPerInterval = 1;
public CultureInfo cultureInfo = new CultureInfo("en-us");
DateTime dateTime = new DateTime(1, 1, 1, 0, 0, 0);
DateTime dateTime = new DateTime(1, 1, 1, 23, 0, 0);
DateTime prevDateTime;
float timer;