public void updatePlayer() { //locating the end point in the corner TilemapCaveGeneratorQ_6 a = endtilemap.GetComponent <TilemapCaveGeneratorQ_6>(); int[,] data = a.caveGenerator.GetMap(); int max = 0; Vector3Int pos = new Vector3Int(); for (int x = 0; x < a.gridSize; x++) { for (int y = a.gridSize - 1; y >= 0; y--) { int b = a.gridSize - y; if (data[x, y] != 1) { int temp = x + b; if (temp > max) { max = temp; pos = new Vector3Int(x, y, 0); } } } } endtilemap.SetTile(pos, tilebase); a.EndFlag = false; }
public void updatePlayer() { // locating the player in the corner of the cave TilemapCaveGeneratorQ_6 a = tilemap.GetComponent <TilemapCaveGeneratorQ_6>(); int[,] data = a.caveGenerator.GetMap(); int min = 100000000; Vector3Int pos = new Vector3Int(); for (int x = 0; x < a.gridSize; x++) { for (int y = a.gridSize - 1; y >= 0; y--) { int b = a.gridSize - y; if (data[x, y] != 1) { int temp = x + b; if (temp < min) { min = temp; pos = new Vector3Int(x, y, 0); } } } } transform.position = tilemap.CellToWorld(pos); a.playerFlag = false; }
void locatTheEnemy() { //locate the enemy in a random position in the cave TilemapCaveGeneratorQ_6 a = tilemap.GetComponent <TilemapCaveGeneratorQ_6>(); int[,] data = a.caveGenerator.GetMap(); int x = 0, y = 0; while (data[x, y] == 1) { x = Random.Range(0, a.gridSize); y = Random.Range(0, a.gridSize); } transform.position = tilemap.CellToWorld(new Vector3Int(x, y, 0)); //if its done locating the enemy false the flag for the next level if (enemyNumber == 1) { a.E1flag = false; } else { a.E2flag = false; } }
// Update is called once per frame void Update() { //checking if the map done generating the cave TilemapCaveGeneratorQ_6 a = endtilemap.GetComponent <TilemapCaveGeneratorQ_6>(); if (a != null && a.EndFlag) { updatePlayer(); } }
// Update is called once per frame void Update() { TilemapCaveGeneratorQ_6 a = tilemap.GetComponent <TilemapCaveGeneratorQ_6>(); //if its done generating the cave loacte the player if (a != null && a.playerFlag) { updatePlayer(); } }
// Update is called once per frame void Update() { bool e = false; TilemapCaveGeneratorQ_6 a = tilemap.GetComponent <TilemapCaveGeneratorQ_6>(); if (a != null)//checking which enemy is { if (enemyNumber == 1) { e = a.E1flag; } else { e = a.E2flag; } } // if the map done generating the cave locate the enemy if (a != null && e) { locatTheEnemy(); } }
// Start is called before the first frame update void Start() { //assign to current tilemap size and the cave generator a = tilemap.GetComponent <TilemapCaveGeneratorQ_6>(); size = a.gridSize; }