Exemple #1
0
    public bool ActionMoveTo(Vector3 targetPos, bool astar, bool isback, bool isSyncPosition, Vector3 syncPosition)
    {
        if (Owner.ActionControl.IsDisable(ActorAction.ENType.enMoveAction))
        {
            return(false);
        }
        MoveAction action = Owner.ActionControl.LookupAction(ActorAction.ENType.enMoveAction) as MoveAction;

        if (action != null)
        {
            if (action.m_realTargetPos == targetPos)
            {
                action.m_isBack = false;
                return(true);
            }
        }
        if (action == null)
        {
            action = Owner.ActionControl.AddAction(ActorAction.ENType.enMoveAction) as MoveAction;
        }
        action.IsSyncPosition = isSyncPosition;
        action.SyncPosition   = syncPosition;
        action.m_isNotAStar   = !astar;
        action.m_isBack       = isback;
        action.Retarget(targetPos);
        return(true);
    }
Exemple #2
0
    public override void Update()
    {
        base.BaseUpdate();
        if (Self.IsDead)
        {//死亡
            return;
        }
        m_nextAITime -= Time.deltaTime;
        if (m_nextAITime > 0.0f)
        {
            return;
        }
        m_nextAITime = UnityEngine.Random.Range(0.1f, 0.5f);
        FindSneak();
        switch (m_fearType)
        {
        case ENFearType.enEscape:
        {
            Actor target = ActorManager.Singleton.Lookup(m_targetID);
            if (target != null)
            {
                float distance = ActorTargetManager.GetTargetDistance(Owner.MainPos, target.MainPos);
                if (distance < m_escapeDistance)
                {        //恐惧逃跑
                    Vector3 direction = Owner.MainPos - target.MainPos;
                    direction.y = 0;
                    direction.Normalize();

                    Vector3    targetPos = Owner.MainPos + direction * (m_escapeDistance - distance);
                    MoveAction action    = Owner.ActionControl.AddAction(MoveAction.SGetActionType()) as MoveAction;
                    if (action != null)
                    {
                        action.Retarget(targetPos);
                    }
                    return;
                }
            }
            //恐惧站立
            Owner.ActionControl.RemoveAction(MoveAction.SGetActionType());
            StandAction standAction = Owner.ActionControl.LookupAction(StandAction.SGetActionType()) as StandAction;
            if (standAction == null)
            {
                standAction = Owner.ActionControl.AddAction(StandAction.SGetActionType()) as StandAction;
            }
            if (standAction != null)
            {
                standAction.AnimName = "standby";
            }
        }
        break;
        }
    }