Added new tile generation to the game
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Assets.Scripts;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -13,18 +14,15 @@ public class Tile : MonoBehaviour
|
||||
float borderSouth;
|
||||
float borderWest;
|
||||
System.Random rand = new System.Random();
|
||||
string tiletype;
|
||||
TileType tiletype;
|
||||
GameObject contentGenerator;
|
||||
|
||||
List<GameObject> aliveEnemies = new List<GameObject>();
|
||||
|
||||
public void generateTile(Vector3 pos, string type)
|
||||
public void generateTile(Vector3 pos, TileType type)
|
||||
{
|
||||
if (tiletype == null)
|
||||
{
|
||||
tiletype = type;
|
||||
}
|
||||
SteamWorksHandler.getForestAchievement(type);
|
||||
tiletype = type;
|
||||
SteamWorksHandler.getForestAchievement(type.ToString());
|
||||
contentGenerator = GameObject.Find("ContentGenerator");
|
||||
setPosition(pos);
|
||||
setBorders();
|
||||
@@ -58,7 +56,7 @@ public class Tile : MonoBehaviour
|
||||
int xChange = 0;
|
||||
int zChange = 0;
|
||||
int sideLimiter = 0;
|
||||
if(tiletype == "City"){
|
||||
if(tiletype == TileType.CITY){
|
||||
sideLimiter = 20;
|
||||
}
|
||||
else{
|
||||
@@ -70,7 +68,7 @@ public class Tile : MonoBehaviour
|
||||
{
|
||||
xChange = rand.Next(-2, +2);
|
||||
zChange = rand.Next(-2, +2);
|
||||
if(tiletype == "City"){
|
||||
if(tiletype == TileType.CITY){
|
||||
list.Add(new Vector3(j + xChange, 0, i + zChange));
|
||||
}
|
||||
else{
|
||||
@@ -87,10 +85,10 @@ public class Tile : MonoBehaviour
|
||||
int chance = rand.Next(1, 101);
|
||||
if (chance >= 25)
|
||||
{
|
||||
GameObject content = contentGenerator.GetComponent<ContentGenerator>().generateContent(tiletype);
|
||||
GameObject content = contentGenerator.GetComponent<ContentGenerator>().generateContent(tiletype.ToString());
|
||||
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"))){
|
||||
if(tiletype == 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);
|
||||
@@ -113,7 +111,7 @@ public class Tile : MonoBehaviour
|
||||
return position;
|
||||
}
|
||||
|
||||
public void setType(string tiletype)
|
||||
public void setType(TileType tiletype)
|
||||
{
|
||||
this.tiletype = tiletype;
|
||||
}
|
||||
@@ -199,7 +197,7 @@ public class Tile : MonoBehaviour
|
||||
Destroy(enemy);
|
||||
}
|
||||
|
||||
public string getTileType()
|
||||
public TileType getTileType()
|
||||
{
|
||||
return tiletype;
|
||||
}
|
||||
@@ -291,8 +289,12 @@ public class Tile : MonoBehaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
tiletype = json["tiletype"].ToString();
|
||||
tiletype = (TileType)Enum.Parse(typeof(TileType), json["tiletype"].ToString());
|
||||
setPosition(pos);
|
||||
setBorders();
|
||||
}
|
||||
|
||||
public List<TileType> getPossibleNeighbours(){
|
||||
return TileTypeMethods.getPossibleNeighbours(tiletype);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user