override protected void Spawn() { //50% шанс выпадения огненного шара, при том, что два раза подряд выпасть он не может isFireball = Random.value < .5f && !isFireball ? true : false; if (isFireball) { //Рандомно выбирается какой (сверху или снизу) switch (Random.Range(0, 2)) { case 0: ElementsPool.PickFromPool("WithBottomFireBall", _transform.position, parent: _transform.parent); break; case 1: ElementsPool.PickFromPool("WithTopFireBall", _transform.position, parent: _transform.parent); break; } } else { ElementsPool.PickFromPool("Simple_2", _transform.position, parent: _transform.parent); } //Двигается спавнер currPosition.x += TILE_LENGTH; _transform.localPosition = currPosition; }
override protected void Spawn() { //60% шанс выпадения врага, при том, что два раза подряд выпасть он не может isEnemy = Random.value < .6f && !isEnemy ? true : false; if (isEnemy) { //Рандомно выбирается какой (змеи, робот или мина) switch (Random.Range(0, 3)) { case 0: ElementsPool.PickFromPool("WithSnakes", _transform.position, parent: _transform.parent); break; case 1: ElementsPool.PickFromPool("WithRobot", _transform.position, parent: _transform.parent); break; case 2: ElementsPool.PickFromPool("WithMine", _transform.position, parent: _transform.parent); break; } } else { ElementsPool.PickFromPool("Simple_3", _transform.position, parent: _transform.parent); } //Двигается спавнер currPosition.x += TILE_LENGTH; _transform.localPosition = currPosition; }
override protected void SpawnSafe() { //Спавн обычной платформы из пула ElementsPool.PickFromPool("Simple_3", _transform.position, parent: _transform.parent); //Двигается спавнер currPosition.x += TILE_LENGTH; _transform.localPosition = currPosition; }
public void Activate(string powerUp) { switch (powerUp) { case "FastRun": spawner.ActivateFastRun(); isFastRun = true; InGameGUI.Instance.StartPowerUp(powerUp, fastRunTimer); break; case "DoubleCoins": spawner.ActivateDoubleCoins(); isDoubleCoin = true; InGameGUI.Instance.StartPowerUp(powerUp, doubleCoinTimer); break; case "Shield": shield = objectPooler.PickFromPool("Shield", _PTransform); isShield = true; if (!GameState.isLearning) { InGameGUI.Instance.StartPowerUp(powerUp, shieldTimer); } else { InGameGUI.Instance.StartPowerUp(powerUp, 15f); } break; case "Magnet": magnet = objectPooler.PickFromPool("Magnet", _PTransform.position, Quaternion.identity, _PTransform.parent); isMagnet = true; InGameGUI.Instance.StartPowerUp(powerUp, magnetTimer); break; default: Debug.Log("Wrong name of power up!"); break; } }
override protected void Spawn() { //40% шанс выпадения шипа, при том, что два раза подряд выпасть он не может isSpike = Random.value < .4f && !isSpike ? true : false; if (!isSpike) { ElementsPool.PickFromPool("Simple_1", _transform.position, parent: _transform.parent); } else { ElementsPool.PickFromPool("WithSpike", _transform.position, parent: _transform.parent); } //Двигается спавнер currPosition.x += TILE_LENGTH; _transform.localPosition = currPosition; }
private void Start() { data = DataManager.Instance.GetUserData(); isDoubleCoin = false; laserAttackAfter = Random.Range(80, 101); topCoordY = 20f; spawnIn = 40f; _transform = transform; _localPosition = _transform.localPosition; isCoin = false; isDiamond = true; isLaserAttack = false; isSpike = true; objectPooler = ElementsPool.Instance; if (!data.isFirstTime) { currentWave = new PlatformType[6] { PlatformType.Normal, PlatformType.Empty, PlatformType.Empty, PlatformType.Empty, PlatformType.Empty, PlatformType.Empty }; objectPooler.PickFromPool("Normal", spawnPoints[0].position, spawnPoints[0].rotation, transform.parent); } else { GameObject learn = Instantiate(learning, transform.parent); foreach (Platform plat in learn.GetComponentsInChildren <Platform>()) { plat.GetComponent <Renderer>().sharedMaterial = SkinManager.platformMat; } _localPosition.y -= 1.5f * 49f; _transform.localPosition = _localPosition; currentWave = new PlatformType[6] { PlatformType.Empty, PlatformType.Empty, PlatformType.Empty, PlatformType.Normal, PlatformType.Empty, PlatformType.Empty }; objectPooler.PickFromPool("Normal", spawnPoints[3].position, spawnPoints[3].rotation, transform.parent); } _localPosition.y -= 1.5f; _transform.localPosition = _localPosition; spawnerDistance = Mathf.Abs(topCoordY - _localPosition.y); while (spawnerDistance <= spawnIn) { if (isFastRun) { currentWave = GenerateFastWaveFromPrevious(currentWave); SpawnWaveWithoutEnemy(currentWave, isDoubleCoin); } else { currentWave = GenerateNormalWaveFromPrevious(currentWave); SpawnWave(currentWave, isDoubleCoin); } //Move to next position _transform.localPosition = _localPosition; spawnerDistance = Mathf.Abs(topCoordY - _localPosition.y); } StartCoroutine("Spawn"); }
IEnumerator LaserAttack() { while (GameState.playerPositionY < targetPlayerPosition - 2) { yield return(null); } anim.Play("LaserAttack"); while (GameState.playerPositionY < targetPlayerPosition) { yield return(null); } float laserCount = Random.Range(4, 9); while (laserCount > 0) { Laser laser = objectPooler.PickFromPool("Laser", new Vector3(spawnPoints[GameState.playerPositionX].position.x, 0), Quaternion.identity, content).GetComponent <Laser>(); while (laser.gameObject.activeSelf && !laser.isOver) { yield return(new WaitForSeconds(.1f)); } --laserCount; yield return(null); } laserAttackAfter = GameState.score + Random.Range(80, 101); isLaserAttack = false; }