예제 #1
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);
    }
예제 #2
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);
    }
예제 #3
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;
         }
     }
 }
예제 #4
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;
        }
    }
예제 #5
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);
             }
         }
     }
 }
예제 #6
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;
         }
     }
 }
예제 #7
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");
            }
        }
    }
예제 #8
0
    static public bool IsEnemy(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.IsEnemy(selfCamp, selfType, target));
    }
 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);
             }
         }
     }
 }
예제 #10
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);
 }
예제 #11
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);
    }
예제 #12
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);
                }
            }
        }
    }
예제 #13
0
    //paramList
    //0:resultID
    //1:resultRange
    //2:resultTargetType
    //3:skillID
    void CheckTarget(Actor target, float[] paramList)
    {
        if (isReturn)
        {
            return;
        }
        if (target.IsDead)
        {
            return;
        }
        float range = paramList[1];
        float d     = ActorTargetManager.GetTargetDistance(m_self.RealPos, target.RealPos);

        if (d > range)
        {
            return;
        }
        ENResultTargetType type = (ENResultTargetType)paramList[2];

        switch ((ENResultTargetType)type)
        {
        case ENResultTargetType.enEnemySingle:
        {
            if (ActorTargetManager.IsEnemy(m_self, target))
            {
                CreateResult_Skill((int)paramList[0], target, (int)paramList[3], paramList);
                isReturn = true;
            }
        }
        break;

        case ENResultTargetType.enEnemyAll:
        {
            if (ActorTargetManager.IsEnemy(m_self, target))
            {
                CreateResult_Skill((int)paramList[0], target, (int)paramList[3], paramList);
            }
        }
        break;

        case ENResultTargetType.enFriendlySingle:
        {
            if (ActorTargetManager.IsFriendly(m_self, target))
            {
                CreateResult_Skill((int)paramList[0], target, (int)paramList[3], paramList);
                isReturn = true;
            }
        }
        break;

        case ENResultTargetType.enFriendlyAll:
        {
            if (ActorTargetManager.IsFriendly(m_self, target))
            {
                CreateResult_Skill((int)paramList[0], target, (int)paramList[3], paramList);
                isReturn = true;
            }
        }
        break;

        case ENResultTargetType.enEveryone:
        {
            CreateResult_Skill((int)paramList[0], target, (int)paramList[3], paramList);
        }
        break;

        case ENResultTargetType.enFriendlyAllAndSelf:
        {
            if (ActorTargetManager.IsFriendly(m_self, target) || m_self == target)
            {
                CreateResult_Skill((int)paramList[0], target, (int)paramList[3], paramList);
            }
        }
        break;
        }
    }
예제 #14
0
    void CheckTarget(Actor target)
    {
        if (target == null || target.IsDead)
        {
            return;
        }
        Vector3 d = target.RealPos - Self.RealPos;

        d.y = 0;
        float distance = d.magnitude;

        foreach (var item in Self.SkillBag)
        {
            if (item.IsSilence)
            {
                continue;
            }
            if (item.MinComboRequir > Self.Combo.TotalComboNumber)
            {//combo值不足,不能释放技能
                continue;
            }
            if (Self.CurrentRage < item.SkillTableInfo.CostRagePoint)
            {//怒气值不足
                continue;
            }
            if (distance < item.SkillTableInfo.LeastAttackDistance)
            {//最小攻击距离内
                continue;
            }
            float attackRange = Self.CurrentTableInfo.AttackRange;
            if (!Self.CurrentTargetIsDead)
            {
                attackRange = item.SkillTableInfo.AttackDistance > attackRange ? item.SkillTableInfo.AttackDistance : attackRange;
            }
            if (distance < attackRange)
            {//攻击距离内
                switch ((ENTargetType)item.SkillTableInfo.TargetType)
                {
                case ENTargetType.enEnemy:
                    if (!ActorTargetManager.IsEnemy(Self, target))
                    {
                        continue;
                    }
                    break;

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

                case ENTargetType.enSelf:
                    if (Self != target)
                    {
                        continue;
                    }
                    break;

                case ENTargetType.enNullTarget:
                    break;

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

                default:
                    continue;
                    //break;
                }
                if (!m_newSkillIDListForFire.Contains(item.SkillTableInfo.ID))
                {
                    if (Self.NormalSkillList.Contains(item.SkillTableInfo.ID))
                    {
                        m_newSkillIDListForFire.AddRange(Self.NormalSkillList);
                    }
                    else
                    {
                        m_newSkillIDListForFire.Add(item.SkillTableInfo.ID);
                    }
                }
                if (!SkillIDListForFire.Contains(item.SkillTableInfo.ID))
                {
                    m_isSkillUpdateForFire = true;
                }

                if (item.SkillTableInfo.SkillType == (int)ENSkillType.enSkill)
                {//skill
                    FireSkillIDListWithoutNormal.Add(item.SkillTableInfo.ID);
                }
            }
        }
    }
예제 #15
0
    public override void Update()
    {
        base.Update();
        if (Self.IsActorExit)
        {
            return;                  //当前角色离场
        }
        //TimeToRelive();
        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(); //检测可释放技能
        if (Self.CurrentCmd == null)
        {                //当前没有命令
            MoveAction action = Self.ActionControl.LookupAction(ActorAction.ENType.enMoveAction) as MoveAction;
            if ((action == null || action.IsStopMove) &&
                !Self.ActionControl.IsActionRunning(ActorAction.ENType.enAttackAction) &&
                !Self.ActionControl.IsActionRunning(ActorAction.ENType.enRollAction))
            {     //不在移动、攻击、翻滚等位移动作中
                if (!Self.CurrentTargetIsDead)
                { //当前目标没死
                    float distance = ActorTargetManager.GetTargetDistance(Self.RealPos, Self.CurrentTarget.RealPos);
                    if (Self.CurrentTableInfo.AutoAttackRange > distance)
                    {//当前目标在自动攻击范围内
                        //Self.FireNormalSkill();
                        return;
                    }
                }
                else
                {
                    if (m_isAutoAttack)
                    {
                        m_autoAttackInterval -= Time.deltaTime;
                        if (m_autoAttackInterval < 0)
                        {
                            GetRangeTargetList(ENTargetType.enEnemy, Self.CurrentTableInfo.AutoAttackRange);
                            if (m_targetIDList.Count > 0)
                            {
                                Self.TargetManager.CurrentTarget = m_minActor;
                                Self.CurrentCmd           = new Player.Cmd(Player.ENCmdType.enLoopNormalAttack);
                                Self.CurrentCmd.m_skillID = Self.NormalSkillList[0];
                                return;
                            }
                        }
                    }
                }
                //自动反击
                if (m_lastActionTime == 0)
                {
                    m_lastActionTime = Time.time;
                }
                if (!m_isCounterattack && Time.time - m_lastActionTime > GameSettings.Singleton.m_autoCounterattack)
                {//距离最后一次位移动作 已超过3秒 可以反击
                    m_isCounterattack = false;
                }
            }
            if (m_isCounterattack)
            {//可以反击
                if (Self.DamageTime > m_lastActionTime + GameSettings.Singleton.m_autoCounterattack)
                {
                    if (Self.DamageSource != null && !Self.DamageSource.IsDead && ActorTargetManager.IsEnemy(Self, Self.DamageSource))
                    {
                        if (m_counterSkillRange == 0)
                        {
                            SkillInfo info = GameTable.SkillTableAsset.Lookup(Self.NormalSkillList[0]);
                            m_counterSkillRange = info.AttackDistance;
                        }
                        Vector3 distance = Owner.RealPos - Self.DamageSource.RealPos;
                        distance.y = 0;
                        if (distance.magnitude > m_counterSkillRange)
                        {//不在攻击范围内
                            //向技能目标移动
                            ActionMoveTo(Self.DamageSource.RealPos);
                        }
                        else
                        {//在攻击范围内
                            //释放技能
                            if (ActionTryAttack(Self.NormalSkillList[0], Self.DamageSource))
                            {
                                m_curTargetID      = Self.DamageSource.ID;
                                Self.CurrentTarget = ActorManager.Singleton.Lookup(m_curTargetID);
                                m_lastActionTime   = 0;
                                m_isCounterattack  = false;
                                return;
                            }
                        }
                    }
                }
            }
        }
        else
        {
            MainPlayer.Cmd cmd = Self.CurrentCmd;
            if (cmd.m_type != Player.ENCmdType.enSkill && cmd.m_type != Player.ENCmdType.enLoopNormalAttack)
            {//取消自动攻击
                m_isAutoAttack = false;
            }
            //最后一次动作的时间
            m_lastActionTime = 0;
            //清除自动反击
            m_isCounterattack = false;
            if (cmd.m_type != Player.ENCmdType.enSkill)
            {//取消技能高亮
                DelSkillHighlight();
            }

            m_autoAttackInterval = GameSettings.Singleton.m_autoAttackInterval;
            if (!IsCmdExecute())
            {//命令不允许执行
                Self.CurrentCmd = null;
                return;
            }

            m_curTargetID = 0;
            if (!Self.CurrentTargetIsDead)
            {
                m_curTargetID = Self.CurrentTarget.ID;
            }
            switch (cmd.m_type)
            {
            case Player.ENCmdType.enMove:
            {
                //  [8/3/2015 tgame]
                if (cmd.m_isMoveByNoAStar)
                {
                    if (ActionMoveToNotAStar(cmd.m_moveTargetPos))
                    {
                        //点击地面特效
                        Self.IsMoveAfterSwitch = false;
                        Self.CurrentCmd        = null;
                    }
                }
                else
                {
                    if (ActionMoveTo(cmd.m_moveTargetPos))
                    {
                        //点击地面特效
                        Self.IsMoveAfterSwitch = false;
                        Self.CurrentCmd        = null;
                    }
                }
            }
            break;

            case Player.ENCmdType.enStopMove:
            {
                MoveAction ac = Self.ActionControl.LookupAction(ActorAction.ENType.enMoveAction) as MoveAction;
                if (ac != null)
                {
                    Self.ActionControl.RemoveAction(ActorAction.ENType.enMoveAction);
                }
            }
            break;

            case Player.ENCmdType.enRoll:
            {
                RollAction rollAction = Self.ActionControl.AddAction(ActorAction.ENType.enRollAction) as RollAction;
                if (rollAction != null)
                {
                    rollAction.Init(cmd.m_moveTargetPos);
                    Self.CurrentCmd = null;
                }
            }
            break;

            case Player.ENCmdType.enSwitchActor:
            {
                if (!m_isAttacking)
                {
                    if (Self.ActionControl.IsActionRunning(ActorAction.ENType.enAttackAction))
                    {
                        if (ActorManager.Singleton.m_switchCDTotal > 0)
                        {        //cd中,继续攻击
                            Self.FireNormalSkill();
                            return;
                        }
                        m_isAttacking = true;
                    }
                }
                if (ActorManager.Singleton.SwitchMainActor(false, m_isAttacking))
                {
                    Self.CurrentCmd = null;
                    m_isAttacking   = false;
                }
            }
            break;

            case Player.ENCmdType.enSkill:
            {
                int skillID = cmd.m_skillID;
                Actor.ActorSkillInfo info = Self.SkillBag.Find(item => item.SkillTableInfo.ID == skillID);
                if (IsFireSkill(skillID))
                {
                    GetRangeTargetList((ENTargetType)info.SkillTableInfo.TargetType, Self.CurrentTableInfo.AttackRange, Self.m_firstTargetType);
                    if (ActionTryFireSkill(skillID))
                    {
                        m_isAutoAttack = false;
                        m_lastSkillID  = skillID;
                        DelSkillHighlight();

                        Actor target = ActorManager.Singleton.Lookup(m_curTargetID);
                        if (target != null && ActorTargetManager.IsEnemy(Self, target))
                        {        //只对仇人进行循环普攻
                            Self.CurrentTarget        = target;
                            Self.CurrentCmd.m_skillID = Self.NormalSkillList[0];
                            Self.CurrentCmd.m_type    = Player.ENCmdType.enStop;     //enLoopNormalAttack;
                        }
                        else
                        {
                            Self.CurrentCmd = null;
                        }
                    }
                    else
                    {
                        if (m_targetIDList.Count == 0)
                        {
                            DelSkillHighlight();
                            Self.CurrentCmd = null;
                        }
                    }
                }
                else
                {
                    GetRangeTargetList((ENTargetType)info.SkillTableInfo.TargetType, Self.CurrentTableInfo.AttackRange);
                    if (m_targetIDList.Count != 0 && skillID != m_highlightSkillID)
                    {        //技能高亮的通知
                        AddSkillHighlight();
                        m_highlightSkillID = skillID;
                    }
                }
            }
            break;

            case Player.ENCmdType.enLoopNormalAttack:
            {
                int skillID = Self.CurrentCmd.m_skillID;
                if (Self.CurrentTargetIsDead)
                {        //循环攻击时 必须要有目标 目标不能死亡
                    Self.CurrentCmd = null;
                    return;
                }
                if (IsFireSkill(skillID))
                {
                    if (ActionTryFireSkill(skillID))
                    {
                        m_lastSkillID = skillID;
                    }
                }
            }
            break;

            default:
                break;
            }
        }
    }
예제 #16
0
    bool LookupTarget(SkillInfo info, out Actor skillTarget, out float closestDistance)
    {
        skillTarget     = null;
        closestDistance = float.MaxValue;
        //if (info.SkillTableInfo.SkillEffectType == (int)ENSkillEffectType.enRestore)
        //{
        //    return false;
        //}
        if (info.TargetType == (int)ENTargetType.enNullTarget)
        {//不需要目标就能释放的技能
            return(true);
        }
        //首先查看是否可对当前目标释放
        Actor curTarget = ActorManager.Singleton.Lookup(m_curTargetID);

        if (curTarget != null && !curTarget.IsDead)
        {
            float distance = ActorTargetManager.GetTargetDistance(Owner.MainPos, curTarget.MainPos);
            if (distance >= info.LeastAttackDistance)
            {//最小攻击距离外
                switch ((ENTargetType)info.TargetType)
                {
                case ENTargetType.enEnemy:
                {
                    if (ActorTargetManager.IsEnemy(Owner, curTarget))
                    {
                        skillTarget = curTarget;
                        return(true);
                    }
                }
                break;

                case ENTargetType.enFriendly:
                {
                    if (ActorTargetManager.IsFriendly(Owner, curTarget))
                    {
                        skillTarget = curTarget;
                        return(true);
                    }
                }
                break;

                case ENTargetType.enSelf:
                {
                    if (Owner == curTarget)
                    {
                        skillTarget = curTarget;
                        return(true);
                    }
                }
                break;

                case ENTargetType.enNullTarget:
                    break;

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

                default:
                    break;
                }
            }
        }
        //不可以对当前目标释放,查找距离自己最近的

        for (int i = 0; i < m_targetIDList.Count; ++i)
        {
            Actor target = ActorManager.Singleton.Lookup(m_targetIDList[i]);
            if (target == null)
            {
                continue;
            }
            if (target.IsDead)
            {
                continue;
            }
            float distance = ActorTargetManager.GetTargetDistance(Owner.MainPos, target.MainPos);
            if (distance < info.LeastAttackDistance)
            {//最小攻击距离内
                continue;
            }
            switch ((ENTargetType)info.TargetType)
            {
            case ENTargetType.enEnemy:
            {
                if (!ActorTargetManager.IsEnemy(Owner, target))
                {
                    continue;
                }
            }
            break;

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

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

            case ENTargetType.enNullTarget:
                break;

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

            default:
                break;
            }
            if (m_firstTargetType != ActorType.enNone)
            {     //优先选择目标条件成立
                if (target.Type == m_firstTargetType)
                { //是优先选择的目标类型
                    if (skillTarget == null)
                    {
                        skillTarget     = target;
                        closestDistance = distance;
                    }
                    else
                    {
                        if (skillTarget.Type == m_firstTargetType)
                        {//已有优先目标,进行比较,取近的
                            if (distance < closestDistance)
                            {
                                skillTarget     = target;
                                closestDistance = distance;
                            }
                        }
                        else
                        {
                            skillTarget     = target;
                            closestDistance = distance;
                        }
                    }
                }
                else
                {
                    if (skillTarget == null)
                    {
                        skillTarget     = target;
                        closestDistance = distance;
                    }
                    else
                    {
                        if (skillTarget.Type != m_firstTargetType)
                        {
                            if (distance < closestDistance)
                            {
                                skillTarget     = target;
                                closestDistance = distance;
                            }
                        }
                    }
                }
            }
            else
            {
                if (distance < info.AttackDistance)
                {
                    skillTarget = target;
                    break;
                }
                else
                {
                    if (distance < closestDistance)
                    {
                        skillTarget     = target;
                        closestDistance = distance;
                    }
                }
            }
        }
        return(skillTarget != null);
    }
예제 #17
0
    void OnTriggerEnter(Collider other)
    {
        if (!ActorTargetManager.IsTrigger(other))
        {
            return;
        }
        try
        {
            if (m_info.m_isNeedRemove)
            {
                return;
            }
            Transform targetObj = other.transform;
            while (null != targetObj && targetObj.name != "body")
            {
                targetObj = targetObj.parent;
            }
            if (null == targetObj)
            {
                return;
            }
            ActorProp actorProp = targetObj.parent.GetComponent <ActorProp>();
            if (null == actorProp)
            {
                Debug.LogWarning("trigger return, actorProp get failed");
                return;
            }
            Actor target = actorProp.ActorLogicObj;
            if (target == null || target.IsDead)
            {
                return;
            }
            if (m_info.m_itemInfo.IsOnlyForChosenTarget)
            {     //只对选中目标生效
                if (target != m_info.m_dstActor)
                { //不是选中目标
                    return;
                }
            }
            if (m_info.m_bouncyTargetIDList != null)
            {     //反弹中
                if (target != m_info.m_dstActor)
                { //不是选中目标
                    return;
                }
            }
            SkillResultInfo info = GameTable.SkillResultTableAsset.Lookup(m_info.m_itemInfo.Item_ResultID);
            if (info == null)
            {
                //Debug.LogWarning("trigger return, SkillResultInfo is null, result id is " + m_info.m_itemInfo.Item_ResultID);
                return;
            }
            switch ((ENResultTargetType)info.ResultTargetType)
            {
            case ENResultTargetType.enEnemySingle:
            case ENResultTargetType.enEnemyAll:
            {        //作用于enemy
                if (!ActorTargetManager.IsEnemy(m_info.m_actorCamp, m_info.m_actorType, target))
                {
                    return;
                }
            }
            break;

            case ENResultTargetType.enFriendlySingle:
            case ENResultTargetType.enFriendlyAll:
            {        //作用于friendly
                if (!ActorTargetManager.IsFriendly(m_info.m_actorCamp, m_info.m_actorType, target))
                {
                    return;
                }
            }
            break;

            case ENResultTargetType.enEveryone:
                break;

            case ENResultTargetType.enSelf:
                if (m_info.m_actorType != target.Type)
                {
                    return;
                }
                break;

            case ENResultTargetType.enFriendlyAllAndSelf:
            case ENResultTargetType.enFriendlySingleAndSelf:
            {
                if (!ActorTargetManager.IsFriendly(m_info.m_actorCamp, m_info.m_actorType, target) && m_info.m_actorType != target.Type)
                {
                    return;
                }
            }
            break;

            default:
                return;
            }
            if (m_targetIDList.Contains(target.ID))
            {
                if (!m_info.m_itemInfo.IsMultiResult)
                {//不对目标多次生效
                    return;
                }
            }
            else
            {
                m_targetIDList.Add(target.ID);
            }

            GlobalEnvironment.Singleton.IsInCallbackOrTrigger = true;

            IResult r = BattleFactory.Singleton.CreateResult(ENResult.Skill, m_info.m_srcActor.ID, target.ID,
                                                             m_info.m_itemInfo.Item_ResultID, m_info.m_skillID);
            if (r != null)
            {
                target.SetBlastPos(m_info.m_itemObj.transform.position, m_info.m_itemObj.transform.forward);
                r.ResultExpr(null);
                BattleFactory.Singleton.GetBattleContext().CreateResultControl().DispatchResult(r);
            }
            if (m_info.m_itemInfo.IsRemoveAfterResult)
            {
                m_info.m_isNeedRemove = true;
            }

            //播放击中声音
            if (!string.IsNullOrEmpty(info.SoundList))
            {
                string[] param = info.SoundList.Split(new char[1] {
                    ','
                });
                string sound = param[0];
                if (!string.IsNullOrEmpty(sound))
                {
#if UNITY_IPHONE || UNITY_ANDRIOD
#else
                    AudioClip aClip = PoolManager.Singleton.LoadSound(sound);
                    if (aClip != null)
                    {
                        AudioSource.PlayClipAtPoint(aClip, gameObject.transform.position);
                    }
#endif
                }
                else
                {
                    Debug.LogWarning("sound string is null");
                }
            }
            RemoteAttackManager.Singleton.StartBouncy(m_info, target.MainPos);
        }
        catch (Exception e)
        {
            Debug.LogError("Error On OnTriggerEnter" + e.Message + ",,,,Stack:" + e.StackTrace.ToString());
        }
        GlobalEnvironment.Singleton.IsInCallbackOrTrigger = false;
    }
예제 #18
0
    public bool CreateSkillResult()
    {
        SkillResultInfo info = GameTable.SkillResultTableAsset.Lookup(SkillResultID);

        if (info == null)
        {
            Debug.LogError("SkillResultID is null, SkillResultID:" + SkillResultID + ",skillID:" + m_skillID + ",index:" + m_skillResultIDIndex);
            return(false);
        }

        CurrentActor.SelfAI.GetRangeTargetList(ENTargetType.enNone, info.InstantRange);
        List <int> resultActorIDList = new List <int>();
        float      minDistance       = float.MaxValue;
        int        tempActorID       = 0;

        foreach (var targetID in CurrentActor.SelfAI.m_targetIDList)
        {
            Actor target = ActorManager.Singleton.Lookup(targetID);
            if (target == null || target.IsDead)
            {
                continue;
            }
            switch ((ENResultTargetType)info.ResultTargetType)
            {
            case ENResultTargetType.enEnemySingle:
            {        //作用于单个enemy
                if (m_skillTarget != null && ActorTargetManager.IsEnemy(CurrentActor, m_skillTarget))
                {    //有技能目标,技能目标是enemy
                    if (m_skillTarget == target)
                    {
                        tempActorID = m_skillTarget.ID;
                    }
                }
                else
                {
                    if (ActorTargetManager.IsEnemy(CurrentActor, target))
                    {
                        Vector3 temp = target.RealPos - CurrentActor.MainPos;
                        temp.y = 0;
                        if (temp.magnitude < minDistance)
                        {
                            minDistance = temp.magnitude;
                            tempActorID = target.ID;
                        }
                    }
                }
            }
            break;

            case ENResultTargetType.enEnemyAll:
            {        //作用于所有enemy
                if (ActorTargetManager.IsEnemy(CurrentActor, target))
                {
                    resultActorIDList.Add(target.ID);
                }
            }
            break;

            case ENResultTargetType.enFriendlySingle:
            {        //作用于单个friendly
                if (m_skillTarget != null && ActorTargetManager.IsFriendly(CurrentActor, m_skillTarget))
                {    //有技能目标,技能目标是friend
                    if (m_skillTarget == target)
                    {
                        tempActorID = m_skillTarget.ID;
                    }
                }
                else
                {
                    if (ActorTargetManager.IsFriendly(CurrentActor, target))
                    {
                        Vector3 temp = target.RealPos - CurrentActor.MainPos;
                        temp.y = 0;
                        if (temp.magnitude < minDistance)
                        {
                            minDistance = temp.magnitude;
                            tempActorID = target.ID;
                        }
                    }
                }
            }
            break;

            case ENResultTargetType.enFriendlyAll:
            {        //作用于所有friendly
                if (ActorTargetManager.IsFriendly(CurrentActor, target))
                {
                    resultActorIDList.Add(target.ID);
                }
            }
            break;

            case ENResultTargetType.enEveryone:
            {
                resultActorIDList.Add(target.ID);
            }
            break;

            case ENResultTargetType.enSelf:
            {
                if (CurrentActor == target)
                {
                    tempActorID = target.ID;
                }
            }
            break;

            case ENResultTargetType.enFriendlyAllAndSelf:
            {
                if (ActorTargetManager.IsFriendly(CurrentActor, target) || CurrentActor == target)
                {
                    resultActorIDList.Add(target.ID);
                }
            }
            break;

            case ENResultTargetType.enFriendlySingleAndSelf:
            {
                if (m_skillTarget != null &&
                    (ActorTargetManager.IsFriendly(CurrentActor, m_skillTarget) || m_skillTarget == CurrentActor))
                {
                    tempActorID = m_skillTarget.ID;
                }
                else
                {        //自己
                    if (CurrentActor == target)
                    {
                        tempActorID = target.ID;
                    }
                }
            }
            break;

            default:
                break;
            }
        }
        if (tempActorID != 0)
        {
            resultActorIDList.Add(tempActorID);
        }
        //if (ClientNet.Singleton.IsConnected)
        //{
        //}
        //else
        {
            foreach (var targetID in resultActorIDList)
            {
                IResult r = BattleFactory.Singleton.CreateResult(ENResult.Skill, CurrentActor.ID, targetID,
                                                                 SkillResultID, m_skillInfo != null ? m_skillInfo.ID : 0);
                if (r != null)
                {
                    Actor targetActor = ActorManager.Singleton.Lookup(targetID);
                    targetActor.SetBlastPos(CurrentActor.RealPos, CurrentActor.GetBodyObject().transform.forward);
                    r.ResultExpr(null);
                    BattleFactory.Singleton.GetBattleContext().CreateResultControl().DispatchResult(r);
                }
            }
        }
        return(true);
    }
예제 #19
0
    public void OnTriggerEnter(GameObject selfObj, Collider other)
    {
        if (other.isTrigger)
        {
            //Debug.LogWarning("OnTriggerEnter other.isTrigger is true");
            return;
        }
        Actor     target    = null;
        Transform targetObj = other.transform;

        while (null != targetObj && targetObj.name != "body")
        {
            targetObj = targetObj.parent;
        }
        if (null == targetObj)
        {
            //Debug.LogWarning("OnTriggerEnter target obj is null");
            return;
        }
        ActorProp prop = targetObj.parent.GetComponent <ActorProp>();

        target = prop.ActorLogicObj;
        if (null == target)
        {
            Debug.LogWarning("OnTriggerEnter target is null");
            return;
        }
        if (target.IsDead)
        {
            //Debug.LogWarning("OnTriggerEnter target is deaded");
            return;
        }
        //Debug.LogWarning("OnTriggerEnter target id is " +target.ID.ToString());
        SkillResultInfo info = GameTable.SkillResultTableAsset.Lookup(SkillResultID);

        if (info == null)
        {
            Debug.LogError("SkillResultID is null, actor ID:" + CurrentActor.ID + "SkillResultID:," + SkillResultID + ",skillID:" + m_skillID + ",index:" + m_skillResultIDIndex);
            DebugLog.Singleton.OnShowLog("SkillResultID is null, actor ID:" + CurrentActor.ID + "SkillResultID:" + SkillResultID + ",skillID:" + m_skillID + ",index:" + m_skillResultIDIndex);
            return;
        }
        ActorProp selfProp = selfObj.transform.parent.GetComponent <ActorProp>();
        Actor     self     = selfProp.ActorLogicObj;

        switch ((ENResultTargetType)info.ResultTargetType)
        {
        case ENResultTargetType.enEnemySingle:
        {        //只作用于第一个enemy
            if (m_skillTarget != null)
            {
                if (m_skillTarget != target)
                {
                    return;
                }
            }
            else
            {
                if (m_firstTarget != null)
                {
                    return;
                }
                if (!ActorTargetManager.IsEnemy(self, target))
                {
                    return;
                }
                m_firstTarget = target;
            }
        }
        break;

        case ENResultTargetType.enEnemyAll:
        {        //作用于所有enemy
            if (!ActorTargetManager.IsEnemy(self, target))
            {
                return;
            }
        }
        break;

        case ENResultTargetType.enFriendlySingle:
        {        //只作用于第一个friendly
            if (m_skillTarget != null)
            {
                if (m_skillTarget != target)
                {
                    return;
                }
            }
            else
            {
                if (m_firstTarget != null)
                {
                    return;
                }
                if (!ActorTargetManager.IsFriendly(self, target))
                {
                    return;
                }
                m_firstTarget = target;
            }
        }
        break;

        case ENResultTargetType.enFriendlyAll:
        {        //作用于所有friendly
            if (!ActorTargetManager.IsFriendly(self, target))
            {
                return;
            }
        }
        break;

        case ENResultTargetType.enEveryone:
            break;

        case ENResultTargetType.enSelf:
        {
            if (self != target)
            {
                return;
            }
        }
        break;

        case ENResultTargetType.enFriendlyAllAndSelf:
        {
            if (!ActorTargetManager.IsFriendly(self, target) && self != target)
            {
                return;
            }
        }
        break;

        case ENResultTargetType.enFriendlySingleAndSelf:
        {
            if (!ActorTargetManager.IsFriendly(self, target) && self != target)
            {
                return;
            }
            if (m_firstTarget != null)
            {
                return;
            }
            m_firstTarget = target;
        }
        break;

        default:
            return;
        }

        if (ClientNet.Singleton.IsConnected)
        {
            IResult r = BattleFactory.Singleton.CreateResult(ENResult.Skill, self.ID, target.ID,
                                                             SkillResultID, m_skillInfo != null ? m_skillInfo.ID : 0);
            if (r != null)
            {
                target.SetBlastPos(self.RealPos, self.GetBodyObject().transform.forward);
                r.ResultExpr(null);
                BattleFactory.Singleton.GetBattleContext().CreateResultControl().DispatchResult(r);
            }
        }
        else
        {
            IResult r = BattleFactory.Singleton.CreateResult(ENResult.Skill, self.ID, target.ID,
                                                             SkillResultID, m_skillInfo != null ? m_skillInfo.ID : 0);
            if (r != null)
            {
                target.SetBlastPos(self.RealPos, self.GetBodyObject().transform.forward);
                r.ResultExpr(null);
                BattleFactory.Singleton.GetBattleContext().CreateResultControl().DispatchResult(r);
            }
        }
        if (!string.IsNullOrEmpty(info.SoundList))
        {//播放击中声音
            string[] param = info.SoundList.Split(new char[1] {
                ','
            });
            string sound = param[0];
            if (!string.IsNullOrEmpty(sound))
            {
#if UNITY_IPHONE || UNITY_ANDRIOD
#else
                AudioClip aClip = PoolManager.Singleton.LoadSound(sound);
                if (aClip != null)
                {
                    AudioSource.PlayClipAtPoint(aClip, selfObj.transform.position);
                }
#endif
            }
            else
            {
                Debug.LogWarning("sound string is null");
            }
        }
        m_isTriggerSucced = true;
        m_isMissing       = false;
    }
예제 #20
0
    void CheckTarget(Actor target)
    {
        if (SkillTargetIDList.Contains(target.ID))
        {
            return;
        }
        if (target.IsDead)
        {
            return;
        }
        float d = ActorTargetManager.GetTargetDistance(CurrentActor.RealPos, target.RealPos);

        if (m_skillInfo.AttackDistance >= d)
        {
            switch ((ENTargetType)m_skillInfo.TargetType)
            {
            case ENTargetType.enEnemy:
            {
                if (!ActorTargetManager.IsEnemy(CurrentActor, target))
                {
                    return;
                }
            }
            break;

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

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

            case ENTargetType.enNullTarget:
                break;

            case ENTargetType.enInteraction:
            {
                if (!ActorTargetManager.IsInteractionally(CurrentActor, target))
                {
                    return;
                }
            }
            break;

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

            default:
                return;
            }
            if (d < m_closestDistance)
            {
                m_closestTargetID = target.ID;
            }
        }
    }
예제 #21
0
    void CheckTarget(Actor target)
    {
        if (target.Type == ActorType.enNPC)
        {
            NPC npc = target as NPC;
            if (npc.GetNpcType() == ENNpcType.enBlockNPC ||
                npc.GetNpcType() == ENNpcType.enFunctionNPC)
            {
                return;
            }
        }
        if (target.IsDead)
        {
            return;
        }
        switch (m_searchTargetType)
        {
        case ENTargetType.enEnemy:
        {
            if (!ActorTargetManager.IsEnemy(m_selfCamp, m_selfActorType, target))
            {
                return;
            }
        }
        break;

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

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

        case ENTargetType.enNullTarget:
            break;

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

        default:
            break;
        }
        Vector3 distance = target.RealPos - m_selfPos;

        distance.y = 0;
        if (m_searchTargetRange >= distance.magnitude)
        {
            m_targetIDList.Add(target.ID);
        }
    }
예제 #22
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;
            }
        }
    }
예제 #23
0
    void CheckTarget(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 (m_searchTargetType)
        {
        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 range = 0;

        if (Owner.Type == ActorType.enMain || Owner.Type == ActorType.enSwitch || Owner.Type == ActorType.enFollow)
        {
            Player self = Owner as Player;
            range = self.CurrentTableInfo.AttackRange;
            if (range <= 0)
            {
                return;
            }
            range = m_searchTargetRange != 0 ? m_searchTargetRange : range;
        }
        else if (Owner.Type == ActorType.enNPC)
        {
            NPC npc = Owner as NPC;
            if (npc.AttackRange <= 0)
            {
                return;
            }
            range = m_searchTargetRange != 0 ? m_searchTargetRange : npc.AttackRange;
        }
        float distance = ActorTargetManager.GetTargetDistance(Owner.RealPos, target.RealPos);

        if (range >= distance)
        {
            if (distance < m_minDistance)
            {
                m_minDistance = distance;
                m_minActor    = target;
            }
            m_targetIDList.Add(target.ID);
        }
    }
예제 #24
0
    //通过skillResultID产生技能result
    public bool CreateSkillResult(int sourceID, int skillResultID, int targetID = 0, int skillID = 0, float[] param = null)
    {
        m_self = ActorManager.Singleton.Lookup(sourceID);
        if (m_self == null)
        {
            Debug.LogWarning("self is null, id is " + sourceID);
            return(false);
        }
        Actor           target = ActorManager.Singleton.Lookup(targetID);
        SkillResultInfo info   = GameTable.SkillResultTableAsset.Lookup(skillResultID);

        if (info == null)
        {
            if (skillResultID != 0)
            {
                Debug.LogWarning("result id is error, id is " + skillResultID);
            }
            return(false);
        }
        float range = float.MinValue;

        if (info.InstantRange != 0)
        {
            range = info.InstantRange;
        }
        //优先判断当前目标和自己
        switch ((ENResultTargetType)info.ResultTargetType)
        {
        case ENResultTargetType.enEnemySingle:
        {
            if (target != null && !target.IsDead)
            {
                if (ActorTargetManager.IsEnemy(m_self, target))
                {
                    float d = ActorTargetManager.GetTargetDistance(m_self.RealPos, target.RealPos);
                    if (d <= range)
                    {        //给当前技能目标加skillresult
                        CreateResult_Skill(info.ID, target, skillID, param);
                        return(true);
                    }
                }
            }
        }
        break;

        case ENResultTargetType.enFriendlySingle:
        {
            if (target != null && !target.IsDead)
            {
                if (ActorTargetManager.IsFriendly(m_self, target))
                {
                    float d = ActorTargetManager.GetTargetDistance(m_self.RealPos, target.RealPos);
                    if (d <= range)
                    {        //给当前技能目标加skillresult
                        CreateResult_Skill(info.ID, target, skillID, param);
                        return(true);
                    }
                }
            }
        }
        break;

        case ENResultTargetType.enSelf:
        case ENResultTargetType.enFriendlySingleAndSelf:
        {        //给自己加skillresult
            CreateResult_Skill(info.ID, m_self, skillID, param);
            return(true);
        }
            //break;
        }
        ActorManager.Singleton.ForEach_result(CheckTarget, new float[4] {
            info.ID, range, info.ResultTargetType, skillID
        });
        return(true);
    }