Ejemplo n.º 1
0
            /// <summary>
            /// 获取指定角色id的boss信息
            /// </summary>
            /// <param name="actor_id"></param>
            /// <returns></returns>
            public static RedefineBossInfo GetPkgBossInfoByActorId(uint actor_id)
            {
                // 世界BOSS体验副本伪造一个PkgBossInfo数据
                if (SceneHelp.Instance.IsInWorldBossExperienceInstance == true)
                {
                    RedefineBossInfo bossInfo = new RedefineBossInfo();

                    //Dictionary<UnitID, Actor> bossList = ActorManager.Instance.GetMonsterSetByActorId(actor_id);
                    //UnitID bossUuid = null;
                    //foreach (UnitID uuid in bossList.Keys)
                    //{
                    //    bossUuid = uuid;
                    //}
                    //Actor bossActor = ActorManager.Instance.GetActor(bossUuid);
                    // mBossKillTime大于0表示boss已经死了
                    if (mBossKillTime > 0)
                    {
                        byte[] localPlayerName     = System.Text.Encoding.UTF8.GetBytes(Game.Instance.LocalPlayerName);
                        uint   localPlayerVocation = LocalPlayerManager.Instance.LocalActorAttribute.Vocation;
                        bossInfo.state        = 0;
                        bossInfo.refresh_time = mBossKillTime + 60;
                        bossInfo.killers.Clear();
                        RedefineBossKiller killer = new RedefineBossKiller();
                        killer.time      = mBossKillTime;
                        killer.name      = localPlayerName;
                        killer.team_id   = TeamManager.Instance.TeamId;
                        killer.rid       = localPlayerVocation;
                        killer.aff_names = new List <byte[]> {
                            localPlayerName
                        };
                        bossInfo.killers.Add(killer);
                    }
                    else
                    {
                        bossInfo.state = 1;
                    }

                    return(bossInfo);
                }
                else
                {
                    if (mBossInfoAll == null)
                    {
                        return(null);
                    }

                    foreach (var boss_info in mBossInfoAll)
                    {
                        var data_special_mon = DBManager.Instance.GetDB <DBSpecialMon>().GetData(boss_info.id);
                        if (data_special_mon != null && data_special_mon.ActorId == actor_id)
                        {
                            return(boss_info);
                        }
                    }

                    return(null);
                }
            }
Ejemplo n.º 2
0
                public static RedefineBossInfo GetInfo(PkgBossInfo pkg_info)
                {
                    if (pkg_info == null)
                    {
                        return(null);
                    }
                    RedefineBossInfo protocol_info = new RedefineBossInfo();

                    protocol_info.id           = pkg_info.id;
                    protocol_info.state        = pkg_info.state;
                    protocol_info.refresh_time = pkg_info.refresh_time;

                    if (pkg_info.pos != null)
                    {
                        protocol_info.pos    = new RedefinePos();
                        protocol_info.pos.px = pkg_info.pos.px;
                        protocol_info.pos.py = pkg_info.pos.py;
                    }
                    else
                    {
                        protocol_info.pos = null;
                    }
                    protocol_info.killers.Clear();
                    if (pkg_info.killers != null)
                    {
                        for (int index = 0; index < pkg_info.killers.Count; ++index)
                        {
                            var tmp_killer            = pkg_info.killers[index];
                            RedefineBossKiller killer = new RedefineBossKiller();
                            killer.time      = tmp_killer.time;
                            killer.name      = tmp_killer.name;
                            killer.team_id   = tmp_killer.team_id;
                            killer.rid       = tmp_killer.rid;
                            killer.aff_names = tmp_killer.aff_names;
                            protocol_info.killers.Add(killer);
                        }
                    }
                    return(protocol_info);
                }
Ejemplo n.º 3
0
            public void UpdateInfo(List <PkgBossInfo> boss_list)
            {
                if (m_bossArray == null)
                {
                    m_bossArray = new List <BossInfoItem>();
                }

                foreach (var boss_info in boss_list)
                {
                    if (mBossInfoAll != null)
                    {
                        var find_item = mBossInfoAll.Find((a) =>
                        {
                            if (a.id == boss_info.id)
                            {
                                return(true);
                            }
                            return(false);
                        });
                        if (find_item != null)
                        {
                            mBossInfoAll.Remove(find_item);
                        }
                        var protocol_info = RedefineBossInfo.GetInfo(boss_info);
                        mBossInfoAll.Add(protocol_info);
                    }

                    var data_mon_attr = DBManager.Instance.GetDB <DBSpecialMon>().GetData(boss_info.id);
                    if (data_mon_attr == null)
                    {
                        GameDebug.LogError("Cannot find special monster info,id:" + boss_info.id);
                        continue;
                    }

                    if (xc.SceneHelp.Instance.CurSceneID != data_mon_attr.DungeonId)
                    {
                        continue;
                    }

                    BossInfoItem tmp_item = new BossInfoItem();
                    tmp_item.m_pkgBossInfo = boss_info;
                    tmp_item.m_need_update_exchange_model = true;
                    tmp_item.m_uid = new InterObjectUnitID(InterObjectType.TOMB_STONE, tmp_item.m_pkgBossInfo.id);
                    if (tmp_item.m_pkgBossInfo.pos != null)
                    {
                        tmp_item.m_pos.x = tmp_item.m_pkgBossInfo.pos.px * 0.01f;
                        tmp_item.m_pos.z = tmp_item.m_pkgBossInfo.pos.py * 0.01f;
                    }
                    tmp_item.m_pos.y = PhysicsHelp.GetHeight(tmp_item.m_pos.x, tmp_item.m_pos.z);
                    if (tmp_item.m_pos.y < -500)
                    {
                        GameDebug.LogError(string.Format("[MSG_BOSS_INFO] boss_actor pos maybe is error new_pos = {0}, {1}, {2}",
                                                         tmp_item.m_pos.x, tmp_item.m_pos.y, tmp_item.m_pos.z));
                        tmp_item.m_pos.y = 0;
                        var local_player = Game.Instance.GetLocalPlayer();
                        if (local_player != null && local_player.transform != null)
                        {
                            tmp_item.m_pos.y = local_player.transform.position.y;
                        }
                    }
                    tmp_item.m_model_Quaternion = Quaternion.identity;
                    bool can_add_new_monster = true;
                    for (int index = 0; index < m_bossArray.Count; ++index)
                    {
                        BossInfoItem find_item = m_bossArray[index];
                        if (find_item.m_uid != null && find_item.m_uid.m_Idx == tmp_item.m_uid.m_Idx)
                        {
                            if (find_item.m_pkgBossInfo != null &&
                                find_item.m_pkgBossInfo.state == tmp_item.m_pkgBossInfo.state)
                            {
                                can_add_new_monster = false;
                            }
                            else
                            {
                                InterObjectManager.Instance.DestroyObject(find_item.m_uid);
                                m_bossArray.Remove(find_item);
                            }
                            break;
                        }
                    }
                    if (can_add_new_monster)
                    {
                        m_bossArray.Add(tmp_item);
                    }
                }
            }
Ejemplo n.º 4
0
            public virtual void HandleServerData(ushort protocol, byte[] data)
            {
                switch (protocol)
                {
                case NetMsg.MSG_SPAN_BOSS_INFO:
                {
                    var pack      = S2CPackBase.DeserializePack <S2CSpanBossInfo>(data);
                    var boss_list = pack.mon_boss;

                    UpdateInfo(boss_list);

                    ClientEventMgr.Instance.FireEvent(xc.EnumUtil.EnumToInt(xc.ClientEvent.CE_WORLD_BOSS_UPDATE_BOSS_INFO_ALL), null);
                    break;
                }

                case NetMsg.MSG_BOSS_INFO:
                {
                    var pack      = S2CPackBase.DeserializePack <S2CBossInfo>(data);
                    var boss_list = pack.mons;
                    //m_isNeedUpdate = true;

                    UpdateInfo(boss_list);

                    ClientEventMgr.Instance.FireEvent(xc.EnumUtil.EnumToInt(xc.ClientEvent.CE_WORLD_BOSS_UPDATE_BOSS_INFO_ALL), null);
                    break;
                }

                case NetMsg.MSG_BOSS_AFFILIS:
                {
                    S2CBossAffilis pack = S2CPackBase.DeserializePack <S2CBossAffilis>(data);

                    mBossAffiTeamIds[pack.boss] = pack.team_id;

                    List <UpdateBossAffiItem> item_array = GetOneBossAffiItemArray_tryAdd(pack.boss);
                    for (int index = 0; index < item_array.Count; ++index)
                    {
                        item_array[index].m_before_isAffi = item_array[index].m_now_isAffi;
                        item_array[index].m_now_isAffi    = false;
                    }
                    //GameDebug.LogError("************** start");
                    //GameDebug.LogError(string.Format("[pack.uuids] pack.uuids.Count = {0}", pack.uuids.Count));
                    for (int index = 0; index < pack.uuids.Count; ++index)
                    {
                        //GameDebug.LogError(string.Format("[pack.uuids] index = {0} player_id = {1}", index, pack.uuids[index]));
                        UpdateBossAffiItem item = item_array.Find((a) =>
                            {
                                return(a.m_player_id == pack.uuids[index]);
                            });
                        if (item == null)
                        {
                            UpdateBossAffiItem tmp_item = new UpdateBossAffiItem();
                            tmp_item.m_player_id  = pack.uuids[index];
                            tmp_item.m_now_isAffi = true;
                            item_array.Add(tmp_item);
                        }
                        else
                        {
                            item.m_now_isAffi = true;
                        }
                    }
//
//                             for(int index = 0; index < m_updateBossAffiItemArray.Count; ++index)
//                             {
//                                 GameDebug.LogError(string.Format("index = {0} player_id = {1} m_now_isAffi = {2}", index, m_updateBossAffiItemArray[index].m_player_id,
//                                     m_updateBossAffiItemArray[index].m_now_isAffi));
//                             }

                    // GameDebug.LogError("************** end");
                    UpdateAffiliation(item_array);
                    break;
                }

                case NetMsg.MSG_BOSS_INFO_ALL:
                {
                    var pack = S2CPackBase.DeserializePack <S2CBossInfoAll>(data);
                    m_affili_times = pack.affili_times;
                    mBossInfoAll.Clear();
                    for (int index = 0; index < pack.mons.Count; ++index)
                    {
                        var tmp_protocol_info = RedefineBossInfo.GetInfo(pack.mons[index]);
                        mBossInfoAll.Add(tmp_protocol_info);
                    }

                    C2SSpanBossInfo pkg = new C2SSpanBossInfo();
                    Net.NetClient.GetBaseClient().SendData <C2SSpanBossInfo>(NetMsg.MSG_SPAN_BOSS_INFO, pkg);

                    ClientEventMgr.Instance.FireEvent(xc.EnumUtil.EnumToInt(xc.ClientEvent.CE_WORLD_BOSS_UPDATE_BOSS_INFO_ALL), null);
                    break;
                }

                case NetMsg.MSG_DUNGEON_BOSS_GUIDE_AFFI:
                {
                    if (SceneHelp.Instance.IsInWorldBossExperienceInstance == false)
                    {
                        return;
                    }
                    S2CDungeonBossGuideAffi   pack       = S2CPackBase.DeserializePack <S2CDungeonBossGuideAffi>(data);
                    List <UpdateBossAffiItem> item_array = GetOneBossAffiItemArray_tryAdd(1);
                    for (int index = 0; index < item_array.Count; ++index)
                    {
                        item_array[index].m_before_isAffi = item_array[index].m_now_isAffi;
                        item_array[index].m_now_isAffi    = false;
                    }
                    //GameDebug.LogError("************** start");
                    //GameDebug.LogError(string.Format("[pack.uuids] pack.uuids.Count = {0}", pack.uuids.Count));
                    for (int index = 0; index < pack.uuids.Count; ++index)
                    {
                        //GameDebug.LogError(string.Format("[pack.uuids] index = {0} player_id = {1}", index, pack.uuids[index]));
                        UpdateBossAffiItem item = item_array.Find((a) =>
                            {
                                return(a.m_player_id == pack.uuids[index]);
                            });
                        if (item == null)
                        {
                            UpdateBossAffiItem tmp_item = new UpdateBossAffiItem();
                            tmp_item.m_player_id  = pack.uuids[index];
                            tmp_item.m_now_isAffi = true;
                            item_array.Add(tmp_item);
                        }
                        else
                        {
                            item.m_now_isAffi = true;
                        }
                    }
                    UpdateAffiliation(item_array);
                    break;
                }

                default:
                    break;
                }
            }