public static void OnMain() { if (Utils.IsKeyPressed(Keys.Space) && Utils.IsGameOnDisplay()) { Point EnemyPosition = ObjectManager.GetEnemyPosition(); if (EnemyPosition != Point.Empty) { SpellBook.CastSpell(SpellBook.SpellSlot.Q, EnemyPosition); /*SpellBook.SpellSlot[] SpellArray = new SpellBook.SpellSlot[] * { * SpellBook.SpellSlot.Q, * SpellBook.SpellSlot.W, * SpellBook.SpellSlot.E * }; * * SpellBook.CastMultiSpells(SpellArray, EnemyPosition);*/ } else { Engine.IssueOrder(Enums.GameObjectOrder.MoveTo, Cursor.Position); } } }
private IEnumerator Attack(int spellIndex) { Transform currentTarget = MyTarget; // 防止在施法过程中改变目标 Spell newSpell = spellBook.CastSpell(spellIndex); isAttacking = true; mAnimator.SetBool("attack", isAttacking); yield return(new WaitForSeconds(newSpell.MyCastTime)); Debug.Log("create" + spellIndex); if (currentTarget != null) { SpellScript s = Instantiate(newSpell.MySpellPrefab, exitPoints[exitIndex].position, Quaternion.identity).GetComponent <SpellScript> (); s.Initialize(currentTarget, newSpell.MyDamage); } StopAttack(); }
public IEnumerator Attack(int spellIndex) { if (!isAttacking && !IsMoving && InLineOfSight()) { Transform currentTarget = Target; Spell newSpell = spellBook.CastSpell(spellIndex); isAttacking = true; animator.SetBool("attack", isAttacking); yield return(new WaitForSeconds(newSpell.CastTime)); //CastSpell(); if (currentTarget && InLineOfSight()) { GameObject spellObj = Instantiate(newSpell.SpellPrefab, exitPoints[exitIndex].position, Quaternion.identity); SpellScript spellController = spellObj.GetComponent <SpellScript>(); spellController.Fire(Target, newSpell); } StopAttack(); } }
private IEnumerator Attack(int spellIndex) { Transform currentTarget = MyTarget; Spell newSpell = spellBook.CastSpell(spellIndex); attacking = true; myAnimator.SetBool("attack", attacking); yield return(new WaitForSeconds(newSpell.CastTime)); // hard coded cast time for debugging if (currentTarget != null && InLineOfSight()) { SpellScript s = Instantiate(newSpell.SpellPrefab, exitPoints[(int)exitIndex].position, Quaternion.identity).GetComponent <SpellScript>(); s.Initialize(currentTarget, newSpell.Damage); } StopAttack(); }