Beispiel #1
0
    // returns a spell if it can cast one
    // otherwise, returns null
    public async Task <Spell> EnemyAttackIfAble()
    {
        await Task.Delay(1000);   // wait a second before attacking if able

        string intent        = _currentEnemy.Intent;
        Spell  intendedSpell = null;

        if (!string.IsNullOrEmpty(intent))
        {
            intendedSpell = _context.SpellManager.GetEnemySpell(intent);
            Debug.Log(string.Format("Enemy intends to use {0} attack",
                                    _context.LocalizationManager.GetLocalizedString(intendedSpell.Name)));
            List <OrbInfo> requiredOrbs;
            if (_currentEnemyBag.DrawnOrbsMeetsRequirements(intendedSpell.OrbRequirements, out requiredOrbs))
            {
                Debug.Log(string.Format("Enemy executes a {0} attack",
                                        _context.LocalizationManager.GetLocalizedString(intendedSpell.Name)));
                intendedSpell.Effect();
                _context.BagManager.RemoveOrbToEnemyBag(intendedSpell.OrbRequirements);
                PlayEnemySpellEvent?.Invoke(requiredOrbs);
                return(intendedSpell);
            }
        }

        return(intendedSpell);
    }
Beispiel #2
0
    // returns a spell if it can cast one
    // otherwise, returns null
    public Spell AttackIfAble()
    {
        string intent        = _currentEnemy.Intent;
        Spell  intendedSpell = null;

        if (!string.IsNullOrEmpty(intent))
        {
            intendedSpell = context.SpellManager.GetEnemySpell(intent);
            if (context.BagManager.MeetsRequirementsForEnemy(intendedSpell))
            {
                intendedSpell.Effect();
                context.BagManager.RemoveOrbToEnemyBag(intendedSpell.OrbRequirements);
                PlayEnemySpellEvent?.Invoke(intendedSpell.OrbRequirements);
                return(intendedSpell);
            }
        }

        return(intendedSpell);
    }