IEnumerator seterror; //Sets error state to false after t_error time. #endregion void Awake() { spellarray[0] = new spells("FireBall", 1.5f, (int)enum_casting.StraightMagicShot, fireballanim, CastLocationFireBall, 100f, 0.6f, 0f, 0f, true); spellarray[1] = new spells("FrostBolt", 1.0f, (int)enum_casting.CastSpell, frostboltanim, CastLocationFrostBolt, 10f, 0.2f, 0f, 0f, true); spellarray[2] = new spells("PermaFrost", 2.0f, (int)enum_casting.CastSpell, PermaFrostGameObject, CastLocationPermaFrost, 10f, 0f, 8f, 0f, true); aoespellarray[0] = new AoEspell(10f, 30f, 15f); castkeys = new string[3] { "q", "e", "r" }; //Cast Keys spellerrors = new string[4] { "You Must Face The Target!", "No Target!", "Currently Casting", "Spell is On CoolDown!" }; t_error = 0.5f;//Display error for 0.5 sec //Cast bar Initializers castbarp_y = 1.5f;//Distance the cast bar is placed from the middle(pos) castbarp_x = 0.75f; castbarsize = new Vector2(160, 16); castbarpos = new Vector2(Screen.width / 2, Screen.height / 2); //Error Initializer }
public IEnumerator castPermaFrost() { spells c_spells = spellarray[(int)enum_spell.PermaFrost];//General Spell Values of permafrost. b_casting = true; this.GetComponent <Animator>().speed = 0.5f; //This speed works well for all spells. spell_casting = (int)enum_spell.PermaFrost; //Update current spell being cast. this.GetComponent <Player_controller>().mainsubmachinestate = (int)mainsubmachinstates.Casting; this.GetComponent <Player_controller>().currentCastinganim = (int)enum_casting.PermaFrost; AoEspell c_spell = aoespellarray[(int)enum_AoESpells.PermaFrost]; //AoE specific values GameObject castobject = c_spells.spell; //Game Object to cast. float dmg = c_spells.b_damage; float radius = c_spell.radius; float speed = c_spell.speed; Transform origin = c_spells.s_location; float casttime = c_spells.casttime; s_starttime = Time.time;//Log the spell start time yield return(new WaitForSeconds(casttime * (1f - this.GetComponent <Properties>().haste / GeneralProperties.hastecap))); this.GetComponent <Animator>().speed = 1f; //Set Speed Back to one StartCoroutine(CoolDown(spell_casting)); //Start cooldown coroutine and pass it the current spell being casted. GameObject spell = Instantiate(castobject, origin.position, this.transform.rotation) as GameObject; spell.GetComponent <PermaFrost>().castedby = this.gameObject; spell.GetComponent <PermaFrost>().radius = radius; //Max Radius of spell spell.GetComponent <PermaFrost>().damage = dmg; //Base Damage of Spell spell.GetComponent <PermaFrost>().speed = speed; //Speed of Expantion. b_casting = false; //Done Casting }