Ejemplo n.º 1
0
        //--------------------------------------------------------
        //  客户端消息
        //--------------------------------------------------------
        private void OnNpcClicked(CEventBaseArgs args)
        {
            if (args == null || args.arg == null)
            {
                return;
            }

            if (UIInputEvent.TouchedUI() == true)
            {
                return;
            }

            GameObject npcObject = args.arg as GameObject;

            if (npcObject == null)
            {
                return;
            }

            var mono = ActorHelper.GetActorMono(npcObject.gameObject);

            if (mono == null)
            {
                return;
            }

            NpcPlayer targetNpc = mono.BindActor as NpcPlayer;

            if (targetNpc == null)
            {
                return;
            }

            // 点击npc后已经取消任务的导航了,所以要把导航任务清空
            TaskManager.Instance.NavigatingTask = null;

            //MissionManager.Instance.NotifyMetNpc((uint)targetNpc.NpcData.Id);
            targetNpc.OnClicked();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 判断玩家是否和本地玩家在同一服务器
        /// </summary>
        public bool IsInSameServer(uint uuid)
        {
            // 如果是人形怪,则使用本地登录的服务器id,直接返回true
            if (ActorHelper.IsShemale(uuid) == true)
            {
                return(true);
            }

            // 本地玩家服务器
            uint localUuid   = xc.Game.Instance.LocalPlayerID.obj_idx;
            uint curServerId = UuidToServerId(localUuid);

            // 玩家服务器
            uint serverId = UuidToServerId(uuid);

            // 是否都在当前服的入口列表中
            if (mMergedEntrances.Contains(curServerId) == true && mMergedEntrances.Contains(serverId) == true)
            {
                return(true);
            }

            return(curServerId == serverId);
        }
Ejemplo n.º 3
0
 public FriendsInfo(Net.PkgPlayerBrief player_brief)
 {
     this.BattlePower = player_brief.battle_power;
     if (player_brief.guild != null)
     {
         this.SocietyPos = player_brief.guild.guild_pos;
     }
     this.Level  = player_brief.level;
     this.RoleId = player_brief.rid;
     this.Uid    = player_brief.uuid;
     if (player_brief.name != null)
     {
         this.Name = System.Text.Encoding.UTF8.GetString(player_brief.name);
     }
     if (player_brief.guild != null)
     {
         this.SocietyName = System.Text.Encoding.UTF8.GetString(player_brief.guild.guild_name);
     }
     this.Online       = player_brief.offline_time == 0 ? true:false;
     this.TeamId       = player_brief.team_id;
     this.Honor        = player_brief.honor;
     this.TransferLv   = player_brief.transfer;
     this.VipLv        = player_brief.vip;
     this.BubbleId     = ActorHelper.GetPartInList(player_brief.shows, DBAvatarPart.BODY_PART.BUBBLE);
     this.PhotoFrameId = ActorHelper.GetPartInList(player_brief.shows, DBAvatarPart.BODY_PART.PHOTO_FRAME);
     if (player_brief.mate != null)
     {
         this.MateUUID = player_brief.mate.uuid;
         this.MateName = Encoding.UTF8.GetString(player_brief.mate.name);
     }
     else
     {
         this.MateUUID = 0;
         this.MateName = "";
     }
 }
Ejemplo n.º 4
0
        public static string FillTemplateByContentList(string template, string[] param_list)
        {
            if (param_list.Length <= 0)
            {
                return(template);
            }
            if (string.IsNullOrEmpty(template))
            {
                return(string.Empty);
            }

            int index = 0;

            return(mNoticeRegex.Replace(template, new MatchEvaluator(
                                            delegate(Match match)
            {
                string ret = string.Empty;
                if (index >= param_list.Length)
                {
                    return ret;
                }

                string content = param_list [index];
                string target = match.ToString();
                if (target.Length >= 3)
                {
                    target = target.Substring(1, target.Length - 2);
                    EFillType contentType = (EFillType)(int.Parse(target));
                    uint contentNum = 0xffffffff;
                    try
                    {
                        contentNum = Convert.ToUInt32(content);
                    } catch
                    {
                        // Do nothing.
                    }

                    switch (contentType)
                    {
                    // 怪物名字是后端未经过翻译就发过来的,要翻译一下
                    case EFillType.MONSTER_NAME:
                        ret = xc.TextHelper.GetTranslateText(content);
                        break;

                    // 玩法场景名字是后端未经过翻译就发过来的,要翻译一下
                    case EFillType.ACTIVITY_SCENE_NAME:
                        ret = xc.TextHelper.GetTranslateText(content);
                        break;

                    case EFillType.COLOR_TYPE:
                        ret = GoodsHelper.GetGoodsColor(contentNum);
                        break;

                    case EFillType.CHAT_GOODS_TYPELINK:         // 物品超链接
                        {
                            if (param_list.Length >= 3)
                            {
                                uint playerId = Convert.ToUInt32(param_list[index - 2]);
                                uint goods_gid = Convert.ToUInt32(param_list[index - 1]);
                                ulong goods_oid = Convert.ToUInt64(content);

                                uint color_type = GoodsHelper.GetGoodsColorTypeByTypeId(goods_gid);
                                string color_str = GoodsHelper.GetGoodsColor(color_type);
                                string goods_name = GoodsHelper.GetGoodsOriginalNameByTypeId(goods_gid);

                                uint goodsType = GoodsHelper.GetGoodsType(goods_gid);
                                if (goodsType == GameConst.GIVE_TYPE_EQUIP ||        // 装备
                                    goodsType == GameConst.GIVE_TYPE_RIDE_EQUIP ||   // 坐骑装备
                                    goodsType == GameConst.GIVE_TYPE_MAGIC_EQUIP ||  // 法宝装备
                                    goodsType == GameConst.GIVE_TYPE_DECORATE ||     // 饰品
                                    goodsType == GameConst.GIVE_TYPE_ELEMENT_EP ||   // 元素装备
                                    goodsType == GameConst.GIVE_TYPE_GOD_EQUIP ||    // 神兵
                                    goodsType == GameConst.GIVE_TYPE_ARTIFACT_EP ||  // 神器装备
                                    goodsType == GameConst.GIVE_TYPE_FIVE_ELEM)      // 五行战印
                                {
                                    ret = string.Format(xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_20"), color_str, goods_name);
                                    ret = ret + "{" + playerId + "," + goods_oid + "," + goods_gid + "})";
                                }
                                else
                                {
                                    ret = string.Format(xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_21"), color_str, goods_name);
                                    ret = ret + "{" + playerId + "," + goods_gid + "})";
                                }
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.CLIENT_GOODS_TYPELINK:       // 客户端物品超链接
                        {
                            uint goods_gid = Convert.ToUInt32(param_list[index - 1]);
                            uint goods_oid = contentNum;

                            uint color_type = GoodsHelper.GetGoodsColorTypeByTypeId(goods_gid);
                            string color_str = GoodsHelper.GetGoodsColor(color_type);
                            string goods_name = GoodsHelper.GetGoodsOriginalNameByTypeId(goods_gid);
                            ret = string.Format(xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_22"), color_str, goods_name);
                            ret = ret + "{" + content + "})";
                        }
                        break;

                    case EFillType.GOODS_GID:
                        ret = string.Empty;
                        break;

                    case EFillType.HIDE_PLAYER_ID:
                        ret = string.Empty;
                        break;

                    case EFillType.GOODS_GID_NEW:
                        {
                            if (param_list.Length >= 2)
                            {
                                uint playerId = Convert.ToUInt32(param_list[index - 1]);
                                uint goods_gid = Convert.ToUInt32(param_list[index]);

                                uint color_type = GoodsHelper.GetGoodsColorTypeByTypeId(goods_gid);
                                string color_str = GoodsHelper.GetGoodsColor(color_type);
                                string goods_name = GoodsHelper.GetGoodsOriginalNameByTypeId(goods_gid);
                                ret = string.Format(xc.TextHelper.GetConstText("CODE_TEXT_LOCALIZATION_21"), color_str, goods_name);
                                ret = ret + "{" + playerId + "," + goods_gid + "})";
                            }
                            else
                            {
                                ret = content;
                            }

                            break;
                        }

                    case EFillType.PET_ID:     // 守护ID(显示带守护品质颜色的守护名字)
                        {
                            uint pet_id = Convert.ToUInt32(content);
                            var pet_info = DBManager.Instance.GetDB <DBPet>().GetOnePetInfo(pet_id);
                            if (pet_info != null)
                            {
                                string color_str = GoodsHelper.GetGoodsColor(pet_info.Quality + 1);    //守护品质颜色和物品相差1
                                string actor_name = ActorHelper.GetActorName(pet_info.Actor_id);
                                ret = string.Format("{0}{1}</color>", color_str, actor_name);
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.TITLE_ID:
                        {
                            uint title_id = Convert.ToUInt32(content);
                            var title_info = DBManager.Instance.GetDB <DBHonor>().GetData(title_id);
                            if (title_info != null)
                            {
                                string color_str = GoodsHelper.GetGoodsColor(title_info.Quality);
                                string title_name = title_info.Name;
                                ret = string.Format("{0}{1}</color>", color_str, title_name);
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.QUAL_WORD:
                        {
                            uint qual = Convert.ToUInt32(content);
                            string color_str_name = GoodsHelper.GetGoodsColorName(qual);
                            string color_str = GoodsHelper.GetGoodsColor(qual);
                            ret = string.Format("{0}{1}</color>", color_str, color_str_name);
                        }
                        break;

                    case EFillType.TRANSFER_LV:
                        {
                            if (param_list.Length >= 2)
                            {
                                uint init_vocation = Convert.ToUInt32(param_list[index]);
                                uint transfer_lv = Convert.ToUInt32(param_list[index - 1]);
                                object[] param = { transfer_lv, init_vocation };
                                System.Type[] returnType = { typeof(string) };
                                object[] objs = LuaScriptMgr.Instance.CallLuaFunction_return(LuaScriptMgr.Instance.Lua.Global, "TransferMgr_GetVocationName", param, returnType);
                                if (objs != null && objs.Length > 0 && objs[0] != null)
                                {
                                    ret = (string)objs[0];
                                }
                                else
                                {
                                    ret = content;
                                }
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.InitVocation:
                        ret = string.Empty;
                        break;

                    case EFillType.SHOW_TYPE_TO_NAME:     //外显系统ID =>外显系统名字
                        {
                            uint show_type = Convert.ToUInt32(param_list[index]);
                            object[] param = { show_type };
                            System.Type[] returnType = { typeof(string) };
                            object[] objs = LuaScriptMgr.Instance.CallLuaFunction_return(LuaScriptMgr.Instance.Lua.Global, "ShowManager_GetShowName", param, returnType);
                            if (objs != null && objs.Length > 0 && objs[0] != null)
                            {
                                ret = (string)objs[0];
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.SHOW_TYPE_TO_PARAM:    //外显系统ID => 与25一起使用,组成外显系统的外观名字
                        {
                            ret = string.Empty;
                        }
                        break;

                    case EFillType.SHOW_TYPE_TO_FACADE_ID:
                        {
                            if (param_list.Length >= 2)
                            {
                                uint facade_id = Convert.ToUInt32(param_list[index]);
                                uint show_type = Convert.ToUInt32(param_list[index - 1]);
                                object[] param = { show_type, facade_id };
                                System.Type[] returnType = { typeof(string) };
                                object[] objs = LuaScriptMgr.Instance.CallLuaFunction_return(LuaScriptMgr.Instance.Lua.Global, "ShowManager_GetFacadeName", param, returnType);
                                if (objs != null && objs.Length > 0 && objs[0] != null)
                                {
                                    ret = (string)objs[0];
                                }
                                else
                                {
                                    ret = content;
                                }
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.SHOW_TYPE_TO_SYS_ID:       //外显系统ID =>外显系统ID
                        {
                            uint show_type = Convert.ToUInt32(param_list[index]);
                            object[] param = { show_type };
                            System.Type[] returnType = { typeof(string) };
                            object[] objs = LuaScriptMgr.Instance.CallLuaFunction_return(LuaScriptMgr.Instance.Lua.Global, "ShowManager_GetSysIdStr", param, returnType);
                            if (objs != null && objs.Length > 0 && objs[0] != null)
                            {
                                ret = (string)objs[0];
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.FASHION_NAME:       //时装
                        {
                            uint fashionId = Convert.ToUInt32(param_list[index]);
                            object[] param = { fashionId };
                            System.Type[] returnType = { typeof(string) };
                            object[] objs = LuaScriptMgr.Instance.CallLuaFunction_return(LuaScriptMgr.Instance.Lua.Global, "FashionManager_GetFashionNameWithColor", param, returnType);
                            if (objs != null && objs.Length > 0 && objs[0] != null)
                            {
                                ret = (string)objs[0];
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.MALL_NAME:     //商城名字
                        {
                            uint mall_id = Convert.ToUInt32(param_list[index]);
                            var mall_tmpl = xc.DBManager.Instance.GetDB <DBMallType>().GetOneItem(mall_id);
                            if (mall_tmpl != null)
                            {
                                //string color_str = GoodsHelper.GetGoodsColor(mall_tmpl);
                                string tmall_name = mall_tmpl.Name;
                                //ret = string.Format("{0}{1}</color>", color_str, tmall_name);
                                ret = tmall_name;
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.ESCORT_TASK_ID:     //护送任务的id
                        {
                            uint taskId = Convert.ToUInt32(param_list[index]);
                            TaskDefine taskDefine = TaskDefine.MakeDefine(taskId);
                            if (taskDefine != null)
                            {
                                ret = taskDefine.GetFollowNpcName(0);
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.INSTANCE_ID:     //副本id
                        {
                            uint instanceId = Convert.ToUInt32(param_list[index]);
                            DBInstance.InstanceInfo instanceInfo = DBInstance.Instance.GetInstanceInfo(instanceId);
                            if (instanceInfo != null)
                            {
                                ret = instanceInfo.mName;
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.GODWARE_ID:    //神器id
                        {
                            uint god_ware_id = Convert.ToUInt32(param_list[index]);
                            object[] param = { god_ware_id };
                            System.Type[] returnType = { typeof(string) };
                            object[] objs = LuaScriptMgr.Instance.CallLuaFunction_return(LuaScriptMgr.Instance.Lua.Global, "GodWareManager_GetGodWareName", param, returnType);
                            if (objs != null && objs.Length > 0 && objs[0] != null)
                            {
                                ret = (string)objs[0];
                            }
                            else
                            {
                                ret = content;
                            }
                        }
                        break;

                    case EFillType.TIMEFORMAT:
                        int time = Convert.ToInt32(param_list[index]);
                        string strShowTime = CommonTool.SecondsToStr_2(time);
                        ret = strShowTime;
                        break;

                    case EFillType.BIG_PACKET:
                        uint bigNum = Convert.ToUInt32(param_list[index]);
                        if (bigNum != 0)
                        {
                            //ret = string.Format("{0}个大红包,", bigNum);
                            ret = string.Format(xc.DBConstText.GetText("RAIN_RED_PACKET_BIG"), bigNum);
                        }
                        else
                        {
                            ret = "";
                        }
                        break;

                    case EFillType.SMALL_PACKET:
                        uint smallNum = Convert.ToUInt32(param_list[index]);
                        if (smallNum != 0)
                        {
                            //ret = string.Format("{0}个小红包,", smallNum);
                            ret = string.Format(xc.DBConstText.GetText("RAIN_RED_PACKET_SMALL"), smallNum);
                        }
                        else
                        {
                            ret = "";
                        }
                        break;

                    case EFillType.MARKET_ID:
                        {
                            uint goods_gid = Convert.ToUInt32(param_list[index - 1]);
                            uint goods_oid = contentNum;

                            uint color_type = GoodsHelper.GetGoodsColorTypeByTypeId(goods_gid);
                            string color_str = GoodsHelper.GetGoodsColor(color_type);
                            string goods_name = GoodsHelper.GetGoodsOriginalNameByTypeId(goods_gid);

                            // 【click={0}[{1}]</color>】(marketGoodsTips=
                            ret = string.Format(xc.TextHelper.GetConstText("GAME_CHAT_CLICK_MARKET_GOODS"), color_str, goods_name);
                            ret = ret + "{" + content + "})";
                        }
                        break;

                    case EFillType.CONTROL_ID:
                        var id = Convert.ToInt32(param_list[index]);
                        ret = SpanServerManager.Instance.GetServerNameByControlServerId((uint)id);
                        break;

                    case EFillType.CHANNEL_ID:
                        ret = ChannelHelper.GetChannelName(param_list[index]);
                        break;

                    default:
                        ret = xc.TextHelper.GetTranslateText(content);
                        break;
                    }
                }

                index++;
                return ret;
            }
                                            )));
        }
Ejemplo n.º 5
0
        public void UpdateUnitCache(bool doAll, UnitCacheDataFilter filter)
        {
            const int MAX_PROCESS_UNIT_PER_FRAME = 3;

            for (int i = 0; mUnitCacheData.Count != 0; ++i)
            {
                if (!doAll)
                {
                    if (i >= MAX_PROCESS_UNIT_PER_FRAME)
                    {
                        break;
                    }
                }

                UnitCacheInfo info = PopUnitCacheData();

                if (info == null)
                {
                    continue;
                }

                if (info.UnitType != EUnitType.UNITTYPE_PLAYER && info.UnitType != EUnitType.UNITTYPE_NPC &&
                    info.UnitType != EUnitType.UNITTYPE_MONSTER && info.UnitType != EUnitType.UNITTYPE_PET)
                {
                    continue;
                }

                if (filter != null && !filter(info))
                {
                    continue;
                }

                Actor actor = null;
                if (info.CacheType == UnitCacheInfo.EType.ET_Create)
                {
                    float rawY = info.PosBorn.y;
                    info.PosBorn = PhysicsHelp.GetPosition(info.PosBorn.x, info.PosBorn.z);
                    if (info.UnitType == EUnitType.UNITTYPE_PLAYER)
                    {
                        if (info.UnitID.Equals(mGame.LocalPlayerID))// 创建本地玩家
                        {
                            actor = mGame.GetLocalPlayer();
                            if (actor == null)
                            {
                                var vocation = (Actor.EVocationType)ActorHelper.TypeIdToRoleId(info.AOIPlayer.type_idx);
                                info.AOIPlayer.model_id_list = ReplaceModelList(info.AOIPlayer.model_id_list, vocation, false);
                                actor = ActorManager.Instance.CreateActor <LocalPlayer>(info, info.Rotation, null);
                                ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_LOCALPLAYER_CREATE, new CEventBaseArgs(actor));
                            }
                        }
                        else// 创建其他玩家
                        {
                            if (ActorManager.Instance.ActorSet.ContainsKey(info.UnitID))
                            {
                                GameDebug.Log(string.Format("Player(ID: {0}) has been created.", info.UnitID.obj_idx));
                                continue;
                            }

                            actor = ActorManager.Instance.CreateActor <RemotePlayer>(info, info.Rotation, null);

                            // FIXME 创建本地玩家的时候也会发送该消息
                            ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_REMOTEPLAYER_CREATE, new CEventBaseArgs(actor));
                        }
                    }
                    else if (info.UnitType == EUnitType.UNITTYPE_NPC)
                    {
                        actor = ActorManager.Instance.CreateActor <NpcPlayer>(info, info.ClientNpc.Rotation, null);
                    }
                    else if (info.UnitType == EUnitType.UNITTYPE_MONSTER)
                    {
                        if (ActorManager.Instance.ActorSet.ContainsKey(info.UnitID))
                        {
                            GameDebug.LogError(string.Format("Monster(ID: {0}) has been created.", info.UnitID.obj_idx));
                            continue;
                        }
                        Monster.CreateParam createParam = new Monster.CreateParam();
                        createParam.is_pet = false;
                        if (ActorHelper.IsSummon(info.UnitID.obj_idx))
                        {
                            createParam.summon     = true;
                            createParam.summonType = Monster.MonsterType.SummonRemoteMonster;
                            if (info.ParentActor != null)
                            {
                                createParam.master = info.ParentActor.UID;
                                // 判断是不是本地召唤怪
                                if (createParam.master.Equals(Game.Instance.LocalPlayerID) == true)
                                {
                                    createParam.summonType = Monster.MonsterType.SummonLocalMonster;
                                }
                            }
                        }
                        var obj = ActorManager.Instance.CreateActor <Monster>(info, info.Rotation, createParam);
                    }
                    else if (info.UnitType == EUnitType.UNITTYPE_PET)
                    {
                        if (ActorManager.Instance.ActorSet.ContainsKey(info.UnitID))
                        {
                            GameDebug.LogError(string.Format("Pet(ID: {0}) has been created.", info.UnitID.obj_idx));
                            continue;
                        }

                        Monster.CreateParam createParam = new Monster.CreateParam();
                        createParam.is_pet = true;
                        createParam.summon = false;
                        if (info.ParentActor != null)
                        {
                            createParam.master = info.ParentActor.UID;
                        }

                        if (info.AOIPet.is_local)
                        {
                            ActorManager.Instance.CreateActor <LocalPet>(info, info.Rotation, createParam);
                        }
                        else
                        {
                            ActorManager.Instance.CreateActor <RemotePet>(info, info.Rotation, createParam);
                        }
                    }
                }
                else if (info.CacheType == UnitCacheInfo.EType.ET_Destroy)
                {
                    ActorManager.Instance.DestroyActor(info.UnitID, 0);
                }
                else
                {
                    GameDebug.LogError("Error Cache data!");
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 根据AOI信息更新本地玩家
        /// </summary>
        /// <param name="info"></param>
        void UpdateLocalPlayerAOIInfo(PkgPlayerBrief info)
        {
            var local_player = Game.Instance.GetLocalPlayer() as LocalPlayer;

            if (local_player == null)
            {
                return;
            }

            List <uint> model_list   = new List <uint>();
            List <uint> fashion_list = new List <uint>();

            ActorHelper.GetModelFashionList(info.shows, model_list, fashion_list);
            local_player.mAvatarCtrl.ChangeFacade(model_list, fashion_list, info.effects, local_player.VocationID);
            var client_model_set = ActorManager.Instance.ClientModelSet;

            foreach (var client_modle in client_model_set.Values)
            {
                if (client_modle != null && client_modle.RawUID == local_player.UID.obj_idx && client_modle.UpdateWithRawActor)
                {
                    client_modle.mAvatarCtrl.ChangeFacade(model_list, fashion_list, info.effects, local_player.VocationID);
                }
            }

            if (info.guild != null)
            {
                local_player.ActorAttribute.GuildId   = info.guild.guild_id;
                local_player.ActorAttribute.GuildName = System.Text.Encoding.UTF8.GetString(info.guild.guild_name);
            }
            else
            {
                local_player.ActorAttribute.GuildId   = 0;
                local_player.ActorAttribute.GuildName = "";
            }

            local_player.UpdateNameColor(info.name_color);

            local_player.ActorAttribute.Honor      = info.honor;
            local_player.ActorAttribute.Title      = info.title;
            local_player.ActorAttribute.TransferLv = info.transfer;

            local_player.MateInfo = info.mate;

            local_player.SetNameText();
            local_player.ActorAttribute.BattlePower = info.battle_power;
            local_player.ActorAttribute.Level       = info.level;

            uint oldEscortId = local_player.ActorAttribute.EscortId;

            if (info.war != null)
            {
                local_player.ActorAttribute.TeamId   = info.war.team_id;
                local_player.ActorAttribute.EscortId = info.war.escort_id;

                if (local_player != null)
                {
                    local_player.UpdateAOIAttrElement(info.war.attr_elm);
                }

                local_player.UpdateByBitState(info.bit_states);
                local_player.SetHeadIcons(Actor.EHeadIcon.TEAM);
                local_player.UpdatePetId(info.war.pet_skin);
            }
            else
            {
                local_player.ActorAttribute.TeamId   = 0;
                local_player.ActorAttribute.EscortId = 0;
            }
            if (oldEscortId != local_player.ActorAttribute.EscortId)
            {
                local_player.UpdateEscortNPC();
            }
            if (local_player.ActorAttribute.EscortId > 0)
            {
                // 如果有进行中的护送任务,则寻路做这个任务
                if (oldEscortId != local_player.ActorAttribute.EscortId)
                {
                    RouterManager.Instance.GenericGoToSysWindow(GameConst.SYS_OPEN_QUEST_ESCORT);
                }
            }

            local_player.SetHeadIcons(Actor.EHeadIcon.PEAK);

            LocalPlayerManager.Instance.LocalActorAttribute.EscortId = local_player.ActorAttribute.EscortId;

            local_player.MountId = info.ride;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 响应aoi出现的消息
        /// </summary>
        /// <param name="pack"></param>
        public void HandleUnitAppear(S2CNwarAppear pack)
        {
            var uuid = pack.move.id;

            // 如果是玩家或者人形怪
            if (ActorHelper.IsPlayer(uuid) || ActorHelper.IsShemale(uuid))
            {
#if TEST_WILD_PROTOCOL
                GameDebug.Log(">>>MSG_NWAR_APPEAR player id = " + pack.moves.id);
#endif
                // 不需要处理本地玩家的appear
                if (uuid == Game.GetInstance().LocalPlayerID.obj_idx)
                {
                    return;
                }

                // 超出极限了,直接抛弃
                if (IsPlayerReachLimit())
                {
                    return;
                }

                var info = GetWildPlayerInfo(pack.move.id, true);
                if (info != null)
                {
                    info.HandleAppear(pack.move, pack.version, pack.buffs, (uint)pack.appear_bit);
                }
            }
            // 如果是召唤怪物
            else if (ActorHelper.IsSummon(uuid))
            {
#if TEST_WILD_PROTOCOL
                GameDebug.Log(">>>MSG_NWAR_APPEAR summon id = " + pack.moves.id);
#endif
                // 不需要处理本地玩家的召唤怪
                if (ActorHelper.IsMySummon(uuid))
                {
                    return;
                }

                var monster_info = GetWildMonsterInfo(pack.move.id, true);
                if (monster_info != null)
                {
                    monster_info.HandleAppear(pack.move, pack.buffs);
                }
            }
            // 如果是普通怪物
            else
            {
#if TEST_WILD_PROTOCOL
                GameDebug.Log(">>>MSG_NWAR_APPEAR monster id = " + pack.moves.id);
#endif
                var monster_info = GetWildMonsterInfo(pack.move.id, true);
                if (monster_info != null)
                {
                    monster_info.HandleAppear(pack.move, pack.buffs);
                }
            }

            var monBrief = pack.mon_brief;
            if (monBrief != null)
            {
                GetWildMonsterInfo(monBrief.uuid, true).HandleBriefInfo(monBrief);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 更新AOI的数据
        /// </summary>
        /// <param name="info"></param>
        protected override void UpdateAoiInfo(PkgPlayerBrief info)
        {
            if (Actor == null)
            {
                return;
            }

            Actor.ActorAttribute.State = info.state;

            List <uint> model_list   = new List <uint>();
            List <uint> fashion_list = new List <uint>();

            ActorHelper.GetModelFashionList(info.shows, model_list, fashion_list);
            Actor.mAvatarCtrl.ChangeFacade(model_list, fashion_list, info.effects, Actor.VocationID);

            if (info.guild != null)
            {
                Actor.ActorAttribute.GuildId   = info.guild.guild_id;
                Actor.ActorAttribute.GuildName = System.Text.Encoding.UTF8.GetString(info.guild.guild_name);
            }
            else
            {
                Actor.ActorAttribute.GuildId   = 0;
                Actor.ActorAttribute.GuildName = "";
            }

            Actor.ActorAttribute.Honor      = info.honor;
            Actor.ActorAttribute.Title      = info.title;
            Actor.ActorAttribute.TransferLv = info.transfer;
            Actor.UpdateNameColor(info.name_color);
            Actor.MateInfo = info.mate;
            Actor.SetNameText();
            Actor.ActorAttribute.BattlePower = info.battle_power;
            Actor.ActorAttribute.Level       = info.level;

            uint oldEscortId = Actor.ActorAttribute.EscortId;

            if (info.war != null)
            {
                Actor.ActorAttribute.TeamId   = info.war.team_id;
                Actor.ActorAttribute.EscortId = info.war.escort_id;

                //Actor.PKLvProtect = Info.war.pk_lv_protect;
                if (Actor != null)
                {
                    Actor.UpdateAOIAttrElement(info.war.attr_elm);
                }

                Actor.UpdateByBitState(Info.bit_states);
                Actor.SetHeadIcons(Actor.EHeadIcon.TEAM);
                if (Actor is Player)
                {
                    (Actor as Player).UpdatePetId(info.war.pet_skin);
                }
            }
            else
            {
                Actor.ActorAttribute.TeamId   = 0;
                Actor.ActorAttribute.EscortId = 0;
            }
            Actor.SetHeadIcons(Actor.EHeadIcon.PEAK);

            // 远程玩家的护送npc暂时屏蔽掉
            //Player player = Actor as Player;
            //if (player != null)
            //{
            //    if (oldEscortId != Actor.ActorAttribute.EscortId)
            //    {
            //        player.UpdateEscortNPC();
            //    }
            //}

            Actor.MountId = info.ride;
        }
Ejemplo n.º 9
0
        public void HandleServerData(ushort protocol, byte[] data)
        {
            switch (protocol)
            {
            case NetMsg.MSG_RELATION_INFO:
            {
                var        pack       = S2CPackBase.DeserializePack <S2CRelationInfo>(data);
                FriendType friendType = (FriendType)pack.type;
                if (friendType != FriendType.Closer)
                {
                    FriendsManager.Instance.GetListByType(friendType).Clear();
                }
                for (int i = 0; i < pack.infos.Count; i++)
                {
                    var         netInfo = pack.infos[i];
                    FriendsInfo info    = new FriendsInfo(netInfo);
                    FriendsManager.Instance.AddFriend(friendType, info, true);
                }
                ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_FRIENDS_CHANGE, new CEventBaseArgs(friendType));
                break;
            }

            case NetMsg.MSG_RELATION_ONLINE_INFO:
            {
                var        pack       = S2CPackBase.DeserializePack <S2CRelationOnlineInfo>(data);
                FriendType friendType = (FriendType)pack.type;
                var        list       = FriendsManager.Instance.GetListByType(friendType);
                for (int i = 0; i < list.Count; i++)
                {
                    var friends = list[i];
                    friends.TeamId = 0;
                    friends.UpdateOnlineState(0);
                }

                for (int j = 0; j < pack.infos.Count; j++)
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        var friends    = list[i];
                        var srvFriends = pack.infos[j];
                        if (friends.Uid == srvFriends.uuid)
                        {
                            if (srvFriends.name != null)
                            {
                                friends.Name = Encoding.UTF8.GetString(srvFriends.name);
                            }

                            friends.Level        = srvFriends.level;
                            friends.TeamId       = srvFriends.team_id;
                            friends.TransferLv   = srvFriends.transfer;
                            friends.VipLv        = srvFriends.vip;
                            friends.BubbleId     = ActorHelper.GetPartInList(srvFriends.shows, DBAvatarPart.BODY_PART.BUBBLE);
                            friends.PhotoFrameId = ActorHelper.GetPartInList(srvFriends.shows, DBAvatarPart.BODY_PART.PHOTO_FRAME);
                            if (srvFriends.mate != null)
                            {
                                friends.MateName = Encoding.UTF8.GetString(srvFriends.mate.name);
                                friends.MateUUID = srvFriends.mate.uuid;
                            }
                            else
                            {
                                friends.MateUUID = 0;
                                friends.MateName = "";
                            }

                            friends.UpdateOnlineState(1);
                        }
                    }
                }

                ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_FRIENDS_ONLINE_CHANGE, new CEventBaseArgs(friendType));
                break;
            }

            case NetMsg.MSG_RELATION_ADD:
            {
                var         pack       = S2CPackBase.DeserializePack <S2CRelationAdd>(data);
                FriendsInfo info       = new FriendsInfo(pack.info);
                FriendType  friendType = (FriendType)pack.type;
                string      playerName = System.Text.Encoding.UTF8.GetString(pack.info.name);
                switch (friendType)
                {
                case FriendType.Friend:
                {
                    UINotice.Instance.ShowMessage(string.Format(DBConstText.GetText("FRIENDS_ADD_POSITIVE"), playerName));
                    ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_FRIENDS_ADD_BOTH_SIDES, new CEventBaseArgs(info.Uid));
                    break;
                }

                case FriendType.Black:
                {
                    UINotice.Instance.ShowMessage(DBConstText.GetText("FRIENDS_ADD_3"));
                    break;
                }

                case FriendType.Enemy:
                {
                    break;
                }
                }
                FriendsManager.Instance.AddFriend(friendType, info, false);
                ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_FRIENDS_CHANGE, new CEventBaseArgs(friendType));
                break;
            }

            case NetMsg.MSG_RELATION_BE_ADDED:
            {
                var         pack       = S2CPackBase.DeserializePack <S2CRelationBeAdded>(data);
                FriendsInfo friendInfo = new FriendsInfo(pack.info);
                string      playerName = System.Text.Encoding.UTF8.GetString(pack.info.name);
                FriendsManager.Instance.AddFriend(FriendType.Friend, friendInfo, false);
                UINotice.Instance.ShowMessage(string.Format(DBConstText.GetText("FRIENDS_ADD_PASSIVE"), playerName));
                ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_FRIENDS_ADD_BOTH_SIDES, new CEventBaseArgs(friendInfo.Uid));
                break;
            }

            case NetMsg.MSG_RELATION_ALREADY_BEEN:
            {
                var pack = S2CPackBase.DeserializePack <S2CRelationAlreadyBeen>(data);
                if ((FriendType)pack.type == FriendType.Friend)
                {
                    ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_FRIENDS_ADD_BOTH_SIDES, new CEventBaseArgs(pack.uuid));
                }
                break;
            }

            case NetMsg.MSG_RELATION_DEL:
            {
                var        pack       = S2CPackBase.DeserializePack <S2CRelationDel>(data);
                FriendType friendType = (FriendType)pack.type;
                FriendsManager.Instance.Remove(friendType, pack.target_id);
                ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_FRIENDS_CHANGE, new CEventBaseArgs(friendType));
                break;
            }

            case NetMsg.MSG_RELATION_SEARCH:
            {
                var pack = S2CPackBase.DeserializePack <S2CRelationSearch>(data);
                if (pack.info == null)
                {
                    UINotice.Instance.ShowMessage(string.Format(DBConstText.GetText("FRIENDS_SEARCH")));
                }
                else
                {
                    FriendsInfo info = new FriendsInfo(pack.info);
                    ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_FRIENDS_SEARCH_RESULT, new CEventBaseArgs(info));
                }
                break;
            }

            case NetMsg.MSG_RELATION_RECOMMEND:
            {
                var pack = S2CPackBase.DeserializePack <S2CRelationRecommend>(data);
                FriendsManager.Instance.Recommends.Clear();
                for (int i = 0; i < pack.infos.Count; i++)
                {
                    FriendsInfo info = new FriendsInfo(pack.infos[i]);
                    FriendsManager.Instance.Recommends.Add(info);
                }
                ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_FRIENDS_RECOMMEND, null);
                break;
            }

            // 好友申请列表
            case NetMsg.MSG_RELATION_FRIEND_APPLY_L:
            {
                var pack = S2CPackBase.DeserializePack <S2CRelationFriendApplyL>(data);
                FriendsManager.Instance.Applicants.Clear();
                for (int i = 0; i < pack.apply_l.Count; i++)
                {
                    FriendsInfo info = new FriendsInfo(pack.apply_l[i]);
                    FriendsManager.Instance.AddApplicant(info);
                }
                ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_FRIENDS_APPLICANTS_CHANGE, null);
                break;
            }

            // 新增好友申请
            case NetMsg.MSG_RELATION_FRIEND_APPLY_ADD:
            {
                var pack = S2CPackBase.DeserializePack <S2CRelationFriendApplyAdd>(data);
                for (int i = 0; i < pack.apply_l.Count; i++)
                {
                    FriendsInfo info = new FriendsInfo(pack.apply_l[i]);
                    FriendsManager.Instance.AddApplicant(info);
                }
                ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_FRIENDS_APPLICANTS_CHANGE, null);
                break;
            }

            // 好友申请删除
            case NetMsg.MSG_RELATION_FRIEND_APPLY_DEL:
            {
                var pack = S2CPackBase.DeserializePack <S2CRelationFriendApplyDel>(data);
                FriendsManager.Instance.RemoveApplicant(pack.uuid);
                ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_FRIENDS_APPLICANTS_CHANGE, null);
                break;
            }

            // 好友亲密度
            case NetMsg.MSG_RELATION_FRIENDSHIP:
            {
                var pack = S2CPackBase.DeserializePack <S2CRelationFriendship>(data);
                for (int i = 0; i < pack.infos.Count; i++)
                {
                    var  info     = pack.infos[i];
                    uint uuid     = info.k;
                    uint intimacy = info.v;
                    List <FriendsInfo> FriendList;
                    if (FriendsManager.Instance.mCommon.TryGetValue(FriendType.Friend, out FriendList))
                    {
                        var FriendInfo = FriendList.Find(_FriendInfo => _FriendInfo.Uid == uuid);
                        if (FriendInfo != null)
                        {
                            FriendInfo.Intimacy = intimacy;
                        }
                    }
                }
                ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_FRIENDS_INTIMACY_CHANGE, null);
                break;
            }

            case NetMsg.MSG_RELATION_RECEIVE_FLOWER:
            {
                var  pack      = S2CPackBase.DeserializePack <S2CRelationReceiveFlower>(data);
                var  brief     = pack.info;
                uint GID       = pack.gid;
                uint FlowerNum = pack.num;
                uint Anonymous = pack.secret;

                uint warSubType = InstanceManager.Instance.InstanceInfo.mWarSubType;
                if (warSubType == GameConst.WAR_SUBTYPE_ARENA || warSubType == GameConst.WAR_SUBTYPE_BATTLE_FIELD)
                {
                    ClientEventMgr.GetInstance().PostEvent((int)ClientEvent.CE_RECEIVE_FLOWER, new CEventEventParamArgs(brief, GID, FlowerNum, Anonymous));
                }
                else
                {
                    ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_RECEIVE_FLOWER, new CEventEventParamArgs(brief, GID, FlowerNum, Anonymous));
                }

                break;
            }

            case NetMsg.MSG_RELATION_SEND_FLOWER_KISS:
            {
                var pack  = S2CPackBase.DeserializePack <S2CRelationSendFlowerKiss>(data);
                var brief = pack.info;
                ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_SEND_FLOWER_KISS, new CEventBaseArgs(brief));
                break;
            }
            }
        }