public void CastSpell(string spellName) { Block(); if (MyTarget != null && MyTarget.GetComponentInParent <Character>().IsAlive&& !IsAttacking && !IsMoving && InLineOfSight()) { attackRoutine = StartCoroutine(Attack(spellName)); } }
public void CastSpell(string spellName) { Block(); if (MyTarget != null && MyTarget.GetComponentInParent <Character>().IsAlive&& !IsAttacking && !IsMoving && InLineOfSight(MyTarget)) //Chcks if we are able to attack { currentTarget = MyTarget; attackRoutine = StartCoroutine(Attack(spellName)); } }
public void CastSpell(string spellName) { if (MyTarget != null && MyTarget.GetComponentInParent <Character>().IsAlive&& !IsAttacking && !isMoving && InLineOfSight(MyTarget)) { IsAttacking = true; TurnPlayer(); MyAnimator.SetBool("attack", IsAttacking); attackRoutine = StartCoroutine(Attack(spellName)); HandleLayers(); } }
public void CastSpell(string spellName) { Block(); //if not attacking and not moving, then the player can attack again if (MyTarget != null && MyTarget.GetComponentInParent <Character>().IsAlive&& !IsAttacking && !IsMoving && InLineOfSight()) { //coroutine = an action that can be done simoultaenously with other functions attackRoutine = StartCoroutine(Attack(spellName)); } //quaternion = rotation of the prefab //instantiate the spell prefab on the position of the exit points which are determined by the inputs }
public void CastSpell(string spellName) { //Activate the colliders used in the InLineOfSight function Block(); //This if statement impliments all the Checks to see if the player can attack a target when the Space button is pressed //Check to see if 1. There is a clickable target under the mouse pointer // 2. The Player is not currently attacking // 3. The Player is not currently Moving // 4. The Target is in Line of Sight if (MyTarget != null && MyTarget.GetComponentInParent <Character>().IsAlive&& !IsAttacking && !IsMoving && InLineOfSight()) { attackRoutine = StartCoroutine(Attack(spellName)); //a Coroutine is code that runs in parallel //to the rest of the script. it is not threading, //but runs in the background waiting for input } }
/// <summary> /// Casts a spell /// </summary> public void CastSpell(Spell spell) { Block(); if (spell.ManaCost <= mana.MyCurrentValue) { if (!spell.NeedsTarget && unusedSpell == null) { unusedSpell = Instantiate(spell.MySpellPrefab, Camera.main.ScreenToWorldPoint(Input.mousePosition), Quaternion.identity); unusedSpell.transform.position = new Vector3(unusedSpell.transform.position.x, unusedSpell.transform.position.y, 0); aoeSpell = spell; } else { Destroy(unusedSpell); } if (MyTarget != null && MyTarget.GetComponentInParent <Character>().IsAlive&& !IsAttacking && !IsMoving && InLineOfSight() && InRange(spell, MyTarget.transform.position)) //Chcks if we are able to attack { MyInitRoutine = StartCoroutine(AttackRoutine(spell)); } } }