예제 #1
0
    /// <summary>
    /// 查找指定位置最近的召唤兽
    /// </summary>
    /// <param name="pos"></param>
    /// <returns></returns>
    public MonsterRole FindNearestSummon(Vector3 pos)
    {
        MonsterRole role = null;
        float       dis  = float.MaxValue;

        foreach (MonsterRole m in m_mapMonster.Values)
        {
            int ownerCid = 0;
            if (m is MS0000)
            {
                ownerCid = ((MS0000)m).owner_cid;
            }
            if (m.m_isMarked)
            {
                continue;
            }
            if (ownerCid == 0)
            {
                continue;
            }
            else
            {
                if (PlayerModel.getInstance().pk_state != PK_TYPE.PK_PEACE)
                {
                    if (ownerCid == PlayerModel.getInstance().cid)
                    {
                        continue;
                    }
                    else if (PlayerModel.getInstance().pk_state == PK_TYPE.PK_TEAM)
                    {
                        if (TeamProxy.getInstance().MyTeamData != null && (TeamProxy.getInstance().MyTeamData.itemTeamDataList?.Exists((member) => member.cid == ownerCid) ?? false))
                        {
                            continue;
                        }
                        else
                        if (ownerCid == PlayerModel.getInstance().cid)
                        {
                            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;
            }
        }
        return(role);
    }
예제 #2
0
 public void RefreshVaildMonster()
 {
     if (TeamProxy.getInstance().MyTeamData != null)
     {
         foreach (MonsterRole m in m_listMonster)
         {
             if (m.ownerName != null && TeamProxy.getInstance().MyTeamData.IsInMyTeam(m.ownerName))
             {
                 m.m_curGameObj.SetActive(true);
             }
         }
     }
 }
예제 #3
0
 public void HideInvaildMonster()
 {
     foreach (MonsterRole m in m_listMonster)
     {
         if (TeamProxy.getInstance().MyTeamData == null)
         {
             if (m.ownerName != null && !m.ownerName.Equals(PlayerModel.getInstance().name))
             {
                 m.m_curGameObj.SetActive(false);
             }
         }
         if (TeamProxy.getInstance().MyTeamData != null)
         {
             if (m.ownerName != null && !TeamProxy.getInstance().MyTeamData.IsInMyTeam(m.ownerName))
             {
                 m.m_curGameObj.SetActive(false);
             }
         }
     }
 }
예제 #4
0
        private void pickup_drop()
        {
            #region if
            if (nearest == null || !nearest.gameObject)
            {
                DropItem drpitm;
                float    min = float.MaxValue;
                Dictionary <uint, DropItem> .Enumerator etor = BaseRoomItem.instance.dDropItem_own.GetEnumerator();
                //if (!etor.MoveNext())
                // goto_dropitem = false;
                //所有物品都时间到了
                if (BaseRoomItem.instance.dDropItem.Count <= 0)
                {
                    goto_dropitem = false;
                    return;
                }
                while (etor.MoveNext())
                {
                    drpitm = etor.Current.Value;
                    if (drpitm != null && drpitm.gameObject)
                    {
                        //自己是否可拾取
                        bool hasOwner = drpitm.itemdta.ownerId != 0,
                             notMine  = drpitm.itemdta.ownerId != PlayerModel.getInstance().cid ||
                                        (TeamProxy.getInstance().MyTeamData != null && drpitm.itemdta.ownerId == TeamProxy.getInstance().MyTeamData.teamId);
                        if (hasOwner && notMine)
                        {
                            continue;
                        }
                        //!--距离超过拾取范围
                        if (Vector3.Distance(drpitm.transform.position /*.ConvertToGamePosition()*/, transform.position) > StateInit.Instance.PickDistance)
                        {
                            continue;
                        }
                        //!--如果背包满且不是金币,不捡
                        if (a3_BagModel.getInstance().curi <= a3_BagModel.getInstance().getItems().Count&& (
                                a3_BagModel.getInstance().getItemNumByTpid((uint)drpitm.itemdta.tpid) == 0 ||
                                a3_BagModel.getInstance().getItemNumByTpid((uint)drpitm.itemdta.tpid) >= a3_BagModel.getInstance().getItemDataById((uint)drpitm.itemdta.tpid).maxnum) &&
                            drpitm.itemdta.tpid != 0)
                        {
                            continue;
                        }

                        if (A3_RollModel.getInstance().rollMapping.ContainsKey(drpitm.itemdta.dpid) && !A3_RollModel.getInstance().rollMapping[drpitm.itemdta.dpid].isCanPick)
                        {
                            continue;
                        }

                        else if (drpitm.canPick && AutoPlayModel.getInstance().WillPick((uint)drpitm.itemdta.tpid))
                        {
                            pickTarget = drpitm;
                            if (nearest == null)
                            {
                                nearest = pickTarget;
                            }
                            else
                            {
                                float dis = Vector3.Distance(pickTarget.transform.position /*.ConvertToGamePosition()*/, transform.position);
                                if (dis < min)
                                {
                                    min     = dis;
                                    nearest = pickTarget;
                                }
                            }
                        }
                        else
                        {
                            pickTarget = null;
                        }
                    }
                }
                calc_ori = transform.position;
                if (nearest != null)
                {
                    //SelfRole._inst.SetDestPos(nearest.transform.position);
                    if (goto_dropitem ^ true)
                    {
                        pickTarget = null;
                    }
                    goto_dropitem = true;
                    drop_pos      = nearest.transform.position;
                    calc_tar      = nearest.transform.position;

                    // if (A3_RollModel.getInstance().rollMapping.ContainsKey(nearest.itemdta.dpid))  // 该物品是roll点物品
                    //{
                    //    bool isCanPick = A3_RollModel.getInstance().rollMapping[nearest.itemdta.dpid].isCanPick;
                    //    if (!isCanPick)
                    //    {
                    //        nearest = null;
                    //        goto_dropitem = false;
                    //        calc_tar = Vector3.zero;
                    //        drop_pos = Vector3.zero;
                    //    }else
                    //    {
                    //        return;
                    //    }
                    //}
                    //else {
                    return;
                    //}
                }
                else
                {
                    goto_dropitem = false;
                    calc_tar      = Vector3.zero;
                    drop_pos      = Vector3.zero;
                }
            }
            #endregion
            #region else
            else
            {
                // print("小鸟和物品之间的距离是多少:" + Vector3.Distance(transform.position, nearest.transform.position/*.ConvertToGamePosition()*/));
                if (Vector3.Distance(transform.position, nearest.transform.position) < 0.5f)
                {
                    if (nearest.gameObject != null)
                    {
                        nearest.PickUpItem();
                        // SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, false);
                        goto_dropitem = false;
                        drop_pos      = Vector3.zero;
                        nearest       = null;
                    }
                    else
                    {
                        goto_dropitem = false;
                        drop_pos      = Vector3.zero;
                        nearest       = null;
                    }
                }
                // bool isOutOfTouch = Vector3.Distance(nearest.transform.position.ConvertToGamePosition(), transform.position) > StateInit.Instance.PickDistance;

                if (nearest != null)
                {
                    //print("物品和pet之间的距离:" + Vector3.Distance(nearest.transform.position, transform.position) + ".限定距离:" + StateInit.Instance.PickDistance);
                    if (Vector3.Distance(nearest.transform.position /*.ConvertToGamePosition()*/, transform.position) <= StateInit.Instance.PickDistance)
                    {
                        //SelfRole._inst.TurnToPos(nearest.transform.position);
                        //SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, true);
                        if (goto_dropitem ^ true)
                        {
                            pickTarget = null;
                        }
                        goto_dropitem = true;
                        drop_pos      = nearest.transform.position;
                    }
                    else
                    {
                        nearest = null;
                        // SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, false);
                        goto_dropitem = false;
                        drop_pos      = Vector3.zero;
                    }
                }
                calc_cur = Path.transform.position;
                if (nearest == null || nearest.gameObject == null)
                {
                    goto_dropitem = false;
                    drop_pos      = Vector3.zero;
                    //SelfRole._inst.m_moveAgent.Stop();
                    //SelfRole._inst.m_curAni.SetBool(EnumAni.ANI_RUN, false);
                    //if (SelfRole.fsm.Autofighting)
                    //    SelfRole.fsm.ChangeState(StateAttack.Instance);
                    //else
                    //    SelfRole.fsm.ChangeState(StateIdle.Instance);
                    //return;
                }
            }
            #endregion
        }
예제 #5
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);
    }
예제 #6
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"));
                    }
                }
            }
        }
    }
예제 #7
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);
    }