// 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(); }
// Use this for initialization protected void Start() { levelControllerScript = GameObject.Find("LevelController").GetComponent <LevelControllerScript>(); levelGrid = levelControllerScript.GetLevelGrid(); mapCols = levelControllerScript.GetMapCols(); mapRows = levelControllerScript.GetMapRows(); }
protected void Move(int x, int y) { levelGrid = levelControllerScript.GetLevelGrid(); // && levelGrid [posX + x, posY + y] != null if (posX + x >= 0 && posX + x < mapCols && posY + y >= 0 && posY + y < mapRows) { Debug.Log((posX) + ", " + (posY)); if (levelGrid [posX + x, posY + y].GetComponent <TileScript> ().IsPassable()) { levelGrid [posX, posY].GetComponent <TileScript> ().RemoveOccupant(); posX += x; posY += y; transform.Translate(new Vector3(x, y, 0)); levelGrid [posX, posY].GetComponent <TileScript> ().SetOccupant(GetComponent <GameObject> ()); } } }
// Use this for initialization void Start () { if (xmax % 2 == 0) {oddColAdjustment = -.5f;} if (ymax % 2 == 0) {oddRowAdjustment = -.5f;} levelControllerScript = GameObject.Find ("LevelController").GetComponent<LevelControllerScript> (); ymax = levelControllerScript.GetMapCols (); xmax = levelControllerScript.GetMapRows (); _levelGrid = levelControllerScript.GetLevelGrid (); corridorTile = Resources.Load ("Prefabs/Environment/Corridor") as GameObject; floorTile = Resources.Load("Prefabs/Environment/Floor") as GameObject; wallTile = Resources.Load("Prefabs/Environment/Wall") as GameObject; doorTile = Resources.Load("Prefabs/Environment/Door") as GameObject; unusedTile = Resources.Load("Prefabs/Environment/Unused") as GameObject; woodWallTile = Resources.Load("Prefabs/Environment/WoodWall") as GameObject; //GameObject sut = Instantiate(unusedTile, new Vector3(0, 0, -1), Quaternion.identity) as GameObject; //levelControllerScript.ReplaceTile(0, 0, unusedTile); CreateDungeon(xmax, ymax, 100); //Initialize(); levelControllerScript.SetLevelGrid(_levelGrid); }