Beispiel #1
0
    private IEnumerator Fire()
    {
        targetList.Sort((x, y) => {
            float dist1 = (Player.Instance.transform.position - x.transform.position).sqrMagnitude;
            float dist2 = (Player.Instance.transform.position - y.transform.position).sqrMagnitude;

            if (dist1 > dist2)
            {
                return(1);
            }
            else if (dist1 == dist2)
            {
                return(0);
            }
            else
            {
                return(-1);
            }
        });

        for (int i = 0; i < currMissiles.Count; i++)
        {
            MagicMissile m = currMissiles[i];
            m.Target             = targetList.Count == 0 ? null : targetList[i % targetList.Count];
            m.Impulse            = m.Target == null ? Vector3.zero : Vector3.up * MagicMissileImpulse;
            m.LifeTime           = 20f;
            m.Damage             = this.Damage;
            m.Type               = this.Type;
            m.Knockback          = this.Knockback;
            m.RigidbodyKnockback = this.RigidbodyKnockback;
            m.Fire();

            yield return(new WaitForSeconds(MissileShootDelay));
        }

        charge = 0.0f;
        currMissiles.Clear();
        enemyList.Clear();
        targetList.Clear();
        collider.enabled = false;
        routine          = null;
    }
Beispiel #2
0
 protected internal override void Fx(int cell, ICallback callback)
 {
     MagicMissile.Fire(CurUser.Sprite.Parent, CurUser.pos, cell, callback);
     Sample.Instance.Play(Assets.SND_ZAP);
 }