Beispiel #1
0
        //通过技能逻辑返回英雄能释放的最大优先级的AI模板
        private SpellAILogic ChooseAILogicPriority(ObjectHero hero, int type, int _spellIndex = 0)
        {
            if (hero.Getm_SpellInfo()[_spellIndex].GetSpellRow().GetID() == -1)
            {
                return(null);
            }
            int[] m_Template = null; //临时自动模式模板
            int[] m_Priority = null; //临时自动模式模板优先级
            switch (type)            //选择当前自动战斗模式
            {
            case (int)EM_SPELL_AI_TYPE.EM_SPELL_AI_TYPE_NORMAL:
                m_Template = hero.Getm_SpellInfo()[_spellIndex].GetSpellRow().getNormalTemplate();
                m_Priority = hero.Getm_SpellInfo()[_spellIndex].GetSpellRow().getNormalpriority();
                break;

            case (int)EM_SPELL_AI_TYPE.EM_SPELL_AI_TYPE_ATTACK:
                m_Template = hero.Getm_SpellInfo()[_spellIndex].GetSpellRow().getAttFirstTemplate();
                m_Priority = hero.Getm_SpellInfo()[_spellIndex].GetSpellRow().getAttFirstpriority();
                break;

            case (int)EM_SPELL_AI_TYPE.EM_SPELL_AI_TYPE_CURE:
                m_Template = hero.Getm_SpellInfo()[_spellIndex].GetSpellRow().getDefFirstTemplate();
                m_Priority = hero.Getm_SpellInfo()[_spellIndex].GetSpellRow().getDefFirstpriority();
                break;

            default:
                break;
            }
            if (m_Template == null || m_Template.Length <= 0)
            {
                return(null);
            }
            int          Templatecout = m_Template.Length;
            int          Maxtemp      = -1;   //临时优先级
            SpellAILogic tempSpellai  = null; //临时AI模板

            for (int i = 0; i < Templatecout; ++i)
            {
                //判断是否满足AI逻辑ID的条件
                SpellAILogic temp = GenerateSubsetFromPool(m_Template[i], m_Priority[i], hero, hero.Getm_SpellInfo()[_spellIndex], m_AITime);
                if (temp.IsAILogicReady())
                {
                    OnlyHeroSpellAILogicList.Add(temp);
                }
            }
            for (int i = 0; i < OnlyHeroSpellAILogicList.Count; ++i)
            {
                if (OnlyHeroSpellAILogicList[i].GetPriority() > Maxtemp)
                {
                    Maxtemp     = OnlyHeroSpellAILogicList[i].GetPriority();
                    tempSpellai = OnlyHeroSpellAILogicList[i];
                }
            }
            return(tempSpellai);
        }