// blokları konumlandıran fonksiyon private Vector2 BlockPositioner(float rate) { int tempEx = exRand; exRand = RandomPos.RandomPosition(exRand, sameLine); sameLine = (tempEx == exRand) ? sameLine += 1 : sameLine = 0; distance += rate; return(new Vector2(BlockPos[exRand], distance)); }
private IEnumerator ShooterLoop() { //bullet hızı ayarla sadece !!!!!!!!!!!!!!! //******************** while (GameConst.instance.isGameOn)//(GameConst.instance.isGameOn) { if (blockNumb <= GameConst.instance.blockNumber && this.gameObject.transform.position.z > GameConst.instance.blocks[0].gameObject.transform.position.z && this.gameObject.transform.position.z < GameConst.instance.LastPosOfArray + GameConst.instance.BlockDistUpdate) { bulletPos = RandomPos.RandomPosition(bulletPos, 2); //float barrelPos = bulletPositionSelector[bulletPos]; //float rand = Random.Range(minRand, maxRand); //uiScript.materialChangetoRed(barrelSelector(barrelPos)); yield return(new WaitUntil(() => this.gameObject.transform.position.z >= GameConst.instance.blocks[blockNumb].gameObject.transform.position.z + GameConst.instance.BlockDistUpdate));// shootInterval); //+ GameConst.instance.BlockDistUpdate); //Debug.Log("Sıktım benim konum : " + this.transform.position.z + "Baktıgım blok konumu " + GameConst.instance.blocks[blockNumb].gameObject.transform.position.z ); float spd = (GameConst.Level == 1) ? (Random.Range(0, 3) > 1) ? bulletSpeedOnTop : bulletSpeedOnMiddle :(Random.Range(0, 2) == 0) ? bulletSpeedOnMiddle : bulletSpeedOnTop; Vector3 bulletPosition = new Vector3(PlatformTurnScript.instance.CoinAndBulletPos[bulletPos].x, PlatformTurnScript.instance.CoinAndBulletPos[bulletPos].y, this.transform.position.z); if (blockNumb < GameConst.instance.blockNumber) { bulletOnTheWay(bulletPosition, PlatformTurnScript.instance.BulletRot[bulletPos], (totBulletSended != 0) ? -1 * spd * Player.instance.speed.z : -1 * spd * PlayerAccelerator.GetPlayerNormalSpeed(Player.instance.initialSpeed)); totBulletSended += 1; blockNumb += 1; } else if (blockNumb == GameConst.instance.blockNumber && Mathf.Approximately(spd, bulletSpeedOnTop)) { bulletOnTheWay(bulletPosition, PlatformTurnScript.instance.BulletRot[bulletPos], -1 * spd * Player.instance.speed.z); totBulletSended += 1; blockNumb += 1; } yield return(new WaitForSecondsRealtime(0.5f)); if (Player.instance.mode == (int)Player.Mode.bulletProof && Random.Range(0, Player.instance.strikeConstant + 2) >= 2 && blockNumb < GameConst.instance.blockNumber) { bulletPos = RandomPos.RandomPosition(bulletPos, 2); float Bspd = (GameConst.Level == 1) ? (Random.Range(0, 3) > 1) ? bulletSpeedOnTop : bulletSpeedOnMiddle : (Random.Range(0, 2) == 0) ? bulletSpeedOnMiddle : bulletSpeedOnTop; Vector3 BbulletPosition = new Vector3(PlatformTurnScript.instance.CoinAndBulletPos[bulletPos].x, PlatformTurnScript.instance.CoinAndBulletPos[bulletPos].y, this.transform.position.z); bulletOnTheWay(BbulletPosition, PlatformTurnScript.instance.BulletRot[bulletPos], -1 * Bspd * Player.instance.speed.z); totBulletSended += 1; } //uiScript.materialChangetoWhite(barrelSelector(barrelPos)); } yield return(null); } StopGun(); }
static void LevelCoins(GameObject Coins) { int rand = Random.Range(0, 3); int r = (rand == 0) ? r = RandomPos.ChooseOne(1, 2) : (rand == 1) ? r = RandomPos.ChooseOne(0, 2) : r = RandomPos.ChooseOne(0, 1); for (int i = 0; i < Coins.transform.childCount; i++) { if (i <= Coins.transform.childCount / 2) { Coins.transform.GetChild(i).transform.localPosition = new Vector3(PlatformTurnScript.instance.CoinAndBulletPos[rand].x, PlatformTurnScript.instance.CoinAndBulletPos[rand].y, Coins.transform.GetChild(i).transform.localPosition.z); } else if (i < Coins.transform.childCount) { Coins.transform.GetChild(i).transform.localPosition = new Vector3(PlatformTurnScript.instance.CoinAndBulletPos[r].x, PlatformTurnScript.instance.CoinAndBulletPos[r].y, Coins.transform.GetChild(i).transform.localPosition.z + 60f); } else { Debug.LogError("Coin atarken hata!!!!"); } } }
private IEnumerator Level_ShooterLoop() { //bullet hızı ayarla sadece !!!!!!!!!!!!!!! //******************** while (GameConst.instance.isGameOn)//(GameConst.instance.isGameOn) { if (blockNumb <= GameConst.instance.blockNumber && this.gameObject.transform.position.z > GameConst.instance.blocks[0].gameObject.transform.position.z && this.gameObject.transform.position.z < GameConst.instance.LastPosOfArray + GameConst.instance.BlockDistUpdate) { bulletPos = RandomPos.RandomPosition(bulletPos, 2); //float barrelPos = bulletPositionSelector[bulletPos]; //float rand = Random.Range(minRand, maxRand); //uiScript.materialChangetoRed(barrelSelector(barrelPos)); yield return(new WaitUntil(() => this.gameObject.transform.position.z >= GameConst.instance.blocks[blockNumb].gameObject.transform.position.z + GameConst.instance.BlockDistUpdate));// shootInterval); //+ GameConst.instance.BlockDistUpdate); //Debug.Log("Sıktım benim konum : " + this.transform.position.z + "Baktıgım blok konumu " + GameConst.instance.blocks[blockNumb].gameObject.transform.position.z ); float spd = (GameConst.Level <= 4) ? (Random.Range(0, 3) > 1) ? bulletSpeedOnTop : bulletSpeedOnMiddle : (Random.Range(0, 2) == 0) ? bulletSpeedOnMiddle : bulletSpeedOnTop; Vector3 bulletPosition = new Vector3(PlatformTurnScript.instance.CoinAndBulletPos[bulletPos].x, PlatformTurnScript.instance.CoinAndBulletPos[bulletPos].y, this.transform.position.z); if (blockNumb < GameConst.instance.blockNumber) { bulletOnTheWay(bulletPosition, PlatformTurnScript.instance.BulletRot[bulletPos], (totBulletSended != 0) ? -1 * spd * Player.instance.speed.z : -1 * spd * PlayerAccelerator.GetPlayerNormalSpeed(Player.instance.initialSpeed)); totBulletSended += 1; blockNumb += 1; } else if (blockNumb == GameConst.instance.blockNumber && Mathf.Approximately(spd, bulletSpeedOnTop)) { bulletOnTheWay(bulletPosition, PlatformTurnScript.instance.BulletRot[bulletPos], -1 * spd * Player.instance.speed.z); totBulletSended += 1; blockNumb += 1; } if (GameConst.Level > 11 && blockNumb < GameConst.instance.blockNumber) { float coefficient = (float)(GameConst.Level - 10) / 10; //Debug.LogError(GameConst.Level + "coef is : " + coefficient); float secondBulletProbability = 15 + (int)(20 * (1 - Mathf.Exp(-(coefficient)))); float secondBulletDecider = Random.Range(0, 100); if (secondBulletProbability > secondBulletDecider) { //Debug.LogError("İkinci mermiyi attık. ikince mermi gelme olasılığı " + secondBulletProbability + " bundan büyük olmuş " + secondBulletDecider ); yield return(new WaitForSeconds(0.5f)); bulletPos = RandomPos.RandomPosition(bulletPos, 2); Vector3 SecondbulletPosition = new Vector3(PlatformTurnScript.instance.CoinAndBulletPos[bulletPos].x, PlatformTurnScript.instance.CoinAndBulletPos[bulletPos].y, this.transform.position.z); float secondSpd = (Mathf.Approximately(spd, bulletSpeedOnTop)) ? bulletSpeedOnMiddle : bulletSpeedOnTop; bulletOnTheWay(SecondbulletPosition, PlatformTurnScript.instance.BulletRot[bulletPos], -1 * secondSpd * Player.instance.speed.z); totBulletSended += 1; } } yield return(new WaitForSecondsRealtime(0.5f)); if (Player.instance.mode == (int)Player.Mode.bulletProof && Random.Range(0, Player.instance.strikeConstant + 2) >= 2 && blockNumb < GameConst.instance.blockNumber) { bulletPos = RandomPos.RandomPosition(bulletPos, 2); float Bspd = (GameConst.Level <= 4) ? (Random.Range(0, 3) > 1) ? bulletSpeedOnTop : bulletSpeedOnMiddle : (Random.Range(0, 2) == 0) ? bulletSpeedOnMiddle : bulletSpeedOnTop; Vector3 BbulletPosition = new Vector3(PlatformTurnScript.instance.CoinAndBulletPos[bulletPos].x, PlatformTurnScript.instance.CoinAndBulletPos[bulletPos].y, this.transform.position.z); bulletOnTheWay(BbulletPosition, PlatformTurnScript.instance.BulletRot[bulletPos], -1 * Bspd * Player.instance.speed.z); totBulletSended += 1; } //uiScript.materialChangetoWhite(barrelSelector(barrelPos)); } yield return(null); } StopGun(); }
public static int CreateBlock(GameObject pooledBlock, int doubleBlockNum) { int tempEx = exRand; exRand = RandomPos.RandomPosition(exRand, GameConst.instance.SameLineBlock); if (tempEx == exRand) { GameConst.instance.SameLineBlock += 1; } else { GameConst.instance.SameLineBlock = 0; } Random.InitState(Random.Range(0, 100)); foreach (MeshRenderer t in pooledBlock.GetComponentsInChildren <MeshRenderer>()) //Added because when smashing block mesh renderes are disabled { t.enabled = true; } int r = (doubleBlockNum == 0) ? 0 : (!beforeActivated) ? Random.Range(0, GameConst.Level + 1) : (beforeActivated) ? Random.Range(0, GameConst.Level + 3) : 1;; /*if(GameConst.instance.gameMode == 0) * { * r = (doubleBlockNum == 0) ? 0 : (!beforeActivated) ? Random.Range(0, GameConst.Level + 1) : (beforeActivated) ? Random.Range(0, GameConst.Level + 3) : 1; * } * else * { * r = (doubleBlockNum == 0) ? 0 : (!beforeActivated) ? Random.Range(0, GameConst.Level + 1) : (beforeActivated) ? Random.Range(0, GameConst.Level + 3) : 1; * }*/ // Debug.Log(r); if (doubleBlockNum <= (GameConst.instance.blocks.Length * 3) / (GameConst.Level) && r < (GameConst.Level / 3f)) { beforeActivated = true; pooledBlock.transform.GetChild(1).GetComponent <MeshRenderer>().enabled = true; pooledBlock.transform.GetChild(1).GetComponent <BoxCollider>().enabled = true; doubleBlockNum++; } else if (pooledBlock.transform.GetChild(1).gameObject.activeSelf) { beforeActivated = false; pooledBlock.transform.GetChild(1).GetComponent <MeshRenderer>().enabled = false; pooledBlock.transform.GetChild(1).GetComponent <BoxCollider>().enabled = false; } if (pooledBlock != null) { if (!pooledBlock.activeInHierarchy) { pooledBlock.SetActive(true); } tempEx = exRand; int i = 0; pooledBlock.transform.localEulerAngles = Vector3.zero; pooledBlock.GetComponent <BlockScript>().OnEnable(); pooledBlock.gameObject.GetComponent <BlockScript>().childPos = new int[pooledBlock.transform.childCount]; foreach (MeshFilter b in pooledBlock.GetComponentsInChildren <MeshFilter>()) { pooledBlock.gameObject.GetComponent <BlockScript>().childPos[i] = tempEx; b.gameObject.transform.localPosition = PlatformTurnScript.instance.BlockPos[tempEx]; b.gameObject.transform.localRotation = Quaternion.Euler(PlatformTurnScript.instance.BlockRot[tempEx]); tempEx = (tempEx == 0) ? tempEx = RandomPos.ChooseOne(1, 2) : (tempEx == 1) ? tempEx = RandomPos.ChooseOne(0, 2) : tempEx = RandomPos.ChooseOne(0, 1); i++; } } return(doubleBlockNum); }