// Use this for initialization void Start() { //load prefabs corridor = Resources.Load("Prefabs/Environment/Corridor") as GameObject; floor = Resources.Load("Prefabs/Environment/Floor") as GameObject; wall = Resources.Load("Prefabs/Environment/Wall") as GameObject; door = Resources.Load("Prefabs/Environment/Door") as GameObject; unused = Resources.Load("Prefabs/Environment/Unused") as GameObject; //grab enemies from prefabs vagrant = Resources.Load("Prefabs/NPCs/Vagrant") as GameObject; //find levelController levelControllerScript = GameObject.Find("LevelController").GetComponent <LevelControllerScript> (); myX = levelControllerScript.GetMapCols(); myY = levelControllerScript.GetMapRows(); ChangeLevel(0, 0); for (int i = 0; i < 10; ++i) { int x = Random.Range(0, _width); int y = Random.Range(0, _height); Debug.Log(x + ", " + y); if (levelControllerScript.GetLevelGrid()[x, y].GetComponent <TileScript> ().IsGround()) { levelControllerScript.SpawnLivingThing(vagrant, x, y); } } levelControllerScript.FillNPCList(); }
void placeNPCs() { Debug.Log("called"); int r = randomInt(_rooms.Count); int x = randomInt(_rooms [r].x + 1, _rooms [r].x + _rooms [r].width - 2); int y = randomInt(_rooms [r].y + 1, _rooms [r].y + _rooms [r].height - 2); if (getTile(x, y) == Tile.Floor) { Debug.Log("npc placing..."); levelControllerScript.SpawnLivingThing(vagrant, x, y); } }