Esempio n. 1
0
        public static void ClearMark(bool clearAnyway = false, PK_TYPE pkState = PK_TYPE.PK_PEACE, Func <BaseRole, bool> filterHandle = null)
        {
            int i = 0;
            Dictionary <uint, MonsterRole>    mapMonster     = MonsterMgr._inst.m_mapMonster;
            Dictionary <uint, ProfessionRole> mapOtherPlayer = OtherPlayerMgr._inst.m_mapOtherPlayer;

            switch (pkState)
            {
            case PK_TYPE.PK_PKALL:
            {
                List <uint> list = new List <uint>(mapOtherPlayer.Keys);
                while (i < list.Count)
                {
                    bool flag = i == list.Count - 1 | clearAnyway;
                    if (flag)
                    {
                        for (int j = 0; j < list.Count; j++)
                        {
                            mapOtherPlayer[list[j]].m_isMarked = false;
                        }
                        break;
                    }
                    bool flag2 = !mapOtherPlayer[list[i]].m_isMarked && (filterHandle == null || filterHandle(mapOtherPlayer[list[i]]));
                    if (flag2)
                    {
                        break;
                    }
                    i++;
                }
                break;
            }

            case PK_TYPE.PK_TEAM:
            {
                List <uint> list2 = new List <uint>(mapOtherPlayer.Keys);
                while (i < list2.Count)
                {
                    bool flag3 = i == list2.Count - 1 | clearAnyway;
                    if (flag3)
                    {
                        for (int k = 0; k < list2.Count; k++)
                        {
                            mapOtherPlayer[list2[k]].m_isMarked = false;
                        }
                        break;
                    }
                    bool flag4 = !mapOtherPlayer[list2[i]].m_isMarked && (filterHandle == null || filterHandle(mapOtherPlayer[list2[i]]));
                    if (flag4)
                    {
                        break;
                    }
                    i++;
                }
                break;
            }
            }
            i = 0;
            List <uint> list3 = new List <uint>(mapMonster.Keys);

            while (i < list3.Count)
            {
                bool flag5 = i == list3.Count - 1 | clearAnyway;
                if (flag5)
                {
                    for (int l = 0; l < list3.Count; l++)
                    {
                        mapMonster[list3[l]].m_isMarked = false;
                    }
                    break;
                }
                bool flag6 = !mapMonster[list3[i]].m_isMarked && (filterHandle == null || filterHandle(mapMonster[list3[i]]));
                if (flag6)
                {
                    break;
                }
                i++;
            }
        }
Esempio n. 2
0
    /// <summary>
    /// 检索离指定位置最近的敌对玩家
    /// </summary>
    /// <param name="pos">指定位置</param>
    /// <param name="isredname">是否仅针对红名角色</param>
    /// <param name="selector">过滤器:跳过对符合过滤条件玩家的检测</param>
    /// <param name="useMark">是否禁用重复检索,建议与selector配合使用</param>
    /// <param name="pkState">指定PK状态</param>
    /// <returns></returns>
    public BaseRole FindNearestEnemyOne(Vector3 pos, bool isredname = false, Func <ProfessionRole, bool> selector = null, bool useMark = false, PK_TYPE pkState = PK_TYPE.PK_PEACE)
    {
        float    dis      = 9999999f;
        BaseRole near_one = null;
        Func <BaseRole, bool> filterHandle;

        switch (pkState)
        {
        default:
        case PK_TYPE.PK_PKALL:
        case PK_TYPE.PK_PEACE:
            filterHandle = (p) => !p.isDead && (p.m_curPhy.position - pos).magnitude < (SelfRole.fsm.Autofighting ? StateInit.Instance.Distance : SelfRole._inst.m_LockDis);
            break;

        case PK_TYPE.PK_TEAM:
            filterHandle = (p) => !p.isDead && (p.m_curPhy.position - pos).magnitude < (SelfRole.fsm.Autofighting ? StateInit.Instance.Distance : SelfRole._inst.m_LockDis) &&
                           ((!TeamProxy.getInstance().MyTeamData?.itemTeamDataList?.Exists((m) => m.cid == p.m_unCID)) ?? true);
            break;

        case PK_TYPE.Pk_SPOET:
            filterHandle = (p) => !p.isDead && (p.m_curPhy.position - pos).magnitude < (SelfRole.fsm.Autofighting ? StateInit.Instance.Distance : SelfRole._inst.m_LockDis) &&
                           ((PlayerModel.getInstance().lvlsideid != p.lvlsideid));
            break;
        }
        bool remarkDone = false;

SEARCH_AGAIN:
        foreach (ProfessionRole p in m_mapOtherPlayer.Values)
        {
            if (OtherPlayerMgr._inst.m_mapOtherPlayer[p.m_unIID].zhuan >= 1)
            {
                if (p.isDead || p.invisible)
                {
                    continue;
                }
                if (p.m_isMarked)
                {
                    continue;
                }
                //if (p.m_eFight_Side != FIGHT_A3_SIDE.FA3S_ENEMYOTHER) continue;
                if (isredname)
                {
                    if (p.rednm <= 0)
                    {
                        continue;
                    }
                }
                if (selector?.Invoke(p) ?? false)
                {
                    continue;
                }
                //军团模式(队友和同军团忽略)
                if (pkState == PK_TYPE.PK_TEAM)
                {
                    if ((TeamProxy.getInstance().MyTeamData?.itemTeamDataList?.Exists((m) => m.cid == p.m_unCID)) ?? true)
                    {
                        continue;
                    }
                    if (PlayerModel.getInstance().clanid != 0 && PlayerModel.getInstance().clanid == p.m_unLegionID)
                    {
                        continue;
                    }
                }
                else if (pkState == PK_TYPE.PK_PEACE)
                {
                    if (!p.havefanjibuff)
                    {
                        continue;
                    }
                }
                else if (pkState == PK_TYPE.Pk_SPOET)
                {
                    if (p.lvlsideid == PlayerModel.getInstance().lvlsideid)
                    {
                        continue;
                    }
                }
                Vector3 off_pos = p.m_curModel.position - pos;
                float   off_dis = off_pos.magnitude;
                if (off_dis < (SelfRole.fsm.Autofighting ? StateInit.Instance.Distance : SelfRole._inst.m_LockDis) && off_dis < dis)
                {
                    dis      = off_dis;
                    near_one = p;
                }
            }
        }
        if (near_one == null)
        {
            //near_one = MonsterMgr._inst.FindNearestSummon(pos);
            if (near_one == null)
            {
                RoleMgr.ClearMark(!useMark, pkState, filterHandle: filterHandle);
                if (!remarkDone)
                {
                    remarkDone = true;
                    goto SEARCH_AGAIN;
                }
            }
            else if (useMark)
            {
                near_one.m_isMarked = true;
            }
        }
        if (near_one != null && useMark)
        {
            near_one.m_isMarked = true;
        }

        return(near_one);
    }
Esempio n. 3
0
        public static void ClearMark(bool clearAnyway = false, PK_TYPE pkState = PK_TYPE.PK_PEACE, Func <BaseRole, bool> filterHandle = null)
        {
            int i         = 0;
            var monDic    = MonsterMgr._inst.m_mapMonster;
            var playerDic = OtherPlayerMgr._inst.m_mapOtherPlayer;

            switch (pkState)
            {
            default: goto case PK_TYPE.PK_PEACE;

            case PK_TYPE.PK_PKALL:
                for (List <uint> idx = new List <uint>(playerDic.Keys); i < idx.Count; i++)
                {
                    if (i == idx.Count - 1 || clearAnyway)
                    {
                        for (int j = 0; j < idx.Count; j++)
                        {
                            playerDic[idx[j]].m_isMarked = false;
                        }
                        break;
                    }
                    if (!playerDic[idx[i]].m_isMarked && (filterHandle?.Invoke(playerDic[idx[i]]) ?? true))
                    {
                        break;
                    }
                }
                goto case PK_TYPE.PK_PEACE;

            case PK_TYPE.PK_TEAM:
                for (List <uint> idx = new List <uint>(playerDic.Keys); i < idx.Count; i++)
                {
                    if (i == idx.Count - 1 || clearAnyway)
                    {
                        for (int j = 0; j < idx.Count; j++)
                        {
                            playerDic[idx[j]].m_isMarked = false;
                        }
                        break;
                    }
                    if (!playerDic[idx[i]].m_isMarked && (filterHandle?.Invoke(playerDic[idx[i]]) ?? true))
                    {
                        break;
                    }
                }
                goto case PK_TYPE.PK_PEACE;

            case PK_TYPE.PK_PEACE:
                i = 0;
                for (List <uint> idx = new List <uint>(monDic.Keys); i < idx.Count; i++)
                {
                    if (i == idx.Count - 1 || clearAnyway)
                    {
                        for (int j = 0; j < idx.Count; j++)
                        {
                            monDic[idx[j]].m_isMarked = false;
                        }
                        break;
                    }
                    if (!monDic[idx[i]].m_isMarked && (filterHandle?.Invoke(monDic[idx[i]]) ?? true))
                    {
                        break;
                    }
                }
                break;

            case PK_TYPE.Pk_SPOET:
                for (List <uint> idx = new List <uint>(playerDic.Keys); i < idx.Count; i++)
                {
                    for (int j = 0; j < idx.Count; j++)
                    {
                        playerDic[idx[j]].m_isMarked = false;
                    }
                    break;
                }
                break;
            }
        }
Esempio n. 4
0
    public BaseRole FindNearestEnemyOne(Vector3 pos, bool isredname = false, Func <ProfessionRole, bool> selector = null, bool useMark = false, PK_TYPE pkState = PK_TYPE.PK_PEACE)
    {
        float    num      = 9999999f;
        BaseRole baseRole = null;

        switch (pkState)
        {
        case PK_TYPE.PK_PEACE:
        case PK_TYPE.PK_PKALL:
        {
IL_2F:
            Func <BaseRole, bool> filterHandle = (BaseRole p) => !p.isDead && (p.m_curPhy.position - pos).magnitude < (SelfRole.fsm.Autofighting ? StateInit.Instance.Distance : SelfRole._inst.m_LockDis);
            goto IL_4D;
        }

        case PK_TYPE.PK_TEAM:
        {
            Func <BaseRole, bool> filterHandle = delegate(BaseRole p)
            {
                bool arg_C1_0;
                if (!p.isDead && (p.m_curPhy.position - pos).magnitude < (SelfRole.fsm.Autofighting ? StateInit.Instance.Distance : SelfRole._inst.m_LockDis))
                {
                    ItemTeamMemberData expr_6E = BaseProxy <TeamProxy> .getInstance().MyTeamData;

                    bool?arg_AA_0;
                    if (expr_6E == null)
                    {
                        arg_AA_0 = null;
                    }
                    else
                    {
                        List <ItemTeamData> expr_82 = expr_6E.itemTeamDataList;
                        arg_AA_0 = ((expr_82 != null) ? new bool?(!expr_82.Exists((ItemTeamData m) => m.cid == p.m_unCID)) : null);
                    }
                    arg_C1_0 = (arg_AA_0 ?? true);
                }
                else
                {
                    arg_C1_0 = false;
                }
                return(arg_C1_0);
            };
            goto IL_4D;
        }
        }
        goto IL_2F;
IL_4D:
        bool flag = false;

        while (true)
        {
            foreach (ProfessionRole current in this.m_mapOtherPlayer.Values)
            {
                bool flag2 = OtherPlayerMgr._inst.m_mapOtherPlayer[current.m_unIID].zhuan >= 1;
                if (flag2)
                {
                    bool flag3 = current.isDead || current.invisible;
                    if (!flag3)
                    {
                        bool isMarked = current.m_isMarked;
                        if (!isMarked)
                        {
                            if (isredname)
                            {
                                bool flag4 = current.rednm <= 0;
                                if (flag4)
                                {
                                    continue;
                                }
                            }
                            bool flag5 = selector != null && selector(current);
                            if (!flag5)
                            {
                                float magnitude = (current.m_curModel.position - pos).magnitude;
                                bool  flag6     = magnitude < (SelfRole.fsm.Autofighting ? StateInit.Instance.Distance : SelfRole._inst.m_LockDis) && magnitude < num;
                                if (flag6)
                                {
                                    num      = magnitude;
                                    baseRole = current;
                                }
                            }
                        }
                    }
                }
            }
            bool flag7 = baseRole == null;
            if (!flag7)
            {
                break;
            }
            baseRole = MonsterMgr._inst.FindNearestSummon(pos);
            bool flag8 = baseRole == null;
            if (!flag8)
            {
                goto IL_1C9;
            }
            Func <BaseRole, bool> filterHandle;
            RoleMgr.ClearMark(!useMark, pkState, filterHandle);
            bool flag9 = !flag;
            if (!flag9)
            {
                break;
            }
            flag = true;
        }
        goto IL_1D9;
IL_1C9:
        if (useMark)
        {
            baseRole.m_isMarked = true;
        }
IL_1D9:
        bool flag10 = baseRole != null & useMark;

        if (flag10)
        {
            baseRole.m_isMarked = true;
        }
        return(baseRole);
    }
Esempio n. 5
0
    public MonsterRole FindNearestMonster(Vector3 pos, Func <MonsterRole, bool> handle = null, bool useMark = false, PK_TYPE pkState = PK_TYPE.PK_PEACE, bool onTask = false)
    {
        float       num         = 9999999f;
        MonsterRole monsterRole = null;

        RoleMgr.ClearMark(!useMark, pkState, (BaseRole m) => (m.m_curPhy.position - pos).magnitude < (SelfRole.fsm.Autofighting ? StateInit.Instance.Distance : SelfRole._inst.m_LockDis));
        foreach (MonsterRole current in this.m_mapMonster.Values)
        {
            bool flag = current.isDead || current is CollectRole || (current is MS0000 && (long)((MS0000)current).owner_cid == (long)((ulong)ModelBase <PlayerModel> .getInstance().cid)) || (current is MDC000 && ((MDC000)current).escort_name == ModelBase <A3_LegionModel> .getInstance().myLegion.clname);
            if (!flag)
            {
                bool flag2 = current is MDC000 && (int)((float)((MDC000)current).curhp / (float)((MDC000)current).maxHp * 100f) <= 20;
                if (!flag2)
                {
                    TaskMonId expr_104 = this.taskMonId;
                    bool      flag3    = expr_104 != null && expr_104.applied && this.taskMonId.value != current.monsterid;
                    if (!flag3)
                    {
                        bool flag4 = handle != null && handle(current);
                        if (!flag4)
                        {
                            bool flag5 = onTask && ModelBase <PlayerModel> .getInstance().task_monsterIdOnAttack.ContainsKey(ModelBase <A3_TaskModel> .getInstance().main_task_id) && current.monsterid != ModelBase <PlayerModel> .getInstance().task_monsterIdOnAttack[ModelBase <A3_TaskModel> .getInstance().main_task_id];

                            if (!flag5)
                            {
                                bool flag6 = BaseProxy <TeamProxy> .getInstance().MyTeamData != null;

                                if (flag6)
                                {
                                    bool mwlr_on = ModelBase <A3_ActiveModel> .getInstance().mwlr_on;

                                    if (mwlr_on)
                                    {
                                        bool flag7 = ModelBase <A3_ActiveModel> .getInstance().mwlr_target_monId != current.monsterid;

                                        if (flag7)
                                        {
                                            continue;
                                        }
                                    }
                                    bool flag8 = current.ownerName != null && !BaseProxy <TeamProxy> .getInstance().MyTeamData.IsInMyTeam(current.ownerName);

                                    if (flag8)
                                    {
                                        continue;
                                    }
                                }
                                else
                                {
                                    bool flag9 = current.ownerName != null && current.ownerName != ModelBase <PlayerModel> .getInstance().name;

                                    if (flag9)
                                    {
                                        continue;
                                    }
                                }
                                bool flag10 = SelfRole.fsm.Autofighting && (current.m_curPhy.position - StateInit.Instance.Origin).magnitude > StateInit.Instance.Distance;
                                if (!flag10)
                                {
                                    bool flag11 = pkState != PK_TYPE.PK_PKALL && current is MS0000 && ((MS0000)current).owner_cid != 0;
                                    if (!flag11)
                                    {
                                        float magnitude = (current.m_curPhy.position - pos).magnitude;
                                        bool  flag12    = magnitude < (SelfRole.fsm.Autofighting ? Mathf.Min(SelfRole._inst.m_LockDis, StateInit.Instance.Distance) : SelfRole._inst.m_LockDis) && magnitude < num;
                                        if (flag12)
                                        {
                                            num         = magnitude;
                                            monsterRole = current;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        bool flag13 = monsterRole != null & useMark;

        if (flag13)
        {
            monsterRole.m_isMarked = true;
        }
        return(monsterRole);
    }
Esempio n. 6
0
    public MonsterRole FindNearestMonster(Vector3 pos, Func <MonsterRole, bool> handle = null, bool useMark = false, PK_TYPE pkState = PK_TYPE.PK_PEACE, bool onTask = false)
    {
        float dis = 9999999f;

        MonsterRole role = null, t_role = null;
        float       t_dis;

        RoleMgr.ClearMark(!useMark, pkState,
                          filterHandle: (m) => (m.m_curPhy.position - pos).magnitude < (SelfRole.fsm.Autofighting ? StateInit.Instance.Distance : SelfRole._inst.m_LockDis));
        foreach (MonsterRole m in m_mapMonster.Values)
        {
            if (m.isDead || m is CollectRole || (m is MS0000 && ((MS0000)m).owner_cid == PlayerModel.getInstance().cid))
            {
                continue;
            }
            if (m.issummon)
            {
                continue;
            }
            if (SelfRole.fsm.Autofighting && (m.m_curPhy.position - StateInit.Instance.Origin).magnitude > StateInit.Instance.Distance)
            {
                continue;
            }
            else
            {
                float _off_dis = (m.m_curPhy.position - pos).magnitude;
                if (_off_dis < (SelfRole.fsm.Autofighting ? Mathf.Min(SelfRole._inst.m_LockDis, StateInit.Instance.Distance) : SelfRole._inst.m_LockDis) &&
                    _off_dis < dis)
                {
                    t_dis  = _off_dis;
                    t_role = m;
                }
            }
            if (m is MDC000 && ((MDC000)m).escort_name == A3_LegionModel.getInstance().myLegion.clname)
            {
                continue;
            }
            if (m is MDC000 && (int)(((float)((MDC000)m).curhp / (float)((MDC000)m).maxHp) * 100) <= 20)
            {
                continue;
            }
            if ((taskMonId?.applied ?? false) && taskMonId.value != m.monsterid)
            {
                continue;
            }
            if (handle?.Invoke(m) ?? false)
            {
                continue;
            }
            if (onTask &&
                PlayerModel.getInstance().task_monsterIdOnAttack.ContainsKey(A3_TaskModel.getInstance().main_task_id) &&
                m.monsterid != PlayerModel.getInstance().task_monsterIdOnAttack[A3_TaskModel.getInstance().main_task_id])
            {
                continue;
            }
            if (TeamProxy.getInstance().MyTeamData != null)
            {
                if (A3_ActiveModel.getInstance().mwlr_on)
                {
                    if (A3_ActiveModel.getInstance().mwlr_target_monId != m.monsterid)
                    {
                        continue;
                    }
                }
                if (m.ownerName != null && !TeamProxy.getInstance().MyTeamData.IsInMyTeam(m.ownerName))
                {
                    continue;
                }
            }
            else if (m.ownerName != null && m.ownerName != PlayerModel.getInstance().name)
            {
                continue;
            }
            if (pkState != PK_TYPE.PK_PKALL && m is MS0000 && ((MS0000)m).owner_cid != 0)
            {
                continue;
            }
            float off_dis = (m.m_curPhy.position - pos).magnitude;
            if (off_dis < (SelfRole.fsm.Autofighting ? Mathf.Min(SelfRole._inst.m_LockDis, StateInit.Instance.Distance) : SelfRole._inst.m_LockDis) &&
                off_dis < dis)
            {
                dis  = off_dis;
                role = m;
            }
        }
        if (role != null && useMark)
        {
            role.m_isMarked = true;
        }
        else if (role == null)
        {
            role = t_role;
        }
        return(role);
    }