示例#1
0
 void FindFriend(Actor target)
 {
     if (m_target != null)
     {
         return;
     }
     if (target.IsDead)
     {
         return;
     }
     if (ActorTargetManager.IsFriendly(m_self, target))
     {
         float d           = ActorTargetManager.GetTargetDistance(m_self.MainPos, target.MainPos);
         float attackRange = 0;
         if (m_self.Type == ActorType.enNPC)
         {
             attackRange = (m_self as NPC).CurrentTableInfo.AttackRange;
         }
         else
         {
             attackRange = (m_self as Player).CurrentTableInfo.AttackRange;
         }
         if (d < attackRange)
         {//攻击范围内
             m_target = target;
         }
     }
 }
示例#2
0
 //高级近战攻击
 bool HighNearAttack()
 {
     if (!Self.CurrentTargetIsDead)
     {//有目标
         float hpPercent = Self.HP / Self.MaxHP;
         if (hpPercent <= 0.5f)
         {//hp<=50%
             float d = ActorTargetManager.GetTargetDistance(Self.RealPos, Self.CurrentTarget.RealPos);
             if (d < 2)
             {
                 if (Time.time - m_battleStartTime > 4)
                 {//
                     //释放“近战”&&“高级”技能
                     int skillID = GetSkillID(ENSkillDistanceType.enNear, ENSkillLevelType.enHigh);
                     if (skillID != 0 && ActionTryFireSkill(skillID))
                     {
                         m_battleStartTime = Time.time;
                         return(true);
                     }
                 }
             }
         }
     }
     return(false);
 }
示例#3
0
    bool PassiveSwitchTarget()
    {//被动切换目标
        float param = Self.MaxHP * DamagedCounterParam;

        foreach (var item in Self.m_damagedRecordMap)
        {
            if (m_curTargetID == item.Key)
            {
                continue;
            }
            if (item.Value > param)
            {
                Actor target = ActorManager.Singleton.Lookup(item.Key);
                if (target == null || target.IsDead)
                {
                    continue;
                }
                if (!ActorTargetManager.IsEnemy(Self, target))
                {
                    continue;
                }
                m_curTargetID      = target.ID;
                Self.CurrentTarget = target;
                //清除
                Self.m_damagedRecordMap[item.Key] = 0;
                (target as NPC).m_priorityAttack  = true;
                return(true);
            }
        }
        return(false);
    }
示例#4
0
    public static AIBaseData GetActorTargetDis(Actor actor, string name = "")
    {
        AIBaseData tmpData = AIBaseData.CreateAIBaseData();

        tmpData.SetFloatValue(ActorTargetManager.GetTargetDistance(actor.RealPos, actor.CurrentTarget.RealPos));
        return(tmpData);
    }
示例#5
0
    //是否攻击
    private bool IsAttack()
    {
        Actor target = ActorManager.Singleton.Lookup(m_curTargetID);

        if (target != null && !target.IsDead)
        {//有目标
            MainPlayer mainActor = target as MainPlayer;
            if (mainActor != null && mainActor.IsActorExit)
            {
                m_curTargetID = 0;
            }
            else
            {
                return(true);
            }
        }
        if (IsCalled)
        {//被同伴呼叫
            return(true);
        }
        GetRangeTargetList(ENTargetType.enEnemy);
        if (Self.AttackRange > m_minDistance)
        {//进入攻击范围
            m_curTargetID = m_minActor.ID;
            return(true);
        }
        if (Self.DamageSource != null && !Self.DamageSource.IsDead)
        {     //受到伤害
            if (ActorTargetManager.IsEnemy(Self, Self.DamageSource))
            { //伤害来源是敌人
                m_curTargetID = Self.DamageSource.ID;
                return(true);
            }
        }
        //AlertAction action = Self.ActionControl.LookupAction(ActorAction.ENType.enAlertAction) as AlertAction;
        //if (action != null && action.IsTimeout)
        //{//敌人在警戒范围内停留超过警戒时间
        //    float minDistance = float.MaxValue;
        //    for (int i = 0; i < m_alertTargetList.Count; ++i)
        //    {
        //        int targetID = m_alertTargetList[i].m_targetID;
        //        target = ActorManager.Singleton.Lookup(targetID);
        //        if (target != null && !target.IsDead)
        //        {
        //            Vector3 d = target.RealPos - Self.RealPos;
        //            if (Mathf.Abs(d.magnitude) < minDistance)
        //            {
        //                m_curTargetID = targetID;
        //            }
        //        }
        //    }
        //    return true;
        //}
        return(false);
    }
示例#6
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;
        }
    }
示例#7
0
 //停止跟随主控角色
 bool StopFollow()
 {
     if (m_isStartFollow)
     {
         float distance = ActorTargetManager.GetTargetDistance(Self.RealPos, MainActor.RealPos);
         distance = Mathf.Abs(distance);
         if (distance < StopFollowDistance)
         {
             Self.ActionControl.RemoveAction(ActorAction.ENType.enMoveAction);
             return(true);
         }
     }
     return(false);
 }
示例#8
0
 void CheckSneak(Actor target)
 {
     if (target == null || target.IsDead)
     {
         return;
     }
     if (target.TempType == ActorType.enPlayer_Sneak)
     {//潜行中
         float distance = ActorTargetManager.GetTargetDistance(Self.RealPos, target.RealPos);
         if (Self.CurrentTableInfo.AlertRange > distance)
         {//警戒范围内
             target.StopSneak();
         }
     }
 }
示例#9
0
 void ChangeTarget(Actor target)
 {
     if (target.IsDead)
     {
         return;
     }
     if (ActorTargetManager.IsEnemy(m_self, target))
     {
         float d = ActorTargetManager.GetTargetDistance(m_self.MainPos, target.MainPos);
         if (m_self.CurrentTableInfo.AttackRange > d)
         {//改变目标
             target.CurrentTarget = m_self;
         }
     }
 }
示例#10
0
    //切入技改变
    void SwitchSkillChanged()
    {
        if (ActorManager.Singleton.Support == null || ActorManager.Singleton.Support.SkillBag.Count == 0)
        {
            return;
        }
        GameObject skill   = m_sameInfoList[SwitchSkillIndex].m_objSkill;
        GameObject enabled = FindChild("Enabled", skill);
        UITexture  sprite  = FindChildComponent <UITexture>("skill", skill);

        Actor.ActorSkillInfo info     = ActorManager.Singleton.Support.SkillBag[0];
        IconInfomation       iconInfo = GameTable.IconInfoTableAsset.Lookup(info.SkillTableInfo.Icon);

        sprite.mainTexture = PoolManager.Singleton.LoadIcon <Texture>(iconInfo.dirName);

        Material curMaterial = sprite.material;

        if (info.IsSilence)
        {//技能被沉默
            enabled.SetActive(true);
            curMaterial = m_diableMaterial;
        }
        else
        {
            if (m_mainPlayer.CurrentTargetIsDead)
            {//无目标
                enabled.SetActive(true);
                curMaterial = m_diableMaterial;
            }
            else
            {
                if (!ActorTargetManager.IsEnemy(m_mainPlayer, m_mainPlayer.CurrentTarget))
                {//当前目标不是敌人
                    enabled.SetActive(true);
                    curMaterial = m_diableMaterial;
                }
                else
                {
                    enabled.SetActive(false);
                    curMaterial = m_normalMaterial;
                }
            }
        }
        //if (sprite.material != curMaterial)
        {
            sprite.material = curMaterial;
        }
    }
示例#11
0
    bool FollowMainActor()
    {//跟随
        float distance = ActorTargetManager.GetTargetDistance(Self.RealPos, MainActor.RealPos);

        distance = Mathf.Abs(distance);
        if (distance > StartFollowDistance)
        {
            if (MainActor.CurrentTargetIsDead || Self.CurrentTargetIsDead)
            {//主控角色没有目标 或 同伴没有目标
                ActionMoveTo(MainActor.RealPos);
                mDisAbleFindPathTime = 0;
                return(true);
            }
        }
        return(false);
    }
示例#12
0
 void CheckTarget(Actor target)
 {
     if (target.IsDead)
     {
         return;
     }
     if (ActorTargetManager.IsEnemy(m_self, target))
     {
         float distance = ActorTargetManager.GetTargetDistance(m_self.RealPos, target.RealPos);
         if (distance < m_range)
         {
             if (!m_targetList.Contains(target))
             {
                 m_targetList.Add(target);
             }
         }
     }
 }
示例#13
0
 public void SetRoomTargetListToBoxNpc(List <NPC> treasureList)
 {
     m_minDistance = float.MaxValue;
     m_targetIDList.Clear();
     foreach (NPC item in treasureList)
     {
         if (item.GetNpcType() == ENNpcType.enBoxNPC && !item.IsDead)
         {
             float distance = ActorTargetManager.GetTargetDistance(Owner.RealPos, item.RealPos);
             if (distance < m_minDistance)
             {
                 m_minDistance = distance;
                 m_minActor    = item;
             }
             m_targetIDList.Add(item.ID);
         }
     }
 }
示例#14
0
 void CheckTarget(Actor target)
 {
     if (m_target != null)
     {
         return;
     }
     if (target.IsDead)
     {
         return;
     }
     if (ActorTargetManager.IsEnemy(m_info.m_actorCamp, m_info.m_actorType, target))
     {
         float d = ActorTargetManager.GetTargetDistance(m_info.m_itemObj.transform.position, target.RealPos);
         if (d < m_range)
         {
             m_target = target;
         }
     }
 }
示例#15
0
    // 创建reuslt的消息
    public override int SendCreateResult_C2BS(int resultId, int source, int target, int skillResultID = 0, int skillID = 0, float[] param = null)
    {
        MessageBlock msg = MessageBlock.CreateMessage(GamePacketID.ENMsgCreateResultC2BS, true);

        msg.AddParam("resultId", resultId);
        msg.AddParam("source", source);
        msg.AddParam("target ", target);
        msg.AddParam("skillResultID", skillResultID);
        msg.AddParam("skillID", skillID);

        Actor targetActor = ActorManager.Singleton.Lookup(target);
        Actor sourceActor = ActorManager.Singleton.Lookup(source);

        float d = 0.0f;

        if (null != targetActor && null != sourceActor)
        {
            d = ActorTargetManager.GetTargetDistance(sourceActor.RealPos, targetActor.RealPos);
        }

        msg.AddParam("distanace", d);

        if (param != null)
        {
            msg.AddParam("paramLength", param.Length);
            foreach (float item in param)
            {
                msg.AddParam("param", item);
            }
        }
        else
        {
            msg.AddParam("paramLength", 0);
        }


        LCMsgSender.Singleton.SendMsg(msg);
        int msgID = msg.MessageID;

        MessageBlock.ReleaseMessage(msg);
        return(msgID);
    }
示例#16
0
    void CheckActorDistance(Actor target, float[] param)
    {
        if (target.Type == ActorType.enNPC)
        {
            NPC npc = target as NPC;
            if (npc.GetNpcType() == ENNpcType.enBlockNPC ||
                npc.GetNpcType() == ENNpcType.enFunctionNPC)
            {
                return;
            }
        }
        else if (target.Type == ActorType.enMain)
        {
            if (target.IsActorExit)
            {
                return;
            }
        }
        if (target.IsDead)
        {
            return;
        }
        if (!ActorTargetManager.IsEnemy(mSelfActor, target))
        {
            return;
        }
        float distance = ActorTargetManager.GetTargetDistance(mSelfActor.RealPos, target.RealPos);

        if (distance <= param[1])//拖拽生效半径
        {
            Vector3        targetPos = mSelfActor.MainPos;
            DragMoveAction action    = target.ActionControl.AddAction(DragMoveAction.SGetActionType()) as DragMoveAction;
            if (null != action)
            {
                action.Init(targetPos, param[2], param[3]);//拖拽偏移量,拖拽速度
            }
            else
            {
                Debug.LogWarning("add DragMoveAction failed");
            }
        }
    }
示例#17
0
    static public bool IsFriendly(Actor self, Actor target)
    {
        if (self == target)
        {
            return(false);
        }
        ENCamp selfCamp = (ENCamp)self.Camp;

        if (selfCamp != self.TempCamp)
        {
            selfCamp = self.TempCamp;
        }
        ActorType selfType = self.Type;

        if (selfType != self.TempType)
        {
            selfType = self.TempType;
        }
        return(ActorTargetManager.IsFriendly(selfCamp, selfType, target));
    }
示例#18
0
 //近战攻击
 bool NearAttack()
 {
     if (!Self.CurrentTargetIsDead)
     {//有目标
         float d = ActorTargetManager.GetTargetDistance(Self.RealPos, Self.CurrentTarget.RealPos);
         if (d < 2)
         {
             if (Time.time - m_battleStartTime > 4)
             {//
              //释放“近战”技能
                 int skillID = GetSkillID(ENSkillDistanceType.enNear, ENSkillLevelType.enBase);
                 if (skillID != 0 && ActionTryFireSkill(skillID))
                 {
                     m_battleStartTime = Time.time;
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
示例#19
0
 public void BaseUpdate()
 {
     base.Update();
     if (Self.IsActorExit)
     {
         return;                  //当前角色离场
     }
     ReliveUI();
     #region Unlock
     if (!Self.CurrentTargetIsDead)
     {//判断距离 清除目标
         float distance = ActorTargetManager.GetTargetDistance(Self.MainPos, Self.CurrentTarget.MainPos);
         if (distance > Self.CurrentTableInfo.UnlockRange)
         {
             Self.CurrentTarget = null;
             Self.DamageSource  = null;
         }
     }
     #endregion
     CheckAllSkill();
 }
示例#20
0
 bool Evading()
 {
     if (Self.CurrentTargetIsDead)
     {
         MoveAction moveAction = MainActor.ActionControl.LookupAction(ActorAction.ENType.enMoveAction) as MoveAction;
         if (moveAction != null)
         {//如果主控角色正在移动
             float PosDistance = ActorTargetManager.GetTargetDistance(Self.MainPos, MainActor.MainPos);
             if (PosDistance < m_evadingValue)
             {//获去主控角色与同伴位置的距离
                 Vector3 mainMoveForward = moveAction.TargetPos - MainActor.MainPos;
                 Vector3 moveForward     = Self.MainPos - MainActor.MainPos;
                 moveForward.y     = 0;
                 mainMoveForward.y = 0;
                 moveForward.Normalize();
                 mainMoveForward.Normalize();
                 float angle = Vector3.Angle(moveForward, mainMoveForward);
                 if (angle < 90)
                 {
                     Vector3 verticalMoveForward = Vector3.Cross(mainMoveForward, new Vector3(0, 1, 0));
                     verticalMoveForward.Normalize();
                     int tmpIntX = (mainMoveForward.x > moveForward.x ? -1 : 1);
                     int tmpIntZ = (mainMoveForward.z > moveForward.z ? -1 : 1);
                     verticalMoveForward.x = Mathf.Abs(verticalMoveForward.x) * tmpIntX;
                     verticalMoveForward.z = Mathf.Abs(verticalMoveForward.z) * tmpIntZ;
                     Vector3 targetPos = Self.MainPos + (verticalMoveForward * m_evadingDistance);
                     if (!SM.RandomRoomLevel.Singleton.QuickFindPath(Self.MainPos, targetPos))
                     {
                         moveForward.x = moveForward.x * -1;
                         moveForward.z = moveForward.z * -1;
                         targetPos     = Self.MainPos + (verticalMoveForward * m_evadingDistance);
                     }
                     ActionMoveTo(targetPos);
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
 void CheckTarget(Actor target)
 {
     if (m_multiTargetList.Count == m_multiTargetNumber)
     {
         return;
     }
     if (target.IsDead)
     {
         return;
     }
     if (ActorTargetManager.IsEnemy(m_self, target))
     {
         float d = ActorTargetManager.GetTargetDistance(m_self.MainPos, target.MainPos);
         if (m_multiTargetRange > d)
         {
             if (!m_multiTargetList.Contains(target))
             {
                 m_multiTargetList.Add(target);
             }
         }
     }
 }
示例#22
0
    public void SetRoomTrageListToTrap(List <Trap> trapList)
    {
        m_minDistance = float.MaxValue;
        m_targetIDList.Clear();
        Dictionary <float, List <int> > tmpTrapDic = new Dictionary <float, List <int> >();
        List <float> tmpDistList = new List <float>();

        foreach (Trap item in trapList)
        {
            if (item.mTrapType == TrapType.enAuto || item.mTrapType == TrapType.enTouchType)
            {
                continue;
            }
            if (!item.m_trapActivate)
            {
                float distance = ActorTargetManager.GetTargetDistance(Owner.RealPos, item.RealPos);
                if (tmpTrapDic.ContainsKey(distance))
                {
                    tmpTrapDic[distance].Add(item.ID);
                }
                else
                {
                    List <int> tmpList = new List <int> ();
                    tmpList.Add(item.ID);
                    tmpTrapDic.Add(distance, tmpList);
                    tmpDistList.Add(distance);
                }
            }
        }
        tmpDistList.Sort();
        foreach (var item in tmpDistList)
        {
            foreach (var id in tmpTrapDic[item])
            {
                m_targetIDList.Add(id);
            }
        }
    }
示例#23
0
    public bool ChangeOtherPos()
    {
        MoveAction moveAction = Self.ActionControl.LookupAction(ActorAction.ENType.enMoveAction) as MoveAction;

        if (moveAction != null)
        {//如果主控角色正在移动
            float PosDistance = ActorTargetManager.GetTargetDistance(Self.MainPos, MainActor.MainPos);
            if (PosDistance < 1)
            {//获去主控角色与同伴位置的距离
                Vector3 selfMoveForward = moveAction.TargetPos - Self.MainPos;
                Vector3 moveForward     = MainActor.MainPos - Self.MainPos;
                moveForward.y     = 0;
                selfMoveForward.y = 0;
                moveForward.Normalize();
                selfMoveForward.Normalize();
                float angle = Vector3.Angle(moveForward, selfMoveForward);
                if (angle < 45)
                {
                    Vector3 verticalMoveForward = Vector3.Cross(selfMoveForward, new Vector3(0, 1, 0));
                    verticalMoveForward.Normalize();
                    int tmpIntX = (selfMoveForward.x > moveForward.x ? 1 : -1);
                    int tmpIntZ = (selfMoveForward.z > moveForward.z ? 1 : -1);
                    verticalMoveForward.x = Mathf.Abs(verticalMoveForward.x) * tmpIntX;
                    verticalMoveForward.z = Mathf.Abs(verticalMoveForward.z) * tmpIntZ;
                    Vector3 targetPos = Self.MainPos + (verticalMoveForward * 3);
//                     if (!SDungeonsMgr.Singleton.QuickFindPath(Self.MainPos, targetPos))
//                     {
//                         moveForward.x = moveForward.x * -1;
//                         moveForward.z = moveForward.z * -1;
//                         targetPos = Self.MainPos + (verticalMoveForward * 3);
//                     }
                    ActionMoveTo(targetPos);
                    return(true);
                }
            }
        }
        return(false);
    }
示例#24
0
 bool SwitchTargetToMainTarget()
 {//切换到主控角色的目标
     if (Self.CurrentTargetIsDead || !(Self.CurrentTarget as NPC).m_priorityAttack)
     {
         if (!MainActor.CurrentTargetIsDead)
         {//主控角色有目标
             if (!ActorTargetManager.IsEnemy(Self, MainActor.CurrentTarget))
             {
                 return(false);
             }
             if (Time.time - MainActor.TargetManager.m_getTagetTimer > GetTargetDuration)
             {     //超过获得目标时长
                 if (MainActor.CurrentTarget != Self.CurrentTarget)
                 { //主控角色的目标与同伴的目标不一致
                     //设置目标
                     Self.CurrentTarget = MainActor.CurrentTarget;
                     m_curTargetID      = MainActor.CurrentTarget.ID;
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
示例#25
0
    bool StartFollow()
    {
        mForceMovePos = Vector3.zero;
        float distance = ActorTargetManager.GetTargetDistance(Self.RealPos, MainActor.RealPos);

        if (distance > StartFollowDistance)
        {
//             MoveAction action = MainActor.ActionControl.LookupAction(ActorAction.ENType.enMoveAction) as MoveAction;
//             if (action != null && action.mRealSpeed != 0)
//             {
//                 mForceMovePos = action.mLastMovePos;
//             }
//             else
//             {
//                 if (mForceMovePos == Vector3.zero)
//                 {
//                     mForceMovePos = MainActor.MainPos;
//                 }
//             }
            mForceMovePos = GetPosGroundPos(MainActor.MainPos);
            if (NormalForceMove(distance, mForceMovePos))
            {
                ActionForwardTo(MainActor.ID);
                return(true);
            }
            else if (forceMove(mForceMovePos))
            {
                ActionForwardTo(MainActor.ID);
                return(true);
            }
            else
            {
                if (MainActor.CurrentTargetIsDead || Self.CurrentTargetIsDead)
                {//主控角色没有目标 或 同伴没有目标
                    ActionMoveTo(MainActor.RealPos);
                    return(true);
                }
            }
//             if (!SDungeonsMgr.Singleton.QuickFindPath(Self.MainPos, MainActor.MainPos) || distance > ForceMoveDistance)
//             {//跟主控角色之间不能寻路或者距离过大
//                 if (mDisAbleFindPathTime == 0)
//                 {//如果不能寻路的时间为0说明这次是第一次不能寻路,为不能寻路的时间赋值
//                     mDisAbleFindPathTime = Time.time;
//                 }
//                 if (Time.time - mDisAbleFindPathTime > MaxFindPathTime)
//                 {
//                     TeleportAction teleportAction = Self.ActionControl.AddAction(ActorAction.ENType.enTeleportAction) as TeleportAction;
//                     if (teleportAction != null)
//                     {
//                         teleportAction.Init(mForceMovePos);
//                     }
//                     //Self.ForceMoveToPosition(mForceMovePos);
//                     mDisAbleFindPathTime = 0;
//                     return true;
//                 }
//             }
//             else
//             {
//                 mDisAbleFindPathTime = 0;
//                 if (MainActor.CurrentTargetIsDead || Self.CurrentTargetIsDead)
//                 {//主控角色没有目标 或 同伴没有目标
//                     ActionMoveTo(MainActor.RealPos);
//                     return true;
//                 }
//             }
        }
//         if (ForceMove())
//         {//瞬移
//             return true;
//         }
//         else if (FollowMainActor())
//         {//跟随
//             return true;
//         }
        return(false);
    }
示例#26
0
    void UpdateImpl(bool damping)
    {
        //camera跟随目标的位置
        Vector3 cameraPos = Vector3.zero;
        //
        float smoothTime = 0;

        switch (m_curTargetType)
        {
        case ENCameraTargetType.enActor:
        {
            if (m_targetActor == null)
            {
                return;
            }
            GameObject obj = m_targetActor.CenterPart;
            if (m_targetActor.ActionControl.IsActionEmpty() ||
                m_targetActor.ActionControl.IsActionRunning(ActorAction.ENType.enStandAction) ||
                m_targetActor.ActionControl.IsActionRunning(ActorAction.ENType.enActorEnterAction) ||
                IsNormalAttack())
            {
                obj = m_targetActor.MainObj;
            }
            cameraPos = null != obj ? obj.transform.position : Vector3.zero;

            if (!m_targetActor.IsDead)
            {        //主控角色未死亡时,对准主控角色跟目标之间
                Actor target = m_targetActor.CurrentTarget;
                if (target != null && !target.IsDead)
                {
                    Vector3 selfPos   = cameraPos;
                    Vector3 targetPos = target.MainPos;
                    selfPos.y   = 0;
                    targetPos.y = 0;
                    cameraPos   = selfPos + (targetPos - selfPos) * 0.5f;
                }
            }
            //计算smooth时间
            smoothTime = GameSettings.Singleton.m_cameraSmoothTimeForStart;
            MoveAction action = m_targetActor.ActionControl.LookupAction(ActorAction.ENType.enMoveAction) as MoveAction;
            if (action != null && CursorEffectFunc.Singleton.CurFingerType != CursorEffectFunc.ENFingerType.enOnDragMoveType)
            {
                float d = ActorTargetManager.GetTargetDistance(m_targetActor.RealPos, action.m_realTargetPos);
                if (d < GameSettings.Singleton.m_cameraStopDistance)
                {
                    smoothTime = GameSettings.Singleton.m_cameraSmoothTimeForStop;
                }
            }
            else if (m_lastCameraPos == cameraPos)
            {        //目标停止运动
                smoothTime = GameSettings.Singleton.m_cameraSmoothTimeForStop;
            }
            float velocity = 0;
            m_currentSmoothTime = Mathf.SmoothDamp(m_currentSmoothTime, smoothTime, ref velocity, GameSettings.Singleton.m_timeForCameraChangeTime);
        }
        break;

        case ENCameraTargetType.enGameObject:
        {
            cameraPos  = m_targetObj.transform.position;
            smoothTime = m_changeTime;
            if (m_autoBackTime != 0)
            {
                if (Time.time - m_startTime > m_autoBackTime)
                {
                    m_changeTime    = m_backTime;
                    m_startTime     = Time.time;
                    m_curTargetType = ENCameraTargetType.enBackToActor;
                }
            }
            m_currentSmoothTime = smoothTime;
        }
        break;

        case ENCameraTargetType.enPostion:
        {
            cameraPos  = m_targetPos;
            smoothTime = m_changeTime;
            if (m_autoBackTime != 0)
            {
                if (Time.time - m_startTime > m_autoBackTime)
                {
                    m_changeTime    = m_backTime;
                    m_startTime     = Time.time;
                    m_curTargetType = ENCameraTargetType.enBackToActor;
                }
            }
            m_currentSmoothTime = smoothTime;
        }
        break;

        case ENCameraTargetType.enBackToActor:
        {
            GameObject obj = m_targetActor.CenterPart;
            if (m_targetActor.ActionControl.IsActionEmpty() ||
                m_targetActor.ActionControl.IsActionRunning(ActorAction.ENType.enStandAction) ||
                m_targetActor.ActionControl.IsActionRunning(ActorAction.ENType.enActorEnterAction) ||
                IsNormalAttack())
            {
                obj = m_targetActor.MainObj;
            }
            cameraPos = null != obj ? obj.transform.position : Vector3.zero;

            if (!m_targetActor.IsDead)
            {        //主控角色未死亡时,对准主控角色跟目标之间
                Actor target = m_targetActor.CurrentTarget;
                if (target != null && !target.IsDead)
                {
                    Vector3 selfPos   = cameraPos;
                    Vector3 targetPos = target.MainPos;
                    selfPos.y   = 0;
                    targetPos.y = 0;
                    cameraPos   = selfPos + (targetPos - selfPos) * 0.5f;
                }
            }

            smoothTime = m_changeTime;
            if (Time.time - m_startTime > m_changeTime)
            {
                m_curTargetType = ENCameraTargetType.enActor;
            }
            m_currentSmoothTime = smoothTime;
        }
        break;

        default:
        {
            m_curTargetType = ENCameraTargetType.enActor;
            UpdateImpl(damping);
            return;
        }
//                break;
        }
        m_lastCameraPos = cameraPos;
        if (!m_isChangeY)
        {
            cameraPos.y = 0.35f;
        }

        //拉远
        MainCamera.transform.position = cameraPos;
        MainCamera.transform.Translate(Vector3.back * GameSettings.Singleton.CameraDistance);
        MainCamera.transform.rotation = Quaternion.Euler(GameSettings.Singleton.CameraRotate);
        cameraPos = MainCamera.transform.position;

        //damp
        if (damping)
        {
            float x = Mathf.SmoothDamp(m_lastCacheCameraPos.x, cameraPos.x, ref xVelocity, m_currentSmoothTime, GameSettings.Singleton.m_smoothMaxSpeed);
            float y = Mathf.SmoothDamp(m_lastCacheCameraPos.y, cameraPos.y, ref yVelocity, m_currentSmoothTime, GameSettings.Singleton.m_smoothMaxSpeed);
            float z = Mathf.SmoothDamp(m_lastCacheCameraPos.z, cameraPos.z, ref zVelocity, m_currentSmoothTime, GameSettings.Singleton.m_smoothMaxSpeed);
            cameraPos = new Vector3(x, y, z);
        }
        Vector3 pos = CheckFloat(m_shakeObj.transform.localPosition);

        //shake
        cameraPos += pos;
        MainCamera.transform.position = cameraPos;
        m_lastCacheCameraPos          = cameraPos;
    }
示例#27
0
    private void CheckTarget(Actor target)
    {
        Actor CurrentActor = this as Actor;

        if (CurrentActor == target)
        {
            return;
        }
        if (target.IsDead)
        {
            return;
        }
        if (!IsCanSelectTarget(target))
        {
            return;
        }
        if (!ActorTargetManager.IsEnemy(CurrentActor, target))
        {
            if (target.Type == ActorType.enNPC)
            {
                NPC npc = target as NPC;
                if (npc.GetNpcType() != ENNpcType.enBoxNPC)
                {
                    return;
                }
            }
            else
            {
                return;
            }
        }
        float distance = ActorTargetManager.GetTargetDistance(CurrentActor.RealPos, target.RealPos);
        //Vector3 targetDirection = target.RealPos - CurrentActor.RealPos;
        //targetDirection.y = 0.0f;
        WorldParamInfo info = GameTable.WorldParamTableAsset.Lookup((int)ENWorldParamIndex.enChangeTargetDistance);

        if (info == null)
        {
            return;
        }
        //if (targetDirection.magnitude > info.FloatTypeValue)
        if (distance > info.FloatTypeValue)
        {
            return;
        }
        //targetDirection.Normalize();
        //Vector3 direction = CurrentActor.MainObj.transform.forward;

        //float yRot = Vector3.Angle(targetDirection, direction);
        //if (yRot < 360.0f)
        {
            CurrentActor.TargetManager.AddTarget(target);
            //if (yRot < m_minRot)
            if (distance < m_minRot)
            {
                if (1 == CurrentActor.TargetManager.GetTargetListValue(target))
                {
                    return;
                }
                //m_minRot = yRot;
                m_minRot = distance;
                CurrentActor.TargetManager.CurrentTarget = target;
            }
        }
    }
示例#28
0
    //释放连接技或特殊技
    bool FireConnectOrSpecialSkill()
    {
        if (Self.WTF != null && Self.WTF.IsWillBurning)
        {//意志燃烧中
            int randValue = UnityEngine.Random.Range(0, (int)ENRandType.enCount);
            switch ((ENRandType)randValue)
            {
            case ENRandType.enHaveTargetSkill:
            {        //指定目标的技能
                foreach (var item in Self.SkillBag)
                {
                    if (!item.IsCanFire(Self))
                    {
                        continue;
                    }
                    if (item.SkillTableInfo.TargetType == (int)ENTargetType.enNullTarget)
                    {        //无目标技能
                        continue;
                    }
                    if ((int)ENSkillConnectionType.enConnect == item.SkillTableInfo.SkillConnectionType ||
                        (int)ENSkillConnectionType.enSpecial == item.SkillTableInfo.SkillConnectionType)
                    {        //连接技和特殊技
                        if (ActionTryFireSkill(item.SkillTableInfo.ID))
                        {    //释放技能成功
                            return(true);
                        }
                    }
                }
            }
            break;

            case ENRandType.enNullTargetSkill:
            {        //无目标的技能
                float d = ActorTargetManager.GetTargetDistance(Self.RealPos, Self.CurrentTarget.RealPos);
                if (Self.CurrentTableInfo.AutoAttackRange >= d)
                {        //自动攻击范围内
                    foreach (var item in Self.SkillBag)
                    {
                        if (!item.IsCanFire(Self))
                        {
                            continue;
                        }
                        if (item.SkillTableInfo.TargetType != (int)ENTargetType.enNullTarget)
                        {        //不是无目标技能
                            continue;
                        }
                        if (ActionTryFireSkill(item.SkillTableInfo.ID))
                        {        //释放技能成功
                            return(true);
                        }
                    }
                }
            }
            break;

            case ENRandType.enBuffSkill:
            {        //buff技能
                Actor friendActor = null;
                int   r           = UnityEngine.Random.Range(0, 2);
                if (r == 0)
                {
                    friendActor = Self;
                }
                else
                {
                    friendActor = MainActor;
                }
                foreach (var item in Self.SkillBag)
                {
                    if (!item.IsCanFire(Self))
                    {
                        continue;
                    }
                    if (item.SkillTableInfo.SkillEffectType != (int)ENSkillEffectType.enBuff)
                    {        //不是buff技能
                        continue;
                    }
                    if (ActionTryAttack(item.SkillTableInfo.ID, friendActor))
                    {        //释放技能成功
                        return(true);
                    }
                }
            }
            break;

            case ENRandType.enRestoreSkill:
            {        //恢复技能
                Actor friendActor = null;
                int   r           = UnityEngine.Random.Range(0, 2);
                if (r == 0)
                {
                    friendActor = Self;
                }
                else
                {
                    friendActor = MainActor;
                }
                foreach (var item in Self.SkillBag)
                {
                    if (!item.IsCanFire(Self))
                    {
                        continue;
                    }
                    if (item.SkillTableInfo.SkillEffectType != (int)ENSkillEffectType.enRestore)
                    {        //不是恢复技能
                        continue;
                    }
                    if (ActionTryAttack(item.SkillTableInfo.ID, friendActor))
                    {        //释放技能成功
                        return(true);
                    }
                }
            }
            break;
            }
        }
        return(false);
    }
示例#29
0
    void CheckActorDistance(Actor target, BuffResultInfo info)
    {
        if (target.Type == ActorType.enNPC)
        {
            NPC npc = target as NPC;
            if (npc.GetNpcType() == ENNpcType.enBlockNPC ||
                npc.GetNpcType() == ENNpcType.enFunctionNPC)
            {
                return;
            }
        }
        else if (target.Type == ActorType.enMain)
        {
            if (target.IsActorExit)
            {
                return;
            }
        }
        if (target.IsDead)
        {
            return;
        }

        switch ((ENTargetType)info.ParamList[2])//判断技能目标类型
        {
        case ENTargetType.enEnemy:
        {
            if (!ActorTargetManager.IsEnemy(m_selfActor, target))
            {
                return;
            }
        }
        break;

        case ENTargetType.enFriendly:
        {
            if (!ActorTargetManager.IsFriendly(m_selfActor, target))
            {
                return;
            }
        }
        break;

        case ENTargetType.enSelf:
        {
            if (m_selfActor != target)
            {
                return;
            }
        }
        break;

        case ENTargetType.enNullTarget:
            break;

        case ENTargetType.enFriendlyAndSelf:
        {
            if (!ActorTargetManager.IsFriendly(m_selfActor, target) && m_selfActor != target)
            {
                return;
            }
        }
        break;

        default:
            break;
        }
        float distance = ActorTargetManager.GetTargetDistance(m_selfActor.RealPos, target.RealPos);
        bool  tmpFlag  = true;

        if (distance <= info.ParamList[1])//判断光环半径
        {
            foreach (Buff tmpBuf in target.MyBuffControl.BuffList)
            {
                if (tmpBuf.BuffID == (int)info.ParamList[2])
                {
                    tmpFlag = false;
                }
            }
            if (tmpFlag)
            {
                IResult addBuffResult = BattleFactory.Singleton.CreateResult(ENResult.AddBuff, m_selfActor.ID, target.ID, 0, 0, new float[1] {
                    info.ParamList[3]
                });
                if (addBuffResult != null)
                {
                    addBuffResult.ResultExpr(new float[1] {
                        info.ParamList[3]
                    });                                                          //添加技能ID
                    BattleFactory.Singleton.DispatchResult(addBuffResult);
                }
            }
        }
        else
        {
            tmpFlag = false;
            foreach (Buff tmpBuf in target.MyBuffControl.BuffList)
            {
                if (tmpBuf.BuffID == info.ParamList[2])
                {
                    tmpFlag = true;
                }
            }
            if (tmpFlag)
            {
                IResult rbResult = BattleFactory.Singleton.CreateResult(ENResult.RemoveBuff, m_selfActor.ID, target.ID, 0, 0, new float[2] {
                    (float)ResultRemoveBuff.ENRemoveBuffType.enBuffID, info.ParamList[3]
                });
                if (rbResult != null)
                {
                    rbResult.ResultExpr(new float[2] {
                        (float)ResultRemoveBuff.ENRemoveBuffType.enBuffID, info.ParamList[3]
                    });
                    BattleFactory.Singleton.DispatchResult(rbResult);
                }
            }
        }
    }
示例#30
0
    //战斗托管时组建targetList
    void CheckAutoBattleTarget(ENTargetType type, Actor target)
    {
        if (target.Type == ActorType.enNPC)
        {
            NPC npc = target as NPC;
            if (npc.GetNpcType() == ENNpcType.enBlockNPC ||
                npc.GetNpcType() == ENNpcType.enFunctionNPC)
            {
                return;
            }
        }
        else if (target.Type == ActorType.enMain)
        {
            if (target.IsActorExit)
            {
                return;
            }
        }
        if (target.IsDead)
        {
            return;
        }
        switch (type)
        {
        case ENTargetType.enEnemy:
        {
            if (!ActorTargetManager.IsEnemy(Owner, target))
            {
                return;
            }
        }
        break;

        case ENTargetType.enFriendly:
        {
            if (!ActorTargetManager.IsFriendly(Owner, target))
            {
                return;
            }
        }
        break;

        case ENTargetType.enSelf:
        {
            if (Owner != target)
            {
                return;
            }
        }
        break;

        case ENTargetType.enNullTarget:
            break;

        case ENTargetType.enFriendlyAndSelf:
        {
            if (!ActorTargetManager.IsFriendly(Owner, target) && Owner != target)
            {
                return;
            }
        }
        break;

        default:
            break;
        }
        float distance = ActorTargetManager.GetTargetDistance(Owner.RealPos, target.RealPos);

        if (distance < m_minDistance)
        {
            m_minDistance = distance;
            m_minActor    = target;
        }
        m_targetIDList.Add(target.ID);
    }