示例#1
0
    public void OnTriggerEnter(Collider other)
    {
        HitData hd = other.gameObject.GetComponent <HitData>();

        if (hd == null)
        {
            return;
        }
        if (hd.m_haveHittedList.Contains(m_selfRole.m_unIID))
        {
            return;
        }
        else
        {
            hd.m_haveHittedList.Add(m_selfRole.m_unIID);
        }

        if (PlayerModel.getInstance().up_lvl >= 1)
        {
            if (CanHited(m_selfRole, hd))
            {
                //临时处理只碰一次
                if (hd.m_bOnlyHit)
                {
                    other.enabled = false;
                }

                if (hd.m_unSkillID == 3003)
                {//冰雨技能攻击到时播放dead2的特效
                    hd.HitAndStop(EnumAni.ANI_T_FXDEAD1);
                }
                else if (hd.m_unSkillID == 3006)
                {//陨石可穿过模型
                }
                else
                {
                    //停止动画
                    hd.HitAndStop();
                }

                if (hd.m_CastRole != null && hd.m_CastRole.isfake)
                {
                    m_selfRole.onHurt(hd);
                }

                //主角自己受到的伤害让服务器下发好了,自己不用去关心
                //m_selfRole.onHurt(hd);
                m_selfRole.ShowHurtFX(hd.m_nHurtFX);


                //if (hd.m_bNeedKill)
                //{
                //    GameObject.Destroy(other.gameObject);
                //}
                //播放死亡
                //GameObject.Destroy(other.gameObject);

                //显示迎战的ui
                if (!hd.m_CastRole.m_isMain && hd.m_CastRole is ProfessionRole && PlayerModel.getInstance().now_pkState == 0)//PlayerModel.getInstance().now_pkState == 0 && hd.m_CastRole is ProfessionRole && PlayerModel.getInstance().now_nameState==0
                {
                    if (!hd.m_CastRole.isDead || hd.m_CastRole != null || !m_selfRole.isDead)
                    {
                        a3_expbar.instance.ShowAgainst(hd.m_CastRole);
                    }
                }

                //我非全体模式时,打我的人是我的团员或者对友,飘字提示
                if (PlayerModel.getInstance().now_pkState != 1 && !hd.m_CastRole.m_isMain && hd.m_CastRole is ProfessionRole)
                {
                    if ((TeamProxy.getInstance().MyTeamData != null && TeamProxy.getInstance().MyTeamData.IsInMyTeam(hd.m_CastRole.roleName)) ||
                        (PlayerModel.getInstance().clanid != 0 && PlayerModel.getInstance().clanid == hd.m_CastRole.m_unLegionID))
                    {
                        flytxt.instance.fly(ContMgr.getCont("a3_pkmodel"));
                    }
                }
            }
        }
    }
示例#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);
    }
    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);
    }