// Update is called once per frame void Update() { /* * Thats looks much, but the function of Ice is the same as for Fire */ if (player.activeMagic.ToString() == "FIRE") { //this is a flag, for the case, when player change the element, while the current element effect is not finish newMagic1 = true; //When chaning from ice to fire, set time back, deactivate ice particalt and set eementchange flag back if (newMagic2 != false) { timeE = time; newMagic2 = false; player.IceParticles(false); } //When element is activated and the currentelement is the same reset duration time if (player.ReFreshMagic != false) { timeE = time; player.ReFreshMagic = false; } //activate image, partical and effects this.GetComponent <Image>().enabled = true; this.GetComponent <Image>().sprite = myFirstImage; player.FireParticles(true); //This is only a time counter if (timeFlag != false) { StartCoroutine(duration()); //Invoke("duration", 1); } else if (timeE < 1) { //When time is beow 0 deactivate everything magicTime.fillAmount = 1; this.GetComponent <Image>().enabled = false; player.beNeutral(); timeE = time; newMagic1 = false; player.FireParticles(false); FindObjectOfType <AudioManager>().Stop("usingMagic"); FindObjectOfType <AudioManager>().Play("magicStop"); ppEffects.deactivateChromaticAberrationWithFade(); //postProcessing } } else if (player.activeMagic.ToString() == "ICE") { newMagic2 = true; if (newMagic1 != false) { timeE = time; newMagic1 = false; player.FireParticles(false); } if (player.ReFreshMagic != false) { timeE = time; player.ReFreshMagic = false; } this.GetComponent <Image>().enabled = true; this.GetComponent <Image>().sprite = mySecondImage; player.IceParticles(true); if (timeFlag != false) { StartCoroutine(duration()); } else if (timeE < 1) { magicTime.fillAmount = 1; this.GetComponent <Image>().enabled = false; player.beNeutral(); timeE = time; newMagic2 = false; player.IceParticles(false); FindObjectOfType <AudioManager>().Stop("usingMagic"); FindObjectOfType <AudioManager>().Play("magicStop"); ppEffects.deactivateChromaticAberrationWithFade(); //postProcessing } } }