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

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

            if (null != data)
            {
                CharacterInfo target = AiLogicUtility.GetLivingCharacterInfoHelper(npc, info.Target);
                if (null != target)
                {
                    if (npc.GetSkillStateInfo().IsSkillActivated())
                    {
                        npc.GetMovementStateInfo().IsMoving = false;
                        NotifyNpcMove(npc);
                        data.LastUseSkillTime = TimeUtility.GetServerMilliseconds();
                        return;
                    }
                    if (npc.IsUnderControl())
                    {
                        data.ControlTime += deltaTime;
                        if (data.ControlTime >= m_MaxControlTime && npc.CanDisControl() && AiLogicUtility.CanCastSkill(npc, m_DisControlSkillId, target))
                        {
                            NotifyNpcAddImpact(npc, m_DisControlImpactId);
                            data.ControlTime = 0;
                            TryCastSkill(npc, m_DisControlSkillId, target, false);
                        }
                        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;
                    }
                    int  skillId = GetCanCastSkillId(npc, (float)Math.Sqrt(powDist));
                    long curTime = TimeUtility.GetServerMilliseconds();
                    if (-1 != skillId && curTime - data.LastUseSkillTime > m_SkillInterval && AiLogicUtility.CanCastSkill(npc, skillId, target))
                    {
                        if (TryCastSkill(npc, skillId, target, true))
                        {
                            NotifyNpcAddImpact(npc, m_SuperArmorImpactId);
                        }
                    }
                    else
                    {
                        info.Time += deltaTime;
                        if (info.Time > m_IntervalTime)
                        {
                            info.Time = 0;
                            AiLogicUtility.PathToTargetWithoutObstacle(npc, data.FoundPath, targetPos, m_IntervalTime, true, this);
                        }
                    }
                }
                else
                {
                    NotifyNpcTargetChange(npc);
                    npc.GetMovementStateInfo().IsMoving = false;
                    NotifyNpcMove(npc);
                    info.Time = 0;
                    ChangeToState(npc, (int)AiStateId.Idle);
                }
            }
        }