public void SpawnTile() { if (LeftTiles.Count == 0 || TopTiles.Count == 0) { CreateTiles(10); } //generam numere intre 0 si 1 int randomIndex = Random.Range(0, 2); if (randomIndex == 0) { GameObject tmp = LeftTiles.Pop(); tmp.SetActive(true); tmp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position; currentTile = tmp; } else if (randomIndex == 1) { GameObject tmp = TopTiles.Pop(); tmp.SetActive(true); tmp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position; currentTile = tmp; } int spawnPickup = Random.Range(0, 10); if (spawnPickup == 0) { currentTile.transform.GetChild(1).gameObject.SetActive(true); } }
public void CreateTiles(int amount) { for (int i = 0; i < amount; i++) { LeftTiles.Push(Instantiate(tilePrefabs[0])); TopTiles.Push(Instantiate(tilePrefabs[1])); LeftTiles.Peek().name = "LeftTile"; TopTiles.Peek().name = "TopTile"; LeftTiles.Peek().SetActive(false); TopTiles.Peek().SetActive(false); } }
///////////////////////////////////////////// public void SpawnTileEasyMode() { int catePiese = Random.Range(1, 4); if (LeftTiles.Count == 0 || TopTiles.Count == 0) { CreateTiles(10); } //generam numere intre 0 si 1 int randomIndex = Random.Range(0, 2); //daca e 0, spawnam left tile if (randomIndex == 0) { for (int i = 0; i < catePiese; i++) { GameObject tmp = LeftTiles.Pop(); tmp.SetActive(true); tmp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position; currentTile = tmp; } } //daca e 1, spawnam top tile else if (randomIndex == 1) { for (int i = 0; i < catePiese; i++) { GameObject tmp = TopTiles.Pop(); tmp.SetActive(true); tmp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position; currentTile = tmp; } } int spawnPickup = Random.Range(0, 10); if (spawnPickup == 0) { currentTile.transform.GetChild(1).gameObject.SetActive(true); } //currentTile = Instantiate(tilePrefabs[randomIndex], currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position, Quaternion.identity); }
public TopTiles GetTopTilesData() { AppleLaLaRepository <Customer> repo_c = new AppleLaLaRepository <Customer>(context); AppleLaLaRepository <Designer> repo_d = new AppleLaLaRepository <Designer>(context); AppleLaLaRepository <Order_details> repo_od = new AppleLaLaRepository <Order_details>(context); AppleLaLaRepository <Order> repo_o = new AppleLaLaRepository <Order>(context); TopTiles topTiles = new TopTiles { MemberCount = repo_c.GetAll().Count(), DesginerCount = repo_d.GetAll().Count(), AppointmentEvent = repo_od.GetAll().Count((x) => x.Appointment_date == DateTime.Today), OrderMonth = repo_o.GetAll().Count((x) => x.Order_date.Month == DateTime.Now.Month) }; return(topTiles); }
public void SpawnTile() { //check if we have some tiles to take before we try to spawn them if (LeftTiles.Count == 0 || TopTiles.Count == 0) { CreateTiles(10); } //CurrentTile -> Tile -> LeftAttachPoint //currentTile = Instantiate(leftTilePrefab, currentTile.transform.GetChild(0).transform.GetChild(0).position, Quaternion.identity); //currentTile = Instantiate(topTilePrefab, currentTile.transform.GetChild(0).transform.GetChild(1).position, Quaternion.identity); //Generating a random number between 0 and 1 int randomIndex = Random.Range(0, 2); if (randomIndex == 0) { //pop remove the tile from the stack GameObject tmp = LeftTiles.Pop(); //in createtiles we set false tmp.SetActive(true); tmp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position; currentTile = tmp; } else if (randomIndex == 1) { //pop remove the tile from the stack GameObject tmp = TopTiles.Pop(); //in createtiles we set false tmp.SetActive(true); tmp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position; currentTile = tmp; } int spawnPickup = Random.Range(0, 10); if (spawnPickup == 0) { //enable the pickup same like tick,pickup is the second child currentTile.transform.GetChild(1).gameObject.SetActive(true); } //Left -> Element0, Top -> Element1 //currentTile = Instantiate(tilePrefabs[0], currentTile.transform.GetChild(0).transform.GetChild(0).position, Quaternion.identity); //currentTile = Instantiate(tilePrefabs[1], currentTile.transform.GetChild(0).transform.GetChild(1).position, Quaternion.identity); //currentTile = Instantiate(tilePrefabs[randomIndex], currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position, Quaternion.identity); }
/// <summary> /// Takes care for placing the tiles randomly and recyle them. /// Also adds pickups for bonus point randomly for red and golden apples. /// </summary> public void SpawnTile() { if (LeftTiles.Count == 0 || TopTiles.Count == 0) { CreateTiles(10); } int randomIndex = Random.Range(0, 2); if (randomIndex == 0) { GameObject tmp = LeftTiles.Pop(); tmp.SetActive(true); tmp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position; currentTile = tmp; } else if (randomIndex == 1) { GameObject tmp = TopTiles.Pop(); tmp.SetActive(true); tmp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position; currentTile = tmp; } // Each tile will have a 50% chance of spawing a red- or golden-apple with their own chance, 1/8 and 1/50 respectily. int spawnPickup = Random.Range(0, 2); if (spawnPickup == 0) { //int + ny if(redapple == 0) + 0, 10 int redApple = Random.Range(0, 8); if (redApple == 0) { currentTile.transform.GetChild(1).gameObject.SetActive(true); } } else if (spawnPickup == 1) { int goldenApple = Random.Range(0, 50); if (goldenApple == 0) { currentTile.transform.GetChild(2).gameObject.SetActive(true); } } }
//get grid public byte[,] GetTileGrid(byte[] romTileData, int tileByteOffset) { byte[,] topTileGrid = TopTiles.GetTileSectionGrid(); byte[,] bottomTileGrid = BottomTiles.GetTileSectionGrid(); byte[,] fullGrid = new byte[8, 6]; //only 2 rows used from bottom grid for (int y = 0; y < 6; y++) { for (int x = 0; x < 8; x++) { if (y < 4) { fullGrid[x, y] = topTileGrid[x, y]; } else { fullGrid[x, y] = bottomTileGrid[x, y - 4]; } } } return(fullGrid); }
public void SpawnTile() { if (leftTiles.Count == 0 || TopTiles.Count == 0) { CreateTiles(10); } //Debug.Log("create index is true"); if (jumpIndex == 0) { randomIndex = Random.Range(0, 2); } int randomGap = Random.Range(5, 10); jumpBlock = Random.Range(5, UpperLimit); if (randomIndex == 0) { GameObject tmp = leftTiles.Pop(); //m_Material = tmp.transform.GetChild(0).GetComponent<Renderer>().material; tmp.SetActive(true); tmp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position; tmp.transform.position = new Vector3(tmp.transform.position.x, 0, tmp.transform.position.z); //tmpPos = tmp.transform.position; //tmpPos.y = 0; if (level > 1) { //loop through collection and change each platform color m_Material = tmp.transform.GetChild(1).GetComponent <Renderer>().material; m_Material.color = Color.red; //UpperLimit -= 5; } if (jumpIndex > 0) { --jumpIndex; } if (randomGap == 8 && jumpIndex == 0) { //tmp.transform.GetChild(0).GetComponent<Renderer>().material.SetColor("_Color", Color.green); rend = tmp.transform.GetChild(0).GetComponent <Renderer>(); //rendTwo = tmp.transform.GetChild(1).GetComponent<Renderer>(); rend.enabled = false; lightPosition = tmp.transform.GetChild(0).position; lightPosition.y = lightPosition.y - 6; lightRotation = tmp.transform.GetChild(0).rotation; //lightRotation.x = 270; tempObject = Instantiate(tmpLight, lightPosition, tmpLight.transform.rotation); tempObject.transform.parent = tmp.transform.GetChild(0); //rendTwo.enabled = false; rend = tmp.transform.GetChild(1).GetComponent <Renderer>(); rend.enabled = false; collision = tmp.transform.GetChild(0).GetComponent <Collider>(); collision.enabled = false; collision = tmp.transform.GetChild(1).GetComponent <Collider>(); collision.enabled = false; jumpIndex = 2; randomIndex = 0; } if (jumpBlock == 8) { tmpObject = tmp; Jumps.Add(tmpObject); m_Material = tmpObject.transform.GetChild(1).GetComponent <Renderer>().material; m_Material.color = Color.white; //Debug.Log(Jumps.Count); } currentTile = tmp; } else if (randomIndex == 1) { GameObject tmp = TopTiles.Pop(); tmp.SetActive(true); tmp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position; tmp.transform.position = new Vector3(tmp.transform.position.x, 0, tmp.transform.position.z); //tmpPos = tmp.transform.position; //tmpPos.y = 0; if (level > 1) { m_Material = tmp.transform.GetChild(1).GetComponent <Renderer>().material; m_Material.color = Color.red; } if (jumpIndex > 0) { --jumpIndex; } if (randomGap == 6 && jumpIndex == 0) { //tmp.transform.GetChild(0).GetComponent<Renderer>().material.SetColor("_Color", Color.red); rend = tmp.transform.GetChild(0).GetComponent <Renderer>(); //rendTwo = tmp.transform.GetChild(1).GetComponent<Renderer>(); rend.enabled = false; rend = tmp.transform.GetChild(1).GetComponent <Renderer>(); rend.enabled = false; lightPosition = tmp.transform.GetChild(0).position; lightPosition.y = lightPosition.y - 6; lightRotation = tmp.transform.GetChild(0).rotation; //lightRotation.x = lightRotation.x - 90; tempObject = Instantiate(tmpLight, lightPosition, tmpLight.transform.rotation); tempObject.transform.parent = tmp.transform.GetChild(0); //rendTwo.enabled = false; collision = tmp.transform.GetChild(0).GetComponent <Collider>(); collision.enabled = false; collision = tmp.transform.GetChild(1).GetComponent <Collider>(); collision.enabled = false; jumpIndex = 2; randomIndex = 1; } if (jumpBlock == 7) { tmpObject = tmp; Jumps.Add(tmpObject); m_Material = tmpObject.transform.GetChild(1).GetComponent <Renderer>().material; m_Material.color = Color.white; //Debug.Log(Jumps.Count); } currentTile = tmp; } }