void EndBattle() { inBossFight = false; inCutscene = true; SeagullFlightController seagullFlight = Seagull.GetComponent <SeagullFlightController>(); seagullFlight.enabled = true; SeagullBossController seagullBoss = Seagull.GetComponent <SeagullBossController>(); seagullBoss.enabled = false; // increment levels Seagull.GetComponent <SeagullFlightController>().currentLevel++; currentLevel++; if (seagullBoss.NUM_OF_ATTACKS < 4) { seagullBoss.NUM_OF_ATTACKS++; } MainCamera.GetComponent <BossFightThirdPersonCameraController>().enabled = false; player.GetComponent <bossControls>().enabled = false; player.GetComponent <movement>().enabled = false; seagullHealthManager.seagullHealth += seagullHealthManager.damageTaken - healthThreshold; seagullHealthManager.damageTaken = 0; Crosshair.SetActive(false); canSpawnCrab = false; DestroyCrabs(); }
void StartBattle() { //ENSURE REMOVAL OF EGGS AND HEALTH TOKENS (TO COMBAT HAVING ONES ON MAP THAT CANT BE REACHED) inCutscene = true; SeagullFlightController seagullFlight = Seagull.GetComponent <SeagullFlightController>(); seagullFlight.enabled = false; SeagullBossController seagullBoss = Seagull.GetComponent <SeagullBossController>(); seagullBoss.enabled = true; //seagullBoss.totalTime = seagullFlight.totalTime; MainCamera.GetComponent <ThirdPersonCameraController>().enabled = false; MainCamera.GetComponent <BossFightThirdPersonCameraController>().enabled = false; MainCamera.GetComponent <Transform>().LookAt(transform); player.transform.position = new Vector3(0, 2, 75); player.transform.LookAt(new Vector3(0, player.transform.position.y, 0)); player.GetComponent <bossControls>().enabled = false; player.GetComponent <movement>().enabled = false; canSpawnCrab = false; DestroyCrabs(); }
void Update() { float delta = Time.deltaTime; if (gameEnded) { activateMenuCountdown -= delta; if (activateMenuCountdown <= 0 && !gameOverMenu.activeSelf) { gameOverMenu.SetActive(true); } } if (TotalScore < 1 && inBossFight && !extraEggSpawned && seagullHealthManager.damageTaken < healthThreshold) { extraEggSpawned = true; SpawnEgg(); } if (player.GetComponent <interaction>().GetPlayerHealth() <= 0 && !gameEnded) { PlayerDeath(); gameEnded = true; Cursor.lockState = CursorLockMode.None; Cursor.visible = true; } scoreValue.text = TotalScore.ToString(); // if both the camera scripts are disabled, look at the seagull (if both are disabled we are in a transition) if (inCutscene) { MainCamera.transform.LookAt(Seagull.transform); } if (inBossFight && Seagull.GetComponent <SeagullBossController>().IsOnGround() && !MainCamera.GetComponent <BossFightThirdPersonCameraController>().enabled) { MainCamera.GetComponent <BossFightThirdPersonCameraController>().enabled = true; } // randomly spawn crabs crabSpawnCountdown -= delta; if (crabSpawnCountdown <= 0 && FirstEggCollected && canSpawnCrab) { SpawnCrab(); crabSpawnCountdown = Random.Range(5, 10); } // randomly spawn health tokens healthTokenSpawnCountdown -= delta; if (FirstEggCollected && healthTokenSpawnCountdown <= 0 && !gameEnded) { SpawnHealthToken(); healthTokenSpawnCountdown = Random.Range(5, healthSpawnTimeThreshold); } /* ============================================ SEAGULL CONTROL ============================================ */ // start boss battle if score threshold satisfied if (CurrentScore > 0 && CurrentScore % fightThreshold == 0 && !inBossFight) { Debug.Log("starting battle"); CurrentScore = 0; inBossFight = true; StartBattle(); } // run battle start initiation method when Seagull reaches the ground if (Seagull.GetComponent <SeagullBossController>().IsOnGround() && !battleStarted) { Debug.Log("battle started"); OnBattleStart(); battleStarted = true; } // set the camera position while the seagull is transitioning from air to ground if (!Seagull.GetComponent <SeagullBossController>().IsOnGround() && !battleStarted && inBossFight) { MainCamera.transform.position = battleCameraPosition; } // trigger the end battle sequence // need to change the conditions if (seagullHealthManager.damageTaken >= healthThreshold && inBossFight && currentLevel < maxLevels && seagullHealthManager.seagullHealth >= 0) { Debug.Log("ending battle"); SeagullBossController SBC = Seagull.GetComponent <SeagullBossController>(); bossControls BC = player.GetComponent <bossControls>(); if (!SBC.attacksLocked) { SBC.attacksLocked = true; } if (BC.canAttack) { BC.canAttack = false; } if (SBC.IsIdle()) { SBC.TakeOff(); EndBattle(); } } if (seagullHealthManager.seagullHealth <= 0 && !gameEnded) { canSpawnCrab = false; DestroyCrabs(); SeagullBossController SBC = Seagull.GetComponent <SeagullBossController>(); bossControls BC = player.GetComponent <bossControls>(); if (!SBC.attacksLocked) { SBC.attacksLocked = true; } if (BC.canAttack) { BC.canAttack = false; } if (SBC.IsIdle()) { gameEnded = true; EndGame(); } } // once the seagull has returned to the sky, call OnBattleEnd to reenable movement and camera if (Seagull.GetComponent <SeagullFlightController>().isFlying&& battleStarted) { Debug.Log("battle ended!"); battleStarted = false; OnBattleEnd(); } /* ========================================================================================================= */ }