private void StartFinalFade() { finalFade = true; transform.GetChild(0).GetComponent <CircleCollider2D> ().enabled = false; LeftWing.GetComponent <Stage6LeftWing> ().StartFinalFade(); RightWing.GetComponent <Stage6RightWing> ().StartFinalFade(); for (int i = 0; i < transform.childCount; i++) { transform.GetChild(i).GetComponent <SpriteRenderer> ().sortingOrder -= 2; } Invoke("Wave1", 3.0f); Invoke("Wave2", 50.0f); Instantiate(superShipParticles); Instantiate(healthParticles); }
// 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; } } } }
void Awake() { testText = GameObject.Find("TestText"); test = testText.GetComponent <Text> (); player = GameObject.FindGameObjectWithTag("Player"); kretanje = player.GetComponent <PlayerMovement> (); pHP = player.GetComponent <PlayerHealth> (); pEN = player.GetComponent <PlayerEnergy> (); // Center = GameObject.Find ("Center"); // Front = GameObject.Find ("Front"); // Back = GameObject.Find ("Back"); LeftWing = GameObject.Find("LeftWing"); RightWing = GameObject.Find("RightWing"); lW = LeftWing.GetComponent <PlayerShooting> (); rW = RightWing.GetComponent <PlayerShooting> (); lWLR = LeftWing.GetComponent <LineRenderer> (); rWLR = RightWing.GetComponent <LineRenderer> (); lWParticles = LeftWing.GetComponent <ParticleSystem> (); rWParticles = RightWing.GetComponent <ParticleSystem> (); klasaTekstObjekt = GameObject.Find("ClassNameText"); klasaTekst = klasaTekstObjekt.GetComponent <Text> (); abilityImageHUD1 = GameObject.FindGameObjectWithTag("Ability1"); abilityImage1 = abilityImageHUD1.GetComponent <Image> (); abilityImageHUD2 = GameObject.FindGameObjectWithTag("Ability2"); abilityImage2 = abilityImageHUD2.GetComponent <Image> (); abilityImageHUD3 = GameObject.FindGameObjectWithTag("Ability3"); abilityImage3 = abilityImageHUD3.GetComponent <Image> (); direktorij = Directory.GetCurrentDirectory(); provjera = direktorij + @"\radioaktivne_mrkve.txt"; provjera2 = direktorij + @"\radioaktivne_mrkve2.txt"; if (!File.Exists(provjera)) { klasa = 1; } else { System.IO.StreamReader file = new System.IO.StreamReader(provjera); while ((line = file.ReadLine()) != null) { if (line.Contains("Klasa: ")) { spremanje = line; spremanje = spremanje.Replace("Klasa: ", ""); } } file.Close(); klasa = int.Parse(spremanje); if (klasa < 1 || klasa > 5) { klasa = 1; } file.Close(); System.IO.StreamReader file2 = new System.IO.StreamReader(provjera); while ((line = file2.ReadLine()) != null) { provjera_load = klasa.ToString() + "Level: "; if (line.Contains(provjera_load)) { spremanje = line; spremanje = spremanje.Replace(provjera_load, ""); level = int.Parse(spremanje); } provjera_load = klasa.ToString() + "Experience: "; if (line.Contains(provjera_load)) { spremanje = line; spremanje = spremanje.Replace(provjera_load, ""); experience = int.Parse(spremanje); } provjera_load = klasa.ToString() + "hpUp: "; if (line.Contains(provjera_load)) { spremanje = line; spremanje = spremanje.Replace(provjera_load, ""); tempHP = int.Parse(spremanje); } provjera_load = klasa.ToString() + "pdUp: "; if (line.Contains(provjera_load)) { spremanje = line; spremanje = spremanje.Replace(provjera_load, ""); tempPDMG = float.Parse(spremanje); } provjera_load = klasa.ToString() + "sdUp: "; if (line.Contains(provjera_load)) { spremanje = line; spremanje = spremanje.Replace(provjera_load, ""); tempSDMG = float.Parse(spremanje); } provjera_load = klasa.ToString() + "enUp: "; if (line.Contains(provjera_load)) { spremanje = line; spremanje = spremanje.Replace(provjera_load, ""); tempEN = float.Parse(spremanje); } provjera_load = klasa.ToString() + "regUp: "; if (line.Contains(provjera_load)) { spremanje = line; spremanje = spremanje.Replace(provjera_load, ""); tempREG = float.Parse(spremanje); } provjera_load = klasa.ToString() + "movUp: "; if (line.Contains(provjera_load)) { spremanje = line; spremanje = spremanje.Replace(provjera_load, ""); tempMov = float.Parse(spremanje); } } file2.Close(); } if (klasa == 1) { className = "Aurelius "; fireEffect1 = 1; fireEffect2 = 2; Sprite newSprite = Resources.Load <Sprite>("Images/64 flat icons/png/128px/Elements_Nature"); if (newSprite) { abilityImage1.sprite = newSprite; } //Heal healComp = Center.AddComponent<Heal>() as Heal; } if (klasa == 2) { className = "Bismarck "; fireEffect1 = 0; fireEffect2 = 3; MeshRenderer mesh = player.GetComponent <MeshRenderer> (); mesh.material = Resources.Load <Material>("Meshes/SciFi_Fighter_AK5-diffuse-Yellow"); Sprite newSprite = Resources.Load <Sprite>("Images/64 flat icons/png/128px/Weapons_Bow"); if (newSprite) { abilityImage1.sprite = newSprite; } Front = (GameObject)Instantiate(Resources.Load("Parts/FrontBismarck")); Front.transform.parent = player.transform; Sprite newSprite2 = Resources.Load <Sprite>("Images/64 flat icons/png/128px/Weapons_Hammer"); if (newSprite2) { abilityImage2.sprite = newSprite2; } Center = (GameObject)Instantiate(Resources.Load("Parts/CenterBismarck")); Center.transform.parent = player.transform; Sprite newSprite3 = Resources.Load <Sprite>("Images/64 flat icons/png/128px/Equipment_Shield"); if (newSprite3) { abilityImage3.sprite = newSprite3; } Back = (GameObject)Instantiate(Resources.Load("Parts/BackBismarck")); Back.transform.parent = player.transform; } if (klasa == 3) { className = "Themistocles "; fireEffect1 = 0; fireEffect2 = 2; Sprite newSprite3 = Resources.Load <Sprite>("Images/64 flat icons/png/128px/Weapons_Bomb"); if (newSprite3) { abilityImage3.sprite = newSprite3; } Front = (GameObject)Instantiate(Resources.Load("Parts/FrontThemistocles")); Front.transform.parent = player.transform; Sprite newSprite2 = Resources.Load <Sprite>("Images/64 flat icons/png/128px/Modifiers_Time"); if (newSprite2) { abilityImage2.sprite = newSprite2; } Center = (GameObject)Instantiate(Resources.Load("Parts/CenterThemistocles")); Center.transform.parent = player.transform; Sprite newSprite1 = Resources.Load <Sprite>("Images/64 flat icons/png/128px/Equipment_Boots"); if (newSprite1) { abilityImage1.sprite = newSprite1; } Back = (GameObject)Instantiate(Resources.Load("Parts/BackThemistocles")); Back.transform.parent = player.transform; } if (klasa == 4) { className = "Tesla "; fireEffect1 = 0; fireEffect2 = 5; MeshRenderer mesh = player.GetComponent <MeshRenderer> (); mesh.material = Resources.Load <Material>("Meshes/SciFi_Fighter_AK5-diffuse-Blue"); rWParticles.startColor = Color.blue; lWParticles.startColor = Color.blue; Sprite newSprite1 = Resources.Load <Sprite>("Images/64 flat icons/png/128px/Modifiers_Accuracy"); if (newSprite1) { abilityImage1.sprite = newSprite1; } Center = (GameObject)Instantiate(Resources.Load("Parts/BackTesla")); Center.transform.parent = player.transform; Sprite newSprite2 = Resources.Load <Sprite>("Images/64 flat icons/png/128px/Elements_Air"); if (newSprite2) { abilityImage2.sprite = newSprite2; } Center = (GameObject)Instantiate(Resources.Load("Parts/CenterTesla")); Center.transform.parent = player.transform; Sprite newSprite3 = Resources.Load <Sprite>("Images/64 flat icons/png/128px/Modifiers_LevelUp"); if (newSprite3) { abilityImage3.sprite = newSprite3; } Center = (GameObject)Instantiate(Resources.Load("Parts/FrontTesla")); Center.transform.parent = player.transform; } if (klasa == 5) { className = "Archimedes "; fireEffect1 = 0; fireEffect2 = 4; Sprite newSprite1 = Resources.Load <Sprite>("Images/64 flat icons/png/128px/Elements_Fire"); if (newSprite1) { abilityImage1.sprite = newSprite1; } Front = (GameObject)Instantiate(Resources.Load("Parts/FrontArchimedes")); Front.transform.parent = player.transform; Sprite newSprite2 = Resources.Load <Sprite>("Images/64 flat icons/png/128px/World_RoseOfWinds"); if (newSprite2) { abilityImage2.sprite = newSprite2; } Back = (GameObject)Instantiate(Resources.Load("Parts/BackArchimedes")); Back.transform.parent = player.transform; Sprite newSprite3 = Resources.Load <Sprite>("Images/64 flat icons/png/128px/UI_Gamepad"); if (newSprite3) { abilityImage3.sprite = newSprite3; } Center = (GameObject)Instantiate(Resources.Load("Parts/CenterArchimedes")); Center.transform.parent = player.transform; //Drones dronesComp = Center.AddComponent<Drones>(); } tempStr = className + level.ToString(); klasaTekst.text = tempStr; expSlider.value = experience; rHealth = classData.RetrieveInteger(1, klasa); rHealth = rHealth + tempHP; rEnergy = classData.RetrieveFloat(1, klasa); rEnergy = rEnergy + tempEN; rRegen = classData.RetrieveFloat(2, klasa); rRegen = rRegen + tempREG; rMovement = classData.RetrieveFloat(3, klasa); rMovement = rMovement + tempMov; rPROF = classData.RetrieveFloat(4, klasa); rSROF = classData.RetrieveFloat(5, klasa); rPDMG = classData.RetrieveFloat(6, klasa); rPDMG = rPDMG + tempPDMG; rSDMG = classData.RetrieveFloat(7, klasa); rSDMG = rSDMG + tempSDMG; float tempDelay1, tempDelay2; tempDelay1 = 0.2f / (rPROF / 0.15f); tempDelay2 = 0.2f / (rSROF / 0.15f); pHP.SetHealth(rHealth); pEN.SetEnergy(rEnergy, rRegen); kretanje.SetSpeed(rMovement); lW.SetData(rPDMG, rPROF, 80f, "Fire1", tempDelay1, fireEffect1); rW.SetData(rSDMG, rSROF, 80f, "Fire2", tempDelay2, fireEffect2); string tempLineRender = "LineRenderMaterial" + klasa.ToString(); lWLR.material = Resources.Load <Material>(tempLineRender); rWLR.material = Resources.Load <Material>(tempLineRender); }