fixed options, fixed save, new Screenshots, v.140
This commit is contained in:
@@ -17,7 +17,6 @@ public class Tile : MonoBehaviour
|
||||
GameObject contentGenerator;
|
||||
|
||||
List<GameObject> aliveEnemies = new List<GameObject>();
|
||||
List<GameObject> deadEnemies = new List<GameObject>();
|
||||
|
||||
public void generateTile(Vector3 pos, string type)
|
||||
{
|
||||
@@ -47,12 +46,9 @@ public class Tile : MonoBehaviour
|
||||
|
||||
public void generateContent()
|
||||
{
|
||||
if (!tiletype.ToLower().Equals("City"))
|
||||
foreach (Vector3 position in getSpawnLocations())
|
||||
{
|
||||
foreach (Vector3 position in getSpawnLocations())
|
||||
{
|
||||
spawnObject(position);
|
||||
}
|
||||
spawnObject(position);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,13 +57,26 @@ public class Tile : MonoBehaviour
|
||||
List<Vector3> list = new List<Vector3>();
|
||||
int xChange = 0;
|
||||
int zChange = 0;
|
||||
for (float i = borderNorth - 10; i >= borderSouth + 10; i = i - 10)
|
||||
int sideLimiter = 0;
|
||||
if(tiletype == "City"){
|
||||
sideLimiter = 20;
|
||||
}
|
||||
else{
|
||||
sideLimiter = 10;
|
||||
}
|
||||
for (float i = borderNorth - sideLimiter; i >= borderSouth + sideLimiter; i = i - sideLimiter)
|
||||
{
|
||||
for (float j = borderWest + 10; j <= borderEast - 10; j = j + 10)
|
||||
for (float j = borderWest + sideLimiter; j <= borderEast - sideLimiter; j = j + sideLimiter)
|
||||
{
|
||||
xChange = rand.Next(-4, +4);
|
||||
zChange = rand.Next(-4, +4);
|
||||
list.Add(new Vector3(j + xChange, 5, i + zChange));
|
||||
xChange = rand.Next(-2, +2);
|
||||
zChange = rand.Next(-2, +2);
|
||||
if(tiletype == "City"){
|
||||
list.Add(new Vector3(j + xChange, 0, i + zChange));
|
||||
}
|
||||
else{
|
||||
list.Add(new Vector3(j + xChange, 5, i + zChange));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return list;
|
||||
@@ -76,11 +85,14 @@ public class Tile : MonoBehaviour
|
||||
public void spawnObject(Vector3 position)
|
||||
{
|
||||
int chance = rand.Next(1, 101);
|
||||
if (chance >= 50)
|
||||
if (chance >= 25)
|
||||
{
|
||||
GameObject content = contentGenerator.GetComponent<ContentGenerator>().generateContent(tiletype);
|
||||
if (content != null)
|
||||
{
|
||||
if(tiletype == "City" && (content.tag.ToLower().Contains("npc") || content.tag.ToLower().Contains("tree") || content.tag.ToLower().Contains("stone") || content.tag.ToLower().Contains("ore"))){
|
||||
position.y = 5;
|
||||
}
|
||||
GameObject obj = Instantiate(content, position, Quaternion.identity);
|
||||
obj.transform.parent = gameObject.transform;
|
||||
if (obj.tag.Contains("Enemy"))
|
||||
@@ -121,26 +133,17 @@ public class Tile : MonoBehaviour
|
||||
{
|
||||
foreach (Rigidbody rigid in gameObject.GetComponentsInChildren<Rigidbody>())
|
||||
{
|
||||
if (!deadEnemies.Contains(rigid.gameObject))
|
||||
{
|
||||
rigid.useGravity = !rigid.useGravity;
|
||||
}
|
||||
rigid.useGravity = !rigid.useGravity;
|
||||
}
|
||||
|
||||
foreach (Renderer rend in gameObject.GetComponentsInChildren<Renderer>())
|
||||
{
|
||||
if (!deadEnemies.Contains(rend.gameObject))
|
||||
{
|
||||
rend.enabled = !rend.enabled;
|
||||
}
|
||||
rend.enabled = !rend.enabled;
|
||||
}
|
||||
|
||||
foreach (Collider col in gameObject.GetComponentsInChildren<Collider>())
|
||||
{
|
||||
if (!deadEnemies.Contains(col.gameObject))
|
||||
{
|
||||
col.enabled = !col.enabled;
|
||||
}
|
||||
col.enabled = !col.enabled;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,11 +214,8 @@ public class Tile : MonoBehaviour
|
||||
|
||||
public void enemyKilled(GameObject enemy)
|
||||
{
|
||||
deadEnemies.Add(enemy);
|
||||
enemy.GetComponent<Rigidbody>().useGravity = false;
|
||||
enemy.GetComponent<Renderer>().enabled = false;
|
||||
enemy.GetComponent<Collider>().enabled = false;
|
||||
aliveEnemies.Remove(enemy);
|
||||
Destroy(enemy);
|
||||
}
|
||||
|
||||
public string getTileType()
|
||||
@@ -239,6 +239,12 @@ public class Tile : MonoBehaviour
|
||||
{
|
||||
result = result + obj.GetComponent<Enemy>().saveEnemy() + "\r\n}";
|
||||
}
|
||||
else if(obj.name.ToLower().Contains("house")){
|
||||
result = result + obj.transform.Find("Door").GetComponent<Door>().saveHouse() + "\r\n}";
|
||||
}
|
||||
else if(obj.name.ToLower().Contains("npc")){
|
||||
result = result + obj.GetComponent<NPC>().saveNPC() + "\r\n}";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = result + FileHandler.generateJSON("objectname", "\"" + obj.name + "\"") + "\r\n}";
|
||||
@@ -296,6 +302,12 @@ public class Tile : MonoBehaviour
|
||||
spawnedObject.GetComponent<Enemy>().loadEnemy(obj);
|
||||
}
|
||||
}
|
||||
else if(spawnedObject.name.ToLower().Contains("house")){
|
||||
spawnedObject.transform.Find("Door").GetComponent<Door>().loadHouse(obj);
|
||||
}
|
||||
else if(spawnedObject.tag.ToLower().Contains("npc")){
|
||||
spawnedObject.GetComponent<NPC>().loadQuest(obj["receivedQuest"].ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
tiletype = json["tiletype"].ToString();
|
||||
|
||||
Reference in New Issue
Block a user