private void CheckCoreHP() { //initialization for phase B if (coreA == null) { bossState = _bossState.PHASE_B_INITIALIZE; currentShootQuantity = 0; shooterIndex = 0; phaseIndex = 0; nextShoot1 = 0; nextShoot2 = 0; rotateCoreB = true; for (int i = 0; i < laser.Length; i++) { laser[i].GetComponent <LaserBeam>().canFire = false; laser[i].GetComponent <LaserBeam>().laserOn = false; laser[i].GetComponent <LaserBeam>().CancelInvoke(); } if (isFiringLaser) { isFiringLaser = false; for (int i = 0; i < laser.Length; i++) { laser[i].GetComponent <LaserBeam>().stopFiring(); } } nextPhaseTime = Time.time; //add explosions and stuff coreB.SetActive(true); } }
private void BossDead() { if (coreB == null) { bossState = _bossState.DEAD; moveBoss = false; for (int i = 0; i < laser.Length; i++) { laser[i].GetComponent <LaserBeam>().canFire = false; laser[i].GetComponent <LaserBeam>().laserOn = false; laser[i].GetComponent <LaserBeam>().CancelInvoke(); } if (isFiringLaser) { isFiringLaser = false; for (int i = 0; i < laser.Length; i++) { laser[i].GetComponent <LaserBeam>().stopFiring(); } } Camera.main.GetComponent <CameraMovement>().moveSpeed = new Vector2(0, 0); //add explosions and stuff StartCoroutine(BossDie()); StartCoroutine(RandomExplosions()); } }
void Start() { //setting boss state when spawned bossState = _bossState.SPAWNING; //initialization coreBRB2D = coreB.GetComponent <Rigidbody2D>(); nextPhaseTime = Time.time; currentShootQuantity = 0; phaseIndex = 0; nextShoot1 = -999; nextShoot2 = -999; firstShot = -999; changeShootDirectionA2 = true; moveBoss = false; audioManager = AudioManager.instance; flasher = GameObject.Find("Canvas").transform.Find("Flash").gameObject; if (audioManager == null) { Debug.LogError("AudioManager not found in the scene!!!"); } try { player = GameObject.Find("Player").gameObject; playerPosition = new Vector2(player.transform.position.x, player.transform.position.y); } catch { //player is dead, do nothing } //set core states coreA.SetActive(true); coreB.SetActive(false); }
private void BossDead() { if (core[0] == null && core[1] == null && core[2] == null) { bossState = _bossState.DEAD; moveBoss = false; StartCoroutine(BossDie()); StartCoroutine(RandomExplosions()); } }
void Start() { //setting boss state when spawned bossSuperstate = _bossState.SPAWNING; nextPhaseTime = Time.time; currentShootQuantity = 0; shooterIndex = 0; phaseIndex = 0; nextShoot1 = -999; nextShoot2 = -999; moveBoss = false; flasher = GameObject.Find("Canvas").transform.Find("Flash").gameObject; audioManager = AudioManager.instance; if (audioManager == null) { Debug.LogError("AudioManager not found in the scene!!!"); } try { player = GameObject.Find("Player").gameObject; playerPosition = new Vector2(player.transform.position.x, player.transform.position.y); } catch { //player is dead, do nothing } //set core to be invulnerable for (int i = 0; i < 2; i++) { if (innerCores[i].gameObject != null) { innerCores[i].transform.tag = "InvulEnemy"; } if (outerCores[i].gameObject != null) { outerCores[i].transform.tag = "InvulEnemy"; } } if (centerCore.gameObject != null) { centerCore.transform.tag = "InvulEnemy"; } }
private bool ChangePhaseOnBullet(int _maxShootQuantity, _bossState[] phaseAlgorithm) { if (currentShootQuantity >= _maxShootQuantity) { currentShootQuantity = 0; shooterIndex = 0; bossState = phaseAlgorithm[phaseIndex]; phaseIndex++; if (phaseIndex >= phaseAlgorithm.Length) { phaseIndex = 0; } nextShoot1 = Time.time; nextShoot2 = Time.time; firstShot = Time.time; nextPhaseTime = Time.time; bladeTime = Time.time; return(true); } else { return(false); } }
private void ChangePhaseOnTime(float phaseTime, _bossState[] phaseAlgorithm) { if (Time.time > nextPhaseTime + phaseTime) { currentShootQuantity = 0; shooterIndex = 0; bossState = phaseAlgorithm[phaseIndex]; phaseIndex++; if (phaseIndex >= phaseAlgorithm.Length) { phaseIndex = 0; } nextShoot1 = Time.time; nextShoot2 = Time.time; firstShot = Time.time; nextPhaseTime = Time.time; isFiringLaser = false; for (int i = 0; i < laser.Length; i++) { laser[i].GetComponent <LaserBeam>().canFire = false; laser[i].GetComponent <LaserBeam>().laserOn = false; } } }
void FixedUpdate() { //find player in case player is dead try { if (player == null) { player = GameObject.Find("Player").gameObject; } playerPosition = new Vector2(player.transform.position.x, player.transform.position.y); } catch { //player is dead, do nothing } //move boss //float sinMovement = sinAmplitude * Easing.Sinusoidal.InOut(sinCounter); if (moveBoss == true) { transform.position = new Vector3(_bossMovement.x + transform.position.x, _bossMovement.y + transform.position.y, 0); //change y direction if (transform.position.y >= 3.5f + Camera.main.transform.position.y || transform.position.y >= 1.0f + playerPosition.y) { _bossMovement.y = -bossMovement.y * Random.Range(0.7f, 1f); } else if (transform.position.y <= -3.5f + Camera.main.transform.position.y || transform.position.y <= -1.0f + playerPosition.y) { _bossMovement.y = bossMovement.y * Random.Range(0.7f, 1f); } //change x direction if (transform.position.x >= 5f + Camera.main.transform.position.x) { _bossMovement.x = -bossMovement.x * Random.Range(0.7f, 1f); } else if (transform.position.x <= 3f + Camera.main.transform.position.x) { _bossMovement.x = bossMovement.x * Random.Range(0.7f, 1f); } } //make cores vulnerable if (Time.time > initialCoreTime + coreInvulTime && !isCoreVulnerable) { isCoreVulnerable = true; for (int i = 0; i < coreShieldAnim.Length; i++) { coreShieldAnim[i].enabled = true; core[i].transform.tag = "Enemy"; } } switch (bossState) { case (_bossState.SPAWNING): //to change boss phase if (Time.time > nextPhaseTime + spawnTime) { nextPhaseTime = Time.time; //set boss state bossState = phaseAlgorithm[phaseIndex]; phaseIndex++; //let boss move in vertical direction moveBoss = true; initialBossPosition = transform.position; bossBodyAnim.enabled = false; for (int i = 0; i < coreShieldAnim.Length; i++) { coreShieldAnim[i].Play("BossCoreReveal"); } //enable colliders after spawning gameObject.GetComponent <PolygonCollider2D>().enabled = true; for (int i = 0; i < core.Length; i++) { core[i].GetComponent <PolygonCollider2D>().enabled = true; } for (int i = 0; i < blade.Length; i++) { blade[i].GetComponent <PolygonCollider2D>().enabled = true; } } break; case (_bossState.PHASE_1): //shooting algorithm if (Time.time > nextShoot1 + shootInterval1 && Time.time > firstShot + timeBeforeFirstShot1) { //check if shooterIndex is overflowing before shooting if (shooterIndex >= core.Length) { shooterIndex = 0; } //if current selected core is dead, move to next core int coreCursor = 0; while (core[shooterIndex] == null && coreCursor < core.Length) { shooterIndex++; //check if shooterIndex is overflowing before shooting if (shooterIndex >= core.Length) { shooterIndex = 0; } //increase core cursor index ++coreCursor; } nextShoot1 = Time.time; //increase shoot counter for phase check and change currentShootQuantity++; //spread shot from cores to player if (core[shooterIndex] != null) { Vector3 distToPlayer = new Vector3(playerPosition.x, playerPosition.y, transform.position.z) - core[shooterIndex].transform.position; ShootInDirection.ShootEqualSpread(normalBullet, shotQuantity1, deviation1, core[shooterIndex].transform.position, distToPlayer, bulletSpeed1); audioManager.PlaySound(spreadBulletSoundName); //increase shooter index to change where bullets are spawned shooterIndex++; } else { Debug.Log("Core is dead"); } } //phase changer ChangePhaseOnBullet(maxShootQuantity1, phaseAlgorithm); //check if all cores are still alive BossDead(); break; case (_bossState.PHASE_2): if (!isBladeOpen && Time.time > timeBeforeBladesOpen + bladeTime) { isBladeOpen = true; bladeAnim[0].Play("UmletBladeTopOpen"); bladeAnim[1].Play("UmletBladeBottomOpen"); audioManager.PlaySound(bladeOpenSoundName); } //shooting algorithm if (Time.time > nextShoot1 + shootInterval2 && Time.time > firstShot + timeBeforeFirstShot2) { nextShoot1 = Time.time; //shoot once in general direction of player for both shooters for (int i = 0; i < shooters.Length; i++) { Vector3 spawnPosition = shooters[i].transform.position + new Vector3(shooterBulletSpawnOffset.x, shooterBulletSpawnOffset.y, 0); //find vector from enemy to player Vector3 distToPlayer = new Vector3(playerPosition.x, playerPosition.y, transform.position.z) - shooters[shooterIndex].transform.position; ShootInDirection.Shoot(normalBullet, 1, deviation2, spawnPosition, distToPlayer, bulletSpeed2, false); Instantiate(ShootRecoil, spawnPosition, Quaternion.identity); } shooterAnim[0].Play("UmletShooterTopRecoil"); shooterAnim[1].Play("UmletShooterBottomRecoil"); //play sound audioManager.PlaySound(normalBulletSoundName); //increase shoot quantity currentShootQuantity++; } //phase changer if (ChangePhaseOnBullet(maxShootQuantity2, phaseAlgorithm)) { isBladeOpen = false; bladeAnim[0].Play("UmletBladeTopClose"); bladeAnim[1].Play("UmletBladeBottomClose"); audioManager.PlaySound(bladeCloseSoundName); } //check if all cores are still alive BossDead(); break; case (_bossState.PHASE_3): //movement //sinCounter += sinSpeed; //laser shooter at middle core if (Time.time > nextShoot1 + shootIntervalLaser3 && Time.time > firstShot + timeBeforeFirstLaser3) { nextShoot1 = Time.time; Vector3 spawnPosition = LaserSpawnArea.transform.position; ShootInDirection.Shoot(laser, 1, 0, spawnPosition, Vector2.left, laser.GetComponent <LaserMovement2>().moveSpeed, false); //play sound audioManager.PlaySound(laserSoundName); } //accel shooter from outer cores if (Time.time > nextShoot2 + shootIntervalAccel3 && Time.time > firstShot + timeBeforeFirstAccel3) { nextShoot2 = Time.time; //accel from core int _shooterIndex = 0; while (_shooterIndex == 0 || _shooterIndex == 2) { if (core[_shooterIndex] != null) { Vector3 spawnPosition = core[_shooterIndex].transform.position; Vector3 distToPlayer = new Vector3(playerPosition.x, playerPosition.y, transform.position.z) - core[_shooterIndex].transform.position; //shoot accel bullet from core to player ShootInDirection.Shoot(accelBullet, 1, 0, spawnPosition, distToPlayer.normalized, accelBulletSpeed, true); } //increase shooter index _shooterIndex += 2; } //play sound audioManager.PlaySound(accelBulletSoundName); //increase shoot quantity counter currentShootQuantity++; } //phase changer ChangePhaseOnBullet(maxShootQuantity3, phaseAlgorithm); //if (ChangePhaseOnBullet(maxShootQuantity3, phaseAlgorithm) && Mathf.Abs(sinMovement) >= 0.99) //{ // sinCounter = 0; //} //check if all cores are still alive BossDead(); break; case (_bossState.DEAD): break; case (_bossState.DEBUG_DEAD): bossState = _bossState.DEAD; moveBoss = false; StartCoroutine(BossDie()); StartCoroutine(RandomExplosions()); break; } }
void Start() { //setting boss state when spawned bossState = _bossState.SPAWNING; nextPhaseTime = Time.time; initialCoreTime = Time.time; currentShootQuantity = 0; phaseIndex = 0; nextShoot1 = -999; nextShoot2 = -999; firstShot = -999; sinCounter = 0; moveBoss = false; isCoreVulnerable = false; _bossMovement = bossMovement; isBladeOpen = false; //disable colliders during spawning gameObject.GetComponent <PolygonCollider2D>().enabled = false; for (int i = 0; i < core.Length; i++) { core[i].GetComponent <PolygonCollider2D>().enabled = false; } for (int i = 0; i < blade.Length; i++) { blade[i].GetComponent <PolygonCollider2D>().enabled = false; } //animators bossBodyAnim = GetComponent <Animator>(); for (int i = 0; i < core.Length; i++) { coreAnim[i] = core[i].GetComponent <Animator>(); coreShieldAnim[i] = coreShield[i].GetComponent <Animator>(); } for (int i = 0; i < blade.Length; i++) { bladeAnim[i] = blade[i].GetComponent <Animator>(); shooterAnim[i] = shooters[i].GetComponent <Animator>(); } bossBodyAnim.Play("IntroBossAnim"); for (int i = 0; i < coreAnim.Length; i++) { coreAnim[i].Play("UmletCoreIntro"); coreShieldAnim[i].Play("UmletCoreShieldIntro"); } bladeAnim[0].Play("UmletBladeTopIntro"); bladeAnim[1].Play("UmletBladeBottomIntro"); shooterAnim[0].Play("UmletShooterTopIntro"); shooterAnim[1].Play("UmletShooterBottomIntro"); audioManager = AudioManager.instance; if (audioManager == null) { Debug.LogError("AudioManager not found in the scene!!!"); } flasher = GameObject.Find("Canvas").transform.Find("Flash").gameObject; audioManager.PlaySound(introSoundName); try { player = GameObject.Find("Player").gameObject; playerPosition = new Vector2(player.transform.position.x, player.transform.position.y); } catch { //player is dead, do nothing } //make core invulnerable for (int i = 0; i < core.Length; i++) { core[i].transform.tag = "InvulEnemy"; } }
void FixedUpdate() { //find player in case player is dead try { if (player == null) { player = GameObject.Find("Player").gameObject; } playerPosition = new Vector2(player.transform.position.x, player.transform.position.y); } catch { //player is dead, do nothing } //add camera movement to boss if (moveBoss == true) { transform.position += new Vector3(Camera.main.GetComponent <CameraMovement>().moveSpeed.x, Camera.main.GetComponent <CameraMovement>().moveSpeed.y, 0); } //rotate core B if (rotateCoreB && coreB != null) { coreB.transform.parent.transform.Rotate(0, 0, rotateSpeed); } switch (bossState) { case (_bossState.SPAWNING): if (Time.time > nextPhaseTime + spawnTime) { nextPhaseTime = Time.time; //set boss state bossState = phaseAAlgorithm[phaseIndex]; phaseIndex++; //set core to be vulnerable coreAShieldAnim.Play("BossCoreReveal"); coreA.transform.tag = "Enemy"; //change core phase //core.GetComponent<RicochetCoreMovement>().enemyState = RicochetCoreMovement._enemyState.PHASE1; } break; case (_bossState.PHASE_A1): //shooting algorithm if (Time.time > nextShoot1 + shootIntervalA1 && Time.time > firstShot + timeBeforeFirstShotA1) { nextShoot1 = Time.time; //increase shoot counter currentShootQuantity++; //find vector from enemy to player Vector3 distToPlayer = new Vector3(playerPosition.x, playerPosition.y, transform.position.z) - outerShooters[shooterIndex].transform.position; Vector3 spawnPosition = outerShooters[shooterIndex].transform.position + new Vector3(bulletSpawnOffset.x, bulletSpawnOffset.y, 0); //shoot ShootInDirection.ShootEqualSpread(ricochetBullet, shotQuantityA1, deviationA1, spawnPosition, distToPlayer, ricochetBullet.GetComponent <RicochetBulletMovement>().speed); //play sound audioManager.PlaySound(ricochetSpreadSoundName); //increase shooter index to change where bullets are spawned shooterIndex++; if (shooterIndex >= outerShooters.Length) { shooterIndex = 0; } } //phase changer ChangePhaseOnBullet(maxShootQuantityA1, phaseAAlgorithm); //check core hp for phase B CheckCoreHP(); break; case (_bossState.PHASE_A2): if (Time.time > nextShoot1 + shootIntervalShortA2 && Time.time > nextShoot2 + shootIntervalLongA2) { nextShoot1 = Time.time; //change shoot direction after each 'wave' of shots if (changeShootDirectionA2) { changeShootDirectionA2 = false; _tempRotate = Quaternion.AngleAxis(Random.Range(-deviationA2, deviationA2), Vector3.forward); } //shoot a few times in mirrored directions for both shooters Vector3 spawnPosition = outerShooters[0].transform.position + new Vector3(bulletSpawnOffset.x, bulletSpawnOffset.y, 0); rotatedUnitVector = _tempRotate * shootDirectionA2.normalized; ShootInDirection.Shoot(ricochetInvulBullet, 1, 0, spawnPosition, rotatedUnitVector.normalized, ricochetInvulBullet.GetComponent <RicochetBulletMovement>().speed, true); spawnPosition = outerShooters[1].transform.position + new Vector3(bulletSpawnOffset.x, bulletSpawnOffset.y, 0); rotatedUnitVector = Vector2.Reflect(rotatedUnitVector, Vector3.down); ShootInDirection.Shoot(ricochetInvulBullet, 1, 0, spawnPosition, rotatedUnitVector.normalized, ricochetInvulBullet.GetComponent <RicochetBulletMovement>().speed, true); //play sound audioManager.PlaySound(ricochetInvulBulletSoundName); // increase shoot quantity after each 'wave' of shots _shotQuantityA2++; if (_shotQuantityA2 >= shotQuantityA2) { nextShoot2 = Time.time; _shotQuantityA2 = 0; currentShootQuantity++; changeShootDirectionA2 = true; } } //phase changer ChangePhaseOnBullet(maxShootQuantityA2, phaseAAlgorithm); //check core hp for phase B CheckCoreHP(); break; case (_bossState.PHASE_A3): //laser shooter using Laser2D if (!isFiringLaser && Time.time > nextShoot1 + timeBeforeFirstLaserA3) { isFiringLaser = true; for (int i = 0; i < laser.Length; i++) { laser[i].GetComponent <LaserBeam>().rayDuration = laserDurationA3; laser[i].GetComponent <LaserBeam>().canFire = true; } //play charge up sound audioManager.PlaySound(chargeUpSoundName); } //snipe shooter if (Time.time > nextShoot2 + shootIntervalSnipeA3 && Time.time > firstShot + timeBeforeFirstSnipeA3) { nextShoot2 = Time.time; chargeUpAnim.Play("ChargeUp"); //snipe from core StartCoroutine(ShootSnipeLaser()); //play charge up sound audioManager.PlaySound(chargeUpSoundName); //increasse shoot quantity counter currentShootQuantity++; } //phase changer ChangePhaseOnTime(laserDurationA3 + timeBeforeFirstLaserA3, phaseAAlgorithm); //check core hp for phase B CheckCoreHP(); break; case (_bossState.PHASE_B_INITIALIZE): //accel core B rotation rotateSpeed += rotateAccel; if (Time.time > nextPhaseTime + timeBeforeMove) { //redirect camera Camera.main.GetComponent <CameraMovement>().moveSpeed = new Vector2(-0.024f, 0f); //set core to be vulnerable coreBShieldAnim.Play("BossCoreReveal"); coreB.transform.tag = "Enemy"; //set boss state bossState = phaseBAlgorithm[phaseIndex]; moveBoss = true; phaseIndex++; } break; case (_bossState.PHASE_B1): //shooting algorithm if (Time.time > nextShoot1 + shootIntervalA1 && Time.time > firstShot + timeBeforeFirstShotB1) { nextShoot1 = Time.time; //increase shoot counter currentShootQuantity++; if (shooterIndex == 0) { rotatedUnitVector = Quaternion.AngleAxis(Random.Range(-deviationB1, deviationB1), Vector3.forward) * shootDirectionB1.normalized; } else { rotatedUnitVector = Vector2.Reflect(rotatedUnitVector, Vector3.down); } //shoot at direction Vector3 spawnPosition = outerShooters[shooterIndex].transform.position + new Vector3(bulletSpawnOffset.x, bulletSpawnOffset.y, 0); ShootInDirection.ShootEqualSpread(ricochetBullet, shotQuantityB1, deviationB1, spawnPosition, rotatedUnitVector.normalized, ricochetBullet.GetComponent <RicochetBulletMovement>().speed); //play sound audioManager.PlaySound(ricochetSpreadSoundName); //increase shooter index to change where bullets are spawned shooterIndex++; if (shooterIndex >= outerShooters.Length) { shooterIndex = 0; } } //phase changer ChangePhaseOnBullet(maxShootQuantityB1, phaseBAlgorithm); //check if boss is dead BossDead(); break; case (_bossState.PHASE_B2): //laser shooter using Laser2D if (!isFiringLaser && Time.time > nextShoot1 + timeBeforeLaserB2) { isFiringLaser = true; for (int i = 0; i < laser.Length; i++) { laser[i].GetComponent <LaserBeam>().rayDuration = phaseB2Time; laser[i].GetComponent <LaserBeam>().canFire = true; } //play charge up sound audioManager.PlaySound(chargeUpSoundName); } //ricochet shooter if (Time.time > nextShoot2 + shootIntervalSnipeB2 && Time.time > firstShot + timeBeforeFirstShotB2) { nextShoot2 = Time.time; //shoot from core Vector3 spawnPosition1 = coreB.transform.position; Vector3 distToPlayer = new Vector3(playerPosition.x, playerPosition.y, transform.position.z) - coreB.transform.position; ShootInDirection.Shoot(spreadBullet, 1, deviationB2, coreB.transform.position, distToPlayer, spreadBullet.GetComponent <RicochetBulletMovement>().speed, true); //play sound audioManager.PlaySound(ricochetSlowBulletSoundName); //increase shoot quantity counter currentShootQuantity++; } //phase changer ChangePhaseOnTime(phaseB2Time + timeBeforeFirstShotB2, phaseBAlgorithm); //check if boss is dead BossDead(); break; case (_bossState.PHASE_B3): //spread shooting if (Time.time > nextShoot1 + shootIntervalB3 && Time.time > firstShot + timeBeforeFirstShotB3) { nextShoot1 = Time.time; //shoot from core Vector3 spawnPosition = coreB.transform.position; ShootInDirection.Shoot(spreadBullet, 1, deviationB3, spawnPosition, Vector3.left, spreadBullet.GetComponent <RicochetBulletMovement>().speed, false); //play sound audioManager.PlaySound(ricochetSlowBulletSoundName); } //phase changer ChangePhaseOnTime(phaseB3Time + timeBeforeFirstShotB3, phaseBAlgorithm); //check if boss is dead BossDead(); break; case (_bossState.DEAD): break; } }
void FixedUpdate() { //find player in case player is dead try { if (player == null) { player = GameObject.Find("Player").gameObject; } //test player = GameObject.Find("Player").gameObject; playerPosition = new Vector2(player.transform.position.x, player.transform.position.y); } catch { //player is dead, do nothing } //add camera movement to boss //transform.position += new Vector3(Camera.main.GetComponent<CameraMovement>().moveSpeed.x, Camera.main.GetComponent<CameraMovement>().moveSpeed.y, 0); //check cores for phase change if (bossSuperstate == _bossState.SPAWNING || bossSuperstate == _bossState.DEAD) { //do nothing } else if (bossSuperstate != _bossState.DEAD && outerCores[0].gameObject == null && outerCores[1].gameObject == null && innerCores[0].gameObject == null && innerCores[1].gameObject == null && centerCore == null) { bossSuperstate = _bossState.DEAD; StartCoroutine(BossDie()); StartCoroutine(RandomExplosions()); } else if (!hasBeenA && bossSuperstate != _bossState.PHASE_A && outerCores[0].gameObject != null && outerCores[1].gameObject != null && innerCores[0].gameObject != null && innerCores[1].gameObject != null && centerCore != null) { hasBeenA = true; bossSuperstate = _bossState.PHASE_A; StartCoroutine(InvulBoss()); //reset all variables currentShootQuantity = 0; shooterIndex = 0; phaseIndex = 1; nextShoot1 = Time.time + phaseChangeInvulDuration; nextShoot2 = Time.time + phaseChangeInvulDuration; nextPhaseTime = Time.time + phaseChangeInvulDuration; } else if (!hasBeenF && bossSuperstate != _bossState.PHASE_F && outerCores[0].gameObject == null && outerCores[1].gameObject == null && innerCores[0].gameObject == null && innerCores[1].gameObject == null && centerCore != null) { hasBeenF = true; hasBeenC = true; bossSuperstate = _bossState.PHASE_F; StartCoroutine(InvulBoss()); //reset all variables currentShootQuantity = 0; shooterIndex = 0; phaseIndex = 0; nextShoot1 = Time.time + phaseChangeInvulDuration; nextShoot2 = Time.time + phaseChangeInvulDuration; nextPhaseTime = Time.time + phaseChangeInvulDuration; } else if (!hasBeenD && bossSuperstate != _bossState.PHASE_D && outerCores[0].gameObject == null && outerCores[1].gameObject == null && centerCore == null) { hasBeenD = true; hasBeenB = true; hasBeenC = true; bossSuperstate = _bossState.PHASE_D; StartCoroutine(InvulBoss()); //reset all variables currentShootQuantity = 0; shooterIndex = 0; phaseIndex = 1; nextShoot1 = Time.time + phaseChangeInvulDuration; nextShoot2 = Time.time + phaseChangeInvulDuration; nextPhaseTime = Time.time + phaseChangeInvulDuration; } else if (!hasBeenE && bossSuperstate != _bossState.PHASE_E && innerCores[0].gameObject == null && innerCores[1].gameObject == null && centerCore == null) { hasBeenE = true; hasBeenB = true; bossSuperstate = _bossState.PHASE_E; StartCoroutine(InvulBoss()); //reset all variables currentShootQuantity = 0; shooterIndex = 0; phaseIndex = 1; nextShoot1 = Time.time + phaseChangeInvulDuration; nextShoot2 = Time.time + phaseChangeInvulDuration; nextPhaseTime = Time.time + phaseChangeInvulDuration; } else if (!hasBeenB && bossSuperstate != _bossState.PHASE_B && centerCore == null) { hasBeenB = true; bossSuperstate = _bossState.PHASE_B; StartCoroutine(InvulBoss()); //reset all variables currentShootQuantity = 0; shooterIndex = 0; phaseIndex = 1; nextShoot1 = Time.time + phaseChangeInvulDuration; nextShoot2 = Time.time + phaseChangeInvulDuration; nextPhaseTime = Time.time + phaseChangeInvulDuration; } else if (!hasBeenC && bossSuperstate != _bossState.PHASE_C && outerCores[0].gameObject == null && outerCores[1].gameObject == null) { hasBeenC = true; bossSuperstate = _bossState.PHASE_C; StartCoroutine(InvulBoss()); //reset all variables currentShootQuantity = 0; shooterIndex = 0; phaseIndex = 1; nextShoot1 = Time.time + phaseChangeInvulDuration; nextShoot2 = Time.time + phaseChangeInvulDuration; nextPhaseTime = Time.time + phaseChangeInvulDuration; } switch (bossSuperstate) { case (_bossState.SPAWNING): //change phase if (Time.time > nextPhaseTime + spawnTime) { nextPhaseTime = Time.time; bossSuperstate = _bossState.PHASE_A; bossSubstateA = phaseAAlgorithm[phaseIndex]; ++phaseIndex; } break; case (_bossState.PHASE_A): switch (bossSubstateA) { case (_bossStateA.PHASE_1): //laser shooter if (!hasShotA1 && Time.time >= nextPhaseTime + firstShootA1) { hasShotA1 = true; GameObject _shooter = Instantiate(laserShooter, centerCore.transform.position, transform.rotation); _shooter.transform.parent = gameObject.transform; audioManager.PlaySound(laserShooterSoundName); ShieldBoss(); } //change phase if (Time.time >= nextPhaseTime + invulTimeA1 + firstShootA1) { UnshieldBoss(); hasShotA1 = false; currentShootQuantity = 0; shooterIndex = 0; if (phaseIndex >= phaseAAlgorithm.Length) { phaseIndex = 0; } bossSubstateA = phaseAAlgorithm[phaseIndex]; phaseIndex++; nextShoot1 = Time.time; nextShoot2 = Time.time; nextPhaseTime = Time.time; } break; case (_bossStateA.PHASE_2): //spread shoot if (Time.time >= shootIntervalA2 + nextShoot1 + firstShootA2) { nextShoot1 = Time.time - firstShootA2; //change bullet spawn position if (innerCores[0].gameObject == null) { shooterIndex = 1; } else if (innerCores[1].gameObject == null) { shooterIndex = 0; } if (innerCores[shooterIndex].gameObject != null) { Vector3 distToPlayer = new Vector3(playerPosition.x, playerPosition.y, transform.position.z) - innerCores[shooterIndex].transform.position; ShootInDirection.ShootEqualSpread(bigBullet, shotQuantityA2, deviationA2, innerCores[shooterIndex].transform.position, distToPlayer, bulletSpeedA2); } audioManager.PlaySound(bigBulletSoundName); //change bullet spawn position if (innerCores[0].gameObject == null) { shooterIndex = 1; } else if (innerCores[1].gameObject == null) { shooterIndex = 0; } else if (shooterIndex == 0) { ++shooterIndex; } else { shooterIndex = 0; } ++currentShootQuantity; } ChangePhaseAOnBullet(maxShootQuantityA2, phaseAAlgorithm); break; case (_bossStateA.PHASE_3): //missile if (Time.time >= shootIntervalA3 + nextShoot1 + firstShootA3) { nextShoot1 = Time.time - firstShootA3; for (int i = 0; i < 2; i++) { if (outerCores[i].gameObject != null) { Vector3 distToPlayer = new Vector3(playerPosition.x, playerPosition.y, transform.position.z) - outerCores[i].transform.position; Instantiate(homingMissile, outerCores[i].transform.position, Quaternion.Euler(0, 0, 180f)); } } audioManager.PlaySound(homingMissileSoundName); ++currentShootQuantity; } ChangePhaseAOnBullet(maxShootQuantityA3, phaseAAlgorithm); break; } break; case (_bossState.PHASE_B): switch (bossSubstateB) { case (_bossStateB.PHASE_1): //spread shoot if (Time.time >= shootIntervalB1 + nextShoot1 + firstShootB1) { nextShoot1 = Time.time - firstShootB1; //change bullet spawn position if (innerCores[0].gameObject == null) { shooterIndex = 1; } else if (innerCores[1].gameObject == null) { shooterIndex = 0; } if (innerCores[shooterIndex].gameObject != null) { Vector3 distToPlayer = new Vector3(playerPosition.x, playerPosition.y, transform.position.z) - innerCores[shooterIndex].transform.position; ShootInDirection.ShootEqualSpread(bigBullet, shotQuantityA2, deviationA2, innerCores[shooterIndex].transform.position, distToPlayer, bulletSpeedA2); } audioManager.PlaySound(bigBulletSoundName); //change bullet spawn position if (innerCores[0].gameObject == null) { shooterIndex = 1; } else if (innerCores[1].gameObject == null) { shooterIndex = 0; } else if (shooterIndex == 0) { ++shooterIndex; } else { shooterIndex = 0; } ++currentShootQuantity; } ChangePhaseBOnBullet(maxShootQuantityB1, phaseBAlgorithm); break; case (_bossStateB.PHASE_2): //missile if (Time.time >= shootIntervalB2 + nextShoot1 + firstShootB2) { nextShoot1 = Time.time - firstShootB2; for (int i = 0; i < 2; i++) { if (outerCores[i].gameObject != null) { Vector3 distToPlayer = new Vector3(playerPosition.x, playerPosition.y, transform.position.z) - outerCores[i].transform.position; Instantiate(homingMissile, outerCores[i].transform.position, Quaternion.Euler(0, 0, 180f)); } } audioManager.PlaySound(homingMissileSoundName); ++currentShootQuantity; } ChangePhaseBOnBullet(maxShootQuantityB2, phaseBAlgorithm); break; case (_bossStateB.PHASE_3): //bomb if (!hasShotB3 && Time.time >= nextPhaseTime + firstShootB3) { hasShotB3 = true; for (int i = 0; i < 2; i++) { if (outerCores[i].gameObject != null) { GameObject _bomb = Instantiate(bomb, outerCores[i].transform.position, transform.rotation); //_bomb.transform.parent = gameObject.transform; } } audioManager.PlaySound(bombSoundName); ShieldBoss(); } //change phase if (Time.time >= nextPhaseTime + invulTimeB3 + firstShootB3) { UnshieldBoss(); hasShotB3 = false; currentShootQuantity = 0; shooterIndex = 0; if (phaseIndex >= phaseBAlgorithm.Length) { phaseIndex = 0; } bossSubstateB = phaseBAlgorithm[phaseIndex]; phaseIndex++; nextShoot1 = Time.time; nextShoot2 = Time.time; nextPhaseTime = Time.time; } break; } break; case (_bossState.PHASE_C): switch (bossSubstateC) { case (_bossStateC.PHASE_1): //spread shoot if (Time.time >= shootIntervalC1 + nextShoot1 + firstShootC1) { nextShoot1 = Time.time - firstShootC1; //change bullet spawn position if (innerCores[0].gameObject == null) { shooterIndex = 1; } else if (innerCores[1].gameObject == null) { shooterIndex = 0; } if (innerCores[shooterIndex].gameObject != null) { Vector3 distToPlayer = new Vector3(playerPosition.x, playerPosition.y, transform.position.z) - innerCores[shooterIndex].transform.position; ShootInDirection.ShootEqualSpread(bigBullet, shotQuantityC1, deviationC1, innerCores[shooterIndex].transform.position, distToPlayer, bulletSpeedC1); } audioManager.PlaySound(bigBulletSoundName); //change bullet spawn position if (innerCores[0].gameObject == null) { shooterIndex = 1; } else if (innerCores[1].gameObject == null) { shooterIndex = 0; } else if (shooterIndex == 0) { ++shooterIndex; } else { shooterIndex = 0; } ++currentShootQuantity; } ChangePhaseCOnBullet(maxShootQuantityC1, phaseCAlgorithm); break; case (_bossStateC.PHASE_2): //laser shooter if (!hasShotC2 && Time.time >= nextPhaseTime + firstShootC2) { hasShotC2 = true; GameObject _shooter = Instantiate(laserShooter, centerCore.transform.position, transform.rotation); _shooter.transform.parent = gameObject.transform; audioManager.PlaySound(laserShooterSoundName); ShieldBoss(); } //change phase if (Time.time >= nextPhaseTime + invulTimeC2 + firstShootC2) { UnshieldBoss(); hasShotC2 = false; currentShootQuantity = 0; shooterIndex = 0; if (phaseIndex >= phaseCAlgorithm.Length) { phaseIndex = 0; } bossSubstateC = phaseCAlgorithm[phaseIndex]; phaseIndex++; nextShoot1 = Time.time; nextShoot2 = Time.time; nextPhaseTime = Time.time; } break; } break; case (_bossState.PHASE_D): //spread shoot if (Time.time >= shootIntervalD + nextShoot1 + firstShootD) { nextShoot1 = Time.time - firstShootD; //change bullet spawn position if (innerCores[0].gameObject == null) { shooterIndex = 1; } else if (innerCores[1].gameObject == null) { shooterIndex = 0; } if (innerCores[shooterIndex].gameObject != null) { Vector3 distToPlayer = new Vector3(playerPosition.x, playerPosition.y, transform.position.z) - innerCores[shooterIndex].transform.position; ShootInDirection.Shoot(bigBullet, shotQuantityD, deviationD, innerCores[shooterIndex].transform.position, distToPlayer, bulletSpeedD, true); } audioManager.PlaySound(bigBulletSoundName); //change bullet spawn position if (innerCores[0].gameObject == null) { shooterIndex = 1; } else if (innerCores[1].gameObject == null) { shooterIndex = 0; } else if (shooterIndex == 0) { ++shooterIndex; } else { shooterIndex = 0; } ++currentShootQuantity; } break; case (_bossState.PHASE_E): switch (bossSubstateE) { case (_bossStateE.PHASE_1): //missile if (Time.time >= shootIntervalE1 + nextShoot1 + firstShootE1) { nextShoot1 = Time.time - firstShootE1; for (int i = 0; i < 2; i++) { if (outerCores[i].gameObject != null) { Vector3 distToPlayer = new Vector3(playerPosition.x, playerPosition.y, transform.position.z) - outerCores[i].transform.position; Instantiate(homingMissile, outerCores[i].transform.position, Quaternion.Euler(0, 0, 180f)); } } audioManager.PlaySound(homingMissileSoundName); ++currentShootQuantity; } ChangePhaseEOnBullet(maxShootQuantityE1, phaseEAlgorithm); break; case (_bossStateE.PHASE_2): //bomb if (!hasShotE2 && Time.time >= nextPhaseTime + firstShootE2) { hasShotE2 = true; for (int i = 0; i < 2; i++) { if (outerCores[i].gameObject != null) { GameObject _bomb = Instantiate(bomb, outerCores[i].transform.position, transform.rotation); //_bomb.transform.parent = gameObject.transform; } } audioManager.PlaySound(bombSoundName); ShieldBoss(); } //change phase if (Time.time >= nextPhaseTime + invulTimeE2 + firstShootE2) { UnshieldBoss(); hasShotE2 = false; currentShootQuantity = 0; shooterIndex = 0; if (phaseIndex >= phaseEAlgorithm.Length) { phaseIndex = 0; } bossSubstateE = phaseEAlgorithm[phaseIndex]; phaseIndex++; nextShoot1 = Time.time; nextShoot2 = Time.time; nextPhaseTime = Time.time; } break; } break; case (_bossState.PHASE_F): //rotating laser shooter if (Time.time >= shootIntervalF + nextShoot1 + firstShootF) { nextShoot1 = Time.time - firstShootF; GameObject _shooter = Instantiate(rotatingLaserShooter, centerCore.transform.position, transform.rotation); _shooter.transform.parent = gameObject.transform; audioManager.PlaySound(laserShooterSoundName); } break; case (_bossState.DEAD): //do nothing for now break; } }