Пример #1
0
    /// <summary>
    /// 设置预设NPC目标是目标角色
    /// </summary>
    /// <returns></returns>
    public BehaviourReturnCode ActionSetPresetNpcActorToTarget()
    {
        Monster monster = RunningProperty.SelfActor as Monster;

        if (monster == null)
        {
            return(BehaviourReturnCode.Failure);
        }

        //Spartan.MonsterGroupInfo monsterGroupInfo = monster.SpartanMonsterGroupInfo;

        //if (monsterGroupInfo != null)
        //{
        //    Actor targetActor = NpcManager.Instance.GetNpcByNpcId((uint)monsterGroupInfo.TargetNpcId);

        //    if (targetActor != null && !targetActor.IsActorInvisiable)
        //    {
        //        RunningProperty.TargetActor = targetActor;

        //        if(RunningProperty.TargetActor == null)
        //        {
        //            return BehaviourReturnCode.Failure;
        //        }
        //    }
        //}

        RunningProperty.RefreshState();

        return(BehaviourReturnCode.Success);
    }
Пример #2
0
    /// <summary>
    /// 设置魔仆的攻击目标
    /// </summary>
    /// <returns></returns>
    public BehaviourReturnCode ActionPetSetTarget()
    {
        if (RunningProperty.TargetActor != null)
        {
            RunningProperty.SelfActor.AttackCtrl.CurSelectActor = RunningProperty.TargetActor.GetActorMono();

            return(BehaviourReturnCode.Success);
        }

        // 是否使用父亲的目标
        if (RunningProperty.IsAttackParentTarget == false)
        {
            var player = AIHelper.GetNearestActor(RunningProperty, ActorManager.Instance.PlayerSet);
            if (player == null)
            {
                var monster = AIHelper.GetNearestActor(RunningProperty, ActorManager.Instance.MonsterSet);
                RunningProperty.TargetActor = monster;
            }
            else
            {
                RunningProperty.TargetActor = player;
            }
        }
        else
        {
            Actor parentActor = RunningProperty.SelfActor.ParentActor;
            if (parentActor == null || parentActor.AttackCtrl == null)
            {
                return(BehaviourReturnCode.Failure);
            }

            // 父亲的目标
            if (parentActor.AttackCtrl.LastTargetId > 0)
            {
                Actor actor = ActorManager.Instance.GetActor(parentActor.AttackCtrl.LastTargetId);
                if (actor != null)
                {
                    RunningProperty.TargetActor = actor;
                }
            }
        }

        if (RunningProperty.TargetActor != null)
        {
            RunningProperty.SelfActor.AttackCtrl.CurSelectActor = RunningProperty.TargetActor.GetActorMono();
        }

        RunningProperty.RefreshState();

        if (RunningProperty.TargetActor == null)
        {
            return(BehaviourReturnCode.Failure);
        }

        return(BehaviourReturnCode.Success);
    }