Example #1
0
    private IEnumerator CastRoutine()
    {
        _isBusy = true;
        //Use interfaces instead of send message for type safety.
        Component[] castables = GetComponents(typeof(ICastable));
        for (int i = 0; i < castables.Length; i++)
        {
            ((ICastable)castables[i]).Cast();
        }

        while (true)
        {
            bool isAnyBusy = false;
            for (int i = 0; i < castables.Length; i++)
            {
                if (((ICastable)castables[i]).IsBusy())
                {
                    isAnyBusy = true;
                    break;
                }
            }
            if (!isAnyBusy)
            {
                break;
            }
            yield return(null);
        }

        _isBusy = false;

        _ability.AbilityCastCompleted(true);
    }