private void Warning() { SceneManager.LoadSceneAsync("WarningFinal", LoadSceneMode.Additive); Invoke("BreakLaser", 10.4f); //was5 LaserProng.GetComponent <Stage6LaserProng>().BreakLaser(); //starts deathray particles. }
// Update is called once per frame void Update() { t += Time.deltaTime; if (t > 1) { fading = false; } if (fading) { sr.color = new Color(1f, 1f, 1f, Mathf.SmoothStep(0.0f, 1.0f, t)); } if (damageReceivedMultiplier > 1.15f) { damageReceivedMultiplier = 1.15f; } if (invulnTimer > 0) { invulnTimer -= Time.deltaTime; } if (health <= 500 && !dead) { dead = true; Death(); } if (canMove) { //transform.Translate (new Vector2 (0, speed * Time.deltaTime)); } if (health <= phase2 && phase == 1) { phase = 2; noshootTimer = invulnTimer = 1f; GameObject[] g = GameObject.FindGameObjectsWithTag("EnemyBullet"); for (int i = 0; i < g.Length; i++) { Destroy(g [i], i / 800f); } Invoke("DestroyAgain", 1f); phase2Shift = true; UpperWing.gameObject.SetActive(true); } else if (health <= phase3 && phase == 2) { phase = 3; noshootTimer = invulnTimer = 1f; GameObject[] g = GameObject.FindGameObjectsWithTag("EnemyBullet"); for (int i = 0; i < g.Length; i++) { Destroy(g [i], i / 800f); } UpperWing.GetComponent <Stage6Upper> ().ReturnToDefault(); LowerWing.gameObject.SetActive(true); Invoke("DestroyAgain", 1f); } else if (health <= phase4 && phase == 3) { phase = 4; noshootTimer = invulnTimer = 1f; LowerWing.GetComponent <Stage6Lower> ().ReturnToDefault(); RightConnector.gameObject.SetActive(true); LeftConnecter.gameObject.SetActive(true); Invoke("DestroyAgain", 1f); } else if (health <= phase5 && phase == 4) { phase = 5; noshootTimer = invulnTimer = 5f; GameObject[] g = GameObject.FindGameObjectsWithTag("EnemyBullet"); for (int i = 0; i < g.Length; i++) { Destroy(g [i], i / 400f); } RightConnector.GetComponent <Stage6Connecter> ().ReturnToDefault(); LeftConnecter.GetComponent <Stage6Connecter> ().ReturnToDefault(); } else if (health <= phase6 && phase == 5) { phase = 6; noshootTimer = invulnTimer = 5f; GameObject[] g = GameObject.FindGameObjectsWithTag("EnemyBullet"); for (int i = 0; i < g.Length; i++) { Destroy(g [i], i / 400f); } LeftWing.GetComponent <Stage6LeftWing> ().ReturnToDefault(); rotateLeft2 = true; } else if (health <= phase7 && phase == 6) { phase = 7; noshootTimer = invulnTimer = 5f; GameObject[] g = GameObject.FindGameObjectsWithTag("EnemyBullet"); for (int i = 0; i < g.Length; i++) { Destroy(g [i], i / 400f); } RightWing.GetComponent <Stage6RightWing> ().ReturnToDefault(); finalPrep = true; } else if (health <= phase8 && phase == 7) { phase = 8; noshootTimer = invulnTimer = 1f; GameObject[] g = GameObject.FindGameObjectsWithTag("EnemyBullet"); for (int i = 0; i < g.Length; i++) { Destroy(g [i], i / 400f); } Invoke("Warning", 0.05f); finalLaserPrep = true; } else if (health <= 0) { phase = -1; } if (canShoot && noshootTimer <= 0) { if (phase == 1) { Shoot(0); } else if (phase == 5) { Shoot(1); Shoot(2); } else if (phase == 6) { Shoot(3); Shoot(4); } else if (phase == 7) { Shoot(1); Shoot(3); } // Every X seconds shoot big laser if (trueFinal && noshootTimer <= 0) { // Next delay noshootTimer = 4; LaserProng.GetComponent <Stage6LaserProng> ().Shoot(); } } else { noshootTimer -= Time.deltaTime; } // Shot for .5 seconds all weapons (4-3.5); if (noshootTimer >= 3.5f && trueFinal) { Shoot(3); Shoot(4); Shoot(1); Shoot(2); } // Laser turning if (trueFinal && noshootTimer <= 2) { Vector3 direction = player.position - transform.position; float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg - 270; Quaternion lookRotation = Quaternion.AngleAxis(angle, Vector3.forward); transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, Time.deltaTime * 2); } if (spikePhase) { if (phase == 5) { noshootTimer = invulnTimer = 1f; } if (sUp) { transform.Translate(Vector3.up * Time.deltaTime * 5); if (transform.position.y > 7) { transform.position = new Vector3(transform.position.x, 7, transform.position.z); sUp = false; sLeft = true; } } else if (sLeft) { transform.Translate(Vector3.left * Time.deltaTime * 5); if (transform.position.x < -11) { transform.position = new Vector3(-11, transform.position.y, transform.position.z); sLeft = false; sDown = true; } if (phase == 5 && Mathf.Abs(transform.position.x) < 0.3f) { sLeft = false; transform.position = new Vector3(0, 7, transform.position.z); rotateLeft = true; spikePhase = false; } } else if (sDown) { transform.Translate(Vector3.down * Time.deltaTime * 5); if (transform.position.y < -7) { transform.position = new Vector3(transform.position.x, -7, transform.position.z); sDown = false; sRight = true; } } else if (sRight) { transform.Translate(Vector3.right * Time.deltaTime * 5); if (transform.position.x > 9.7f) { transform.position = new Vector3(9.7f, transform.position.y, transform.position.z); sRight = false; sUp = true; } } } if (phase2Shift) { transform.Translate((Vector3.zero - transform.position) * Time.deltaTime * 0.4f, Space.World); if (Vector2.Distance(transform.position, Vector3.zero) < 0.06f) { transform.position = Vector3.zero; phase2Shift = false; } } if (finalShiftUI) { for (int i = 0; i < canvasT.childCount - 1; i++) { canvasT.GetChild(i).transform.Translate(0, -Time.deltaTime * 500, 0); if (canvasT.GetChild(i).transform.position.y < -3000) { finalShiftUI = false; } } } if (rotateLeft) { transform.rotation = Quaternion.Euler(0, 0, transform.eulerAngles.z + 25 * Time.deltaTime); noshootTimer = invulnTimer = 1f; if (transform.eulerAngles.z > 90) { transform.rotation = Quaternion.Euler(0, 0, 90); LeftWing.gameObject.SetActive(true); rotateLeft = false; } } if (rotateLeft2) { noshootTimer = invulnTimer = 1f; transform.rotation = Quaternion.Euler(0, 0, transform.eulerAngles.z + 25 * Time.deltaTime); if (transform.eulerAngles.z > 270) { transform.rotation = Quaternion.Euler(0, 0, 270); RightWing.gameObject.SetActive(true); rotateLeft2 = false; } } if (finalPrep) { noshootTimer = invulnTimer = 1f; transform.rotation = Quaternion.Euler(0, 0, transform.eulerAngles.z + 25 * Time.deltaTime); if (Mathf.Abs(transform.eulerAngles.z) < 3) { transform.rotation = Quaternion.Euler(0, 0, 0); finalPrep = false; finalPrep2 = true; } } if (finalPrep2) { noshootTimer = invulnTimer = 1f; transform.Translate(Vector3.down * Time.deltaTime * 3); if (transform.position.y < 5) { transform.position = new Vector3(transform.position.x, 5, transform.position.z); LeftWing.GetComponent <Stage6LeftWing> ().SecondPhase(); RightWing.GetComponent <Stage6RightWing> ().SecondPhase(); finalPrep2 = false; LaserProng.gameObject.SetActive(true); } } if (finalLaserPrep) { noshootTimer = invulnTimer = 1f; transform.Translate(Vector3.up * Time.deltaTime * 3); if (transform.position.y > 6.5) { transform.position = new Vector3(transform.position.x, 6.5f, transform.position.z); finalLaserPrep = false; } } if (finalFade) { for (int i = 0; i < transform.childCount; i++) { if (transform.GetChild(transform.childCount - 1).GetComponent <SpriteRenderer>().color.r > 0.5f) { SpriteRenderer s = transform.GetChild(i).GetComponent <SpriteRenderer> (); s.color = new Color(Mathf.Clamp01(s.color.r) - Time.deltaTime * 0.3f, Mathf.Clamp01(s.color.g) - Time.deltaTime * 0.3f, Mathf.Clamp01(s.color.b) - Time.deltaTime * 0.3f); } else { finalFade = false; } } } if (stationsLeft <= 0 && !finalFadeback) { finalFadeback = true; LeftWing.GetComponent <Stage6LeftWing> ().StartFinalFadeback(); RightWing.GetComponent <Stage6RightWing> ().StartFinalFadeback(); transform.GetChild(0).GetComponent <CircleCollider2D> ().enabled = true; for (int i = 0; i < transform.childCount; i++) { transform.GetChild(i).GetComponent <SpriteRenderer> ().sortingOrder += 2; } stationsLeft = 99; Invoke("StartTrueFinal", 5.0f); noshootTimer = invulnTimer = 1f; GameObject[] g = GameObject.FindGameObjectsWithTag("EnemyBullet"); for (int i = 0; i < g.Length; i++) { Destroy(g [i], i / 400f); } } if (finalFadeback) { for (int i = 0; i < transform.childCount; i++) { if (transform.GetChild(transform.childCount - 1).GetComponent <SpriteRenderer>().color.r < 1) { SpriteRenderer s = transform.GetChild(i).GetComponent <SpriteRenderer> (); s.color = new Color(Mathf.Clamp01(s.color.r) + Time.deltaTime * 0.3f, Mathf.Clamp01(s.color.g) + Time.deltaTime * 0.3f, Mathf.Clamp01(s.color.b) + Time.deltaTime * 0.3f); } else { finalFadeback = false; } } } }