Beispiel #1
0
        private void AnalyseObjectMonster(ObjectMonster monster)
        {
            var _spellInfoArray = monster.Getm_SpellInfo();

            for (int i = 0; i < _spellInfoArray.Count; i++)
            {
                if (_spellInfoArray[i] != null && _spellInfoArray[i].GetSpellID() != -1)
                {
                    SpellInfo _tempInfo = _spellInfoArray[i];
                    for (int j = 0; j < _tempInfo.GetSpellRow().getNormalTemplate().Length; ++j)
                    {
                        if (monster.CheckSkillCondtion(_tempInfo))
                        {
                            SpellAILogic tempLogic = GenerateSubsetFromPool(_tempInfo.GetSpellRow().getNormalTemplate()[j],
                                                                            _tempInfo.GetSpellRow().getNormalpriority()[j],
                                                                            monster, _tempInfo, m_AITime);
                            if (tempLogic.IsAILogicReady() && tempLogic.GetPriority() >= m_MaxPriority)
                            {
                                m_MaxPriority = tempLogic.GetPriority();
                                m_SpellList.Add(new MonsterSpellLogicPackage(monster, tempLogic));
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
        private void OnAItypeUpdate(int type)
        {
            int          cout            = Ok_heros.Count;
            int          Maxtemp         = -1;
            int          FinishHerovalue = -1;   //最终释放技能英雄的索引
            SpellAILogic FinishAi        = null; //最终释放技能模板

            for (int i = 0; i < cout; ++i)
            {
                SpellAILogic temp = ChooseAILogicPriority(Ok_heros[i], type);//获取能释放技能的有效优先级
                if (temp != null)
                {
                    HerosSpellAILogicList.Add(temp);
                    AIOk_heros.Add(Ok_heros[i]);
                }
            }
            int cout2 = HerosSpellAILogicList.Count;

            for (int i = 0; i < cout2; ++i)
            {
                if (HerosSpellAILogicList[i].GetPriority() > Maxtemp)
                {
                    Maxtemp         = HerosSpellAILogicList[i].GetPriority();
                    FinishAi        = HerosSpellAILogicList[i];
                    FinishHerovalue = i;
                }
            }
            if (FinishHerovalue >= 0)
            {
                if (SceneObjectManager.GetInstance().GetIsFireSignState() && SceneObjectManager.GetInstance().GetFireSighCreatrue() != null)
                {
                    AIOk_heros[FinishHerovalue].SetSkillLockTarget(SceneObjectManager.GetInstance().GetFireSighCreatrue());
                }
                else
                {
                    AIOk_heros[FinishHerovalue].SetSkillLockTarget(FinishAi.GetSkillTag());
                }

                if (AIOk_heros[FinishHerovalue].OnPre_CheckUseSkillCondtion())
                {
                    //AIOk_heros[FinishHerovalue].OnSkillConsume();
                    //AIOk_heros[FinishHerovalue].SetObjectActionState(ObjectCreature.ObjectActionState.skillAttack);
                    //string name = FinishAi.GetSkillInfo().GetSpellRow().getSkillNameRes();
                    //SkillShowNamePackage package = new SkillShowNamePackage(AIOk_heros[FinishHerovalue].GetGuid(), name);
                    //GameEventDispatcher.Inst.dispatchEvent(GameEventID.F_ShowSkillName, package);

                    AIOk_heros[FinishHerovalue].LaunchFreeSpellLogic(EM_SPELL_PASSIVE_INDEX.EM_SPELL_PASSIVE_INITIATIVE);
                }
                else
                {
                    AIOk_heros[FinishHerovalue].SetSkillLockTarget(null);
                }
                //Debug.Log(AIOk_heros[FinishHerovalue].GetGameObject().name);
            }
        }
Beispiel #3
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);
        }
Beispiel #4
0
        public void SelectSpellTarget(ObjectHero objHero)
        {
            ReturnData();

            SpellAILogic FinishAi = ChooseAILogicPriority(objHero, (int)EM_SPELL_AI_TYPE.EM_SPELL_AI_TYPE_NORMAL, (int)objHero.GetLaunchFreeSpellIndex());//获取能释放技能的有效优先级

            if (SceneObjectManager.GetInstance().GetIsFireSignState() && SceneObjectManager.GetInstance().GetFireSighCreatrue() != null)
            {
                objHero.SetSkillLockTarget(SceneObjectManager.GetInstance().GetFireSighCreatrue());
            }
            else
            {
                objHero.SetSkillLockTarget(FinishAi.GetSkillTag());
            }
        }
Beispiel #5
0
        //避免频繁申请内存。使用池管理数据 [11/4/2015 Zmy]
        private SpellAILogic GenerateSubsetFromPool(int TemplateID, int Priority, ObjectCreature ReleaseObj, SpellInfo info, float timeInterval)
        {
            for (int i = 0; i < SpellAILogicPool.Count; i++)
            {
                if (SpellAILogicPool[i].IsInIdle())
                {
                    SpellAILogicPool[i].InitLogic(TemplateID, Priority, ReleaseObj, info, timeInterval);
                    return(SpellAILogicPool[i]);
                }
            }

            SpellAILogic temp = new SpellAILogic();

            temp.InitLogic(TemplateID, Priority, ReleaseObj, info, timeInterval);
            SpellAILogicPool.Add(temp);
            return(temp);
        }
Beispiel #6
0
 public MonsterSpellLogicPackage(ObjectMonster caster, SpellAILogic logic)
 {
     m_Caster       = caster;
     m_SpellAILogic = logic;
 }