private void maybeCreateVerLazer(float chance) { if (chance > Random.Range(0f, 1f)) { GridSpot toPut = getRandomAvailableSpot(7); GameObject lazer = Instantiate(verLazerOriginal); GridableObject script = lazer.GetComponent <GridableObject>(); script.setGridPosition(toPut.getY() + 1, toPut.getX()); grid[toPut.getY(), toPut.getX()] = true; temporaryObjs.Add(lazer); } }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag.Equals("Ball")) { GameObject newLazer = Instantiate(lazer); LazerSound.Play(); GridableObject lazerGridScript = newLazer.GetComponent <GridableObject>(); GridableObject btnGridScript = this.gameObject.GetComponent <GridableObject>(); Debug.Log(btnGridScript.getGridY()); // lazerGridScript.setGridPosition(btnGridScript.getGridY(), btnGridScript.getGridX()); if (IsHorizontal) { lazerGridScript.setGridPosition(btnGridScript.getGridY(), 3); } else { lazerGridScript.setGridPosition(5, btnGridScript.getGridX()); } } }
public void addNewRowToList(int row) { destroyTempObjects(); cleanObjsList(); int AddBallCoinPosition = (int)Random.Range(0.0f, (float)ROWSIZE - 0.000001f); for (int i = 0; i < ROWSIZE; ++i) { bool ObjShouldBeAdded = false; bool ObjIsCoin = false; GameObject block = gameObject; if (i == AddBallCoinPosition) { block = Instantiate(AddBallCoin); ObjShouldBeAdded = true; ObjIsCoin = true; } else { float randomValue = Random.Range(0.0f, 10.0f); if (randomValue > 3.0f) { ObjShouldBeAdded = true; ObjIsCoin = false; if (randomValue < 8.0f) { block = Instantiate(originalBlock); } else if (randomValue > 8.0f && randomValue < 8.5f) { block = Instantiate(TRTriangle); } else if (randomValue > 8.5f && randomValue < 9.0f) { block = Instantiate(TLTriangle); } else if (randomValue > 9.0f && randomValue < 9.5f) { block = Instantiate(BRTriangle); } else if (randomValue > 9.5f) { block = Instantiate(BLTriangle); } } } if (ObjShouldBeAdded) { GridableObject gridable = block.GetComponent <GridableObject>(); if (ObjIsCoin == false) { BlockScript script = block.GetComponent <BlockScript>(); script.setHealth(health); } gridable.setGridPosition(row, i); objs.Add(gridable); } } changeGridStatus(); maybeCreateBouncer(BouncerChance); maybeCreateHorLazer(LazerChance); maybeCreateVerLazer(LazerChance); health++; //bouncerFlag = true; }