/* private void OnCollisionExit(Collision collision) * { * if (collision.gameObject.layer == blockLayerIndex) * { * enteredCollision = false; * } * }*/ public void ChangeToBersek() { isOnStrike = true; mode = (int)Mode.bulletProof; bulletProofSpeed = PlayerAccelerator.GetPlayerNormalSpeed(initialSpeed) + modeSpeedIncrease; GameConst.instance.gatheredPower = 0; pointIndex += 1; strikeConstant += 1; uIScript.energySlider.gameObject.SetActive(false); BPS.gameObject.SetActive(true); //RayCalculator(modeSpeedIncrease); }
public void StartAll() { rb.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezeRotation; this.enabled = true; float z = transform.position.z - 15f; transform.position = new Vector3(0, height, z); transform.localScale = initialScale; speed = new Vector3(0f, 0f, PlayerAccelerator.GetPlayerNormalSpeed(initialSpeed)); changeToNormal(); SetPlayerStateForward(); energyTot = GameConst.instance.energyTime / 3f; this.gameObject.GetComponent <MeshRenderer>().enabled = true; }
public void changeToNormal() { isOnStrike = false; normalSpeed = PlayerAccelerator.GetPlayerNormalSpeed(initialSpeed); mode = (int)Mode.normal; energyTot = GameConst.instance.energyTime / 3f; strike = 0; strikeConstant = 0; pointIndex = 1; bulletHits = 0; uIScript.energySlider.gameObject.SetActive(true); BPS.gameObject.SetActive(false); //RayCalculator(modeSpeedIncrease); }
//_________________________METHODS___________________________ private void Awake() { if (instance == null) { //Debug.Log("Player created1"); instance = this; } else { //Debug.LogError("New player destroyed"); Destroy(this.gameObject); } initialSpeed = 85f; speed = new Vector3(0f, 0f, PlayerAccelerator.GetPlayerNormalSpeed(initialSpeed)); Debug.LogWarning("Player speed is : " + speed.z); mode = (int)Mode.normal; }
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(); }
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(); }
//This is used for Endless mode level ending private IEnumerator LevelChangeState(float PlayerSpeedLimit, float PlayerSpeed) { if (!isStarted) { yield return(new WaitUntil(() => blocks[0] != null)); isStarted = true; isGameOn = true; uIScript.startGame(); Time.timeScale = 1f; } else { yield return(new WaitForSeconds(.3f)); } playerLock = true; ObjectPooler.SharedInstance.CreateObjects("BrokenBlock", GameObject.FindWithTag("ALLPLATFORM").transform, blockNumber); BlockChanger(); HollowSetter(blocks[0].gameObject.transform.position.z - 2f); gunScript.passedBlock = 0; //Debug.Log("Top hızlanmaya baslıyor. Top hızı :" + Player.instance.speed.z); float speedRate = 5f; float waitTime = .01f; while (!PlayerAccelerator.PlayerFastEnough(Player.instance.speed.z, PlayerSpeedLimit)) { Player.instance.speed.z += speedRate; yield return(new WaitForSeconds(waitTime)); } yield return(new WaitUntil(() => Player.instance.transform.position.z >= GameObject.FindWithTag("LevelHollows").transform.GetChild(GameObject.FindWithTag("LevelHollows").transform.childCount - 12).transform.position.z)); while (!PlayerAccelerator.PlayerNormalSpeed(Player.instance.speed.z, PlayerSpeed)) { if (PlayerSpeed + 70f >= Player.instance.speed.z && !gunScript.isShooting) { gunScript.blockNumb = 0; gunScript.totBulletSended = 0; gunScript.StartGun(); waitTime = .03f; } Player.instance.speed.z -= speedRate; yield return(new WaitForSeconds(waitTime)); } Player.instance.bulletProofSpeed = PlayerAccelerator.GetPlayerNormalSpeed(Player.instance.initialSpeed) + (Player.instance.modeSpeedIncrease) + ((Player.instance.strikeConstant - 1) * 2f); int m = Player.instance.mode; Player.instance.speed.z = (m == (int)Player.Mode.normal) ? PlayerAccelerator.GetPlayerNormalSpeed(Player.instance.initialSpeed) : Player.instance.bulletProofSpeed; //Player.instance.RayCalculator(0); yield return(new WaitUntil(() => Player.instance.gameObject.transform.position.z >= blocks[0].gameObject.transform.position.z - 35f)); playerLock = false; yield return(new WaitUntil(() => Player.instance.gameObject.transform.position.z >= blocks[0].gameObject.transform.position.z - 15f)); //Player.instance.gameObject.transform.position.z >= blocks[0].gameObject.transform.position.z - 10f); isLevel = true; GameObject.FindWithTag("LevelHollows").transform.position = new Vector3(0f, 0f, LastPosOfArray + 80f); CoinsScript.IncreaseAndActivateCoins(GameObject.FindWithTag("Coins")); AddLevelHollow(2); //createNewLevel = false; StopCoroutine(LevelChangeState(PlayerSpeedLimit, PlayerSpeed)); }