//se fija si a la izquierda hay un plataforma y si hay depende del tamaño de la platafoma si este bloque es bloque plataforma o no public void CheckPlatform(int i, int j, BaseCube block, List <List <BaseCube> > matrizCubes) { if (matrizCubes[i - 1][j].space > 0) { block.space = matrizCubes[i - 1][j].space - 1; return; } if (matrizCubes[i - 1][j].exists) { if (matrizCubes[i - 1][j].tamaño > 0 && !matrizCubes[i - 1][j - 1].exists && !matrizCubes[i - 1][j - 2].exists && !matrizCubes[i][j - 1].exists && !matrizCubes[i][j - 2].exists && !matrizCubes[i - 2][j - 2].exists && !matrizCubes[i - 3][j - 2].exists) { block.tamaño = matrizCubes[i - 1][j].tamaño - 1; if (block.tamaño == 0) { block.space = Modifiers.platformSpaceSize; } block.exists = true; block.GetComponent <MeshRenderer>().material.color = Color.blue; var spikeChance = Random.Range(0, 100);//random para determinar si tiiene pinches if (spikeChance < Modifiers.spikeChance && !matrizCubes[i - 1][j].spike /*&& block.tamaño!= 0*/) { block.Spike(); } else { var coinChance = Random.Range(0, 100);//random para determinar si tiiene pinches if (coinChance < Modifiers.spikeChance) { block.Coin(); } } return; } } var platformChance = Random.Range(0, 100);//random para determinar si es plataforma if (platformChance < Modifiers.platformBlockChance) { if (!matrizCubes[i - 1][j - 1].exists && !matrizCubes[i - 1][j - 2].exists && !matrizCubes[i][j - 1].exists && !matrizCubes[i][j - 2].exists && !matrizCubes[i - 2][j - 2].exists && !matrizCubes[i - 3][j - 2].exists) { block.tamaño = Random.Range(1, Modifiers.platfomrSize); block.exists = true; block.GetComponent <MeshRenderer>().material.color = Color.blue; return; } } }
private void MoverACorneDeCamara() { cam = Camera.main; float height = cam.orthographicSize; float width = height * cam.aspect; transform.position = new Vector3(cam.transform.position.x - width + cubes.transform.localScale.x / 2, cam.transform.position.y - height + cubes.transform.localScale.y / 2, 0); var cantCubesOnBack = background.GetComponent <SpriteRenderer>().bounds.size.x / cubes.GetComponent <Renderer>().bounds.size.x; var cantBack = gridWidth / cantCubesOnBack; var back = Instantiate(background); back.transform.position = new Vector3(cam.transform.position.x + (back.GetComponent <SpriteRenderer>().bounds.size.x / 2 - width), cam.transform.position.y, 0); var spawnPoint = new Vector3(back.transform.position.x + back.GetComponent <SpriteRenderer>().bounds.size.x, back.transform.position.y, back.transform.position.z); for (int i = 1; i <= cantBack + 1; i++) { back = Instantiate(background); back.transform.position = spawnPoint; spawnPoint = new Vector3(back.transform.position.x + back.GetComponent <SpriteRenderer>().bounds.size.x, back.transform.position.y, back.transform.position.z); } }