Beispiel #1
0
        private AiData_Npc_BossXiLie GetAiData(NpcInfo npc)
        {
            AiData_Npc_BossXiLie data = npc.GetAiStateInfo().AiDatas.GetData <AiData_Npc_BossXiLie>();

            if (null == data)
            {
                data = new AiData_Npc_BossXiLie();
                npc.GetAiStateInfo().AiDatas.AddData(data);
            }
            return(data);
        }
Beispiel #2
0
        private void PursuitHandler(NpcInfo npc, AiCommandDispatcher aiCmdDispatcher, long deltaTime)
        {
            if (npc.IsDead() ||
                npc.GetSkillStateInfo().IsSkillActivated())
            {
                npc.GetMovementStateInfo().IsMoving = false;
                NotifyNpcMove(npc);
                return;
            }
            NpcAiStateInfo       info = npc.GetAiStateInfo();
            AiData_Npc_BossXiLie data = GetAiData(npc);

            if (null != data)
            {
                CharacterInfo target = AiLogicUtility.GetLivingCharacterInfoHelper(npc, info.Target);
                if (null != target)
                {
                    if (npc.IsUnderControl())
                    {
                        data.ControlTime += deltaTime;
                        if (data.ControlTime >= m_MaxControlTime && npc.CanDisControl() && AiLogicUtility.CanCastSkill(npc, data.DecontrolSkill, target))
                        {
                            NotifyNpcAddImpact(npc, m_DisControlImpact);
                            data.ControlTime = 0;
                            TryCastSkill(npc, data.DecontrolSkill, target, false);
                            data.CurSkillCombo      = data.DecontrolCombo;
                            data.CurSkillComboIndex = 0;
                        }
                        return;
                    }
                    float   dist          = (float)npc.GetActualProperty().AttackRange;
                    float   distGoHome    = (float)npc.GohomeRange;
                    Vector3 targetPos     = target.GetMovementStateInfo().GetPosition3D();
                    Vector3 srcPos        = npc.GetMovementStateInfo().GetPosition3D();
                    float   powDist       = Geometry.DistanceSquare(srcPos, targetPos);
                    float   powDistToHome = Geometry.DistanceSquare(srcPos, info.HomePos);
                    // 遇敌是播放特效, 逗留两秒。
                    if (data.WaitTime <= m_ResponseTime)
                    {
                        if (!data.HasMeetEnemy)
                        {
                            NotifyNpcMeetEnemy(npc, Animation_Type.AT_Attack);
                            data.HasMeetEnemy = true;
                        }
                        TrySeeTarget(npc, target);
                        data.WaitTime += deltaTime;
                        return;
                    }
                    if (null != data.CurSkillCombo)
                    {
                        if (data.CurSkillCombo.Length > data.CurSkillComboIndex)
                        {
                            TryCastSkill(npc, data.CurSkillCombo[data.CurSkillComboIndex], target);
                            data.CurSkillComboIndex = data.CurSkillComboIndex + 1;
                        }
                        else
                        {
                            if (data.IsInDecontrolCombo)
                            {
                                if ((int)GfxCharacterState_Type.HitFly == target.GfxStateFlag)
                                {
                                    data.CurSkillCombo = data.FlyCombo;
                                }
                                else
                                {
                                    data.CurSkillCombo = data.StandCombo;
                                }
                            }
                            else
                            {
                                data.CurSkillCombo = null;
                            }
                            data.CurSkillComboIndex = 0;
                        }
                    }
                    // 大于攻击距离 跑向目标
                    if (powDist > m_AttackRange * m_AttackRange)
                    {
                        if (TryCastSkill(npc, data.RangeSkill, target))
                        {
                            return;
                        }
                        info.Time += deltaTime;
                        if (info.Time > m_IntervalTime)
                        {
                            NotifyNpcRun(npc);
                            info.Time = 0;
                            AiLogicUtility.PathToTargetWithoutObstacle(npc, data.FoundPath, targetPos, m_IntervalTime, true, this);
                        }
                    }
                    else
                    {
                        if (IsCanUseComboSkills(npc, target, data.MeeleCombo))
                        {// 近战连招
                            data.CurSkillCombo      = data.MeeleCombo;
                            data.CurSkillComboIndex = 0;
                        }
                        else if (TryCastSkill(npc, data.MeeleSkill, target))
                        { // 默认释放技能
                            return;
                        }
                    }
                }
                else
                {
                    NotifyNpcTargetChange(npc);
                    npc.GetMovementStateInfo().IsMoving = false;
                    NotifyNpcMove(npc);
                    info.Time = 0;
                    ChangeToState(npc, (int)AiStateId.Idle);
                }
            }
        }