예제 #1
0
    //检查xhun相关
    public static void CheckXhun()
    {
        bool     has  = false;
        RoleInfo role = LobbyClient.Instance.CurrentRole;
        XSoulInfo <XSoulPartInfo> xsoul_info = role.GetXSoulInfo();

        if (xsoul_info == null)
        {
            return;
        }
        XSoulPartInfo xsoul_part_into = xsoul_info.GetXSoulPartData(XSoulPart.kWeapon);

        if (xsoul_part_into == null)
        {
            return;
        }
        ItemDataInfo itemInfo = xsoul_part_into.XSoulPartItem;

        if (itemInfo == null)
        {
            return;
        }
        int curExp = itemInfo.CurLevelExperience;
        int id     = itemInfo.ItemId;
        int lv     = itemInfo.Level;
        XSoulLevelConfig config = XSoulLevelConfigProvider.Instance.GetDataById(id);

        if (lv < config.m_MaxLevel)
        {
            int maxExp = 0;
            int nextLv = lv + 1 <= config.m_MaxLevel ? lv + 1 : config.m_MaxLevel;
            config.m_LevelExperience.TryGetValue(nextLv, out maxExp);
            int   remainExp = maxExp - curExp; //剩余经验
            int[] hunIds    = config.m_ExperienceProvideItems;
            int   hunExp    = 0;               //魂丹总经验
            for (int i = 0; i < hunIds.Length; i++)
            {
                ItemDataInfo item = GetItemDataInfoById(hunIds[i]);
                if (item != null)
                {
                    ItemConfig itemConfig = ItemConfigProvider.Instance.GetDataById(hunIds[i]);
                    if (itemConfig != null)
                    {
                        hunExp += item.ItemNum * itemConfig.m_ExperienceProvide;
                    }
                }
            }
            if (remainExp <= hunExp)
            {
                has = true;
            }
        }
        ArkCrossEngine.LogicSystem.EventChannelForGfx.Publish("ge_systemnewtip_state_change", "ui", SystemNewTipType.Xhun, has);
    }
예제 #2
0
        internal static void Execute(object msg, User user)
        {
            Msg_CRC_Create enter_msg = msg as Msg_CRC_Create;

            if (enter_msg == null)
            {
                return;
            }
            LogSys.Log(LOG_TYPE.DEBUG, "user {0}({1}) enter.", user.RoleId, user.GetKey());
            user.UserControlState = (int)UserControlState.User;
            user.IsEntered        = true;

            Room room = user.OwnRoom;

            if (null != room)
            {
                Scene scene = room.GetActiveScene();
                if (null != scene)
                {
                    UserInfo userInfo = user.Info;
                    if (null != userInfo)
                    {
                        userInfo.GetXSoulInfo().GetAllXSoulPartData().Clear();
                        foreach (var pair in user.XSouls.GetAllXSoulPartData())
                        {
                            userInfo.GetXSoulInfo().SetXSoulPartData(pair.Key, pair.Value);
                        }
                        foreach (var pair in userInfo.GetXSoulInfo().GetAllXSoulPartData())
                        {
                            XSoulPartInfo part_info = pair.Value;
                            foreach (int impactid in part_info.GetActiveImpacts())
                            {
                                //LogSys.Log(LOG_TYPE.DEBUG, "---add xsoul impact to self: " + impactid);
                                ImpactSystem.Instance.SendImpactToCharacter(userInfo, impactid, userInfo.GetId(),
                                                                            -1, -1, userInfo.GetMovementStateInfo().GetPosition3D(),
                                                                            userInfo.GetMovementStateInfo().GetFaceDir());
                            }
                        }
                        if (scene.SceneState == SceneState.Running)
                        {
                            Data_Unit unit = scene.MapData.ExtractData(DataMap_Type.DT_Unit, userInfo.GetUnitId()) as Data_Unit;
                            if (null != unit)
                            {
                                userInfo.GetMovementStateInfo().SetPosition(unit.m_Pos);
                                userInfo.GetMovementStateInfo().SetFaceDir(unit.m_RotAngle);
                                userInfo.RevivePoint = unit.m_Pos;
                            }
                            scene.SyncForNewUser(user);
                        }
                    }
                }
            }
        }
예제 #3
0
        //--------------------------------------
        private void HandleCreateBattleRoom(Msg_LR_CreateBattleRoom createRoomMsg, PBChannel channel, int handle, uint seq)
        {
            LogSys.Log(LOG_TYPE.DEBUG, "channel:{0}, seq:{1}", channel, seq);
            bool canContinue = true;

            //先检查是否玩家已经在room上。
            foreach (Msg_LR_RoomUserInfo rui in createRoomMsg.UsersList)
            {
                if (RoomPeerMgr.Instance.IsKeyExist(rui.Key))
                {
                    canContinue = false;
                    LogSys.Log(LOG_TYPE.WARN, "User is already in room. UserGuid:{0}, Key:{1}", rui.Guid, rui.Key);
                    break;
                }
            }
            if (!canContinue)
            {
                Msg_RL_ReplyCreateBattleRoom.Builder replyBuilder0 = Msg_RL_ReplyCreateBattleRoom.CreateBuilder();
                replyBuilder0.SetRoomId(createRoomMsg.RoomId);
                replyBuilder0.SetIsSuccess(false);
                channel.Send(replyBuilder0.Build());
                return;
            }
            List <User> users = new List <User>();

            foreach (Msg_LR_RoomUserInfo rui in createRoomMsg.UsersList)
            {
                User rsUser = user_pool_.NewUser();
                LogSys.Log(LOG_TYPE.INFO, "NewUser {0} for {1} {2}", rsUser.LocalID, rui.Guid, rui.Key);
                rsUser.Init();
                if (!rsUser.SetKey(rui.Key))
                {
                    LogSys.Log(LOG_TYPE.WARN, "user who's key is {0} already in room!", rui.Key);
                    LogSys.Log(LOG_TYPE.INFO, "FreeUser {0} for {1} {2}, [RoomManager.HandleCreateBattleRoom]", rsUser.LocalID, rui.Guid, rui.Key);
                    user_pool_.FreeUser(rsUser.LocalID);
                    continue;
                }
                rsUser.Guid             = rui.Guid;
                rsUser.Name             = rui.Nick;
                rsUser.HeroId           = rui.Hero;
                rsUser.CampId           = rui.Camp;
                rsUser.Level            = rui.Level;
                rsUser.ArgFightingScore = rui.ArgScore;
                if (rui.IsMachine == true)
                {
                    rsUser.UserControlState = (int)UserControlState.Ai;
                }
                else
                {
                    rsUser.UserControlState = (int)UserControlState.User;
                }
                //装备数据
                for (int index = 0; index < rui.ShopEquipmentsIdCount; ++index)
                {
                    rsUser.ShopEquipmentsId.Add(rui.GetShopEquipmentsId(index));
                }
                if (null != rsUser.Skill)
                {
                    rsUser.Skill.Clear();
                    for (int i = 0; i < rui.SkillsCount; i++)
                    {
                        SkillTransmitArg skill_arg = new SkillTransmitArg();
                        skill_arg.SkillId    = rui.SkillsList[i].SkillId;
                        skill_arg.SkillLevel = rui.SkillsList[i].SkillLevel;
                        rsUser.Skill.Add(skill_arg);
                    }
                    if (rui.HasPresetIndex)
                    {
                        rsUser.PresetIndex = rui.PresetIndex;
                    }
                }
                ///
                if (null != rsUser.Equip)
                {
                    rsUser.Equip.Clear();
                    for (int i = 0; i < rui.EquipsCount; i++)
                    {
                        ItemTransmitArg equip_arg = new ItemTransmitArg();
                        equip_arg.ItemId             = rui.EquipsList[i].EquipId;
                        equip_arg.ItemLevel          = rui.EquipsList[i].EquipLevel;
                        equip_arg.ItemRandomProperty = rui.EquipsList[i].EquipRandomProperty;
                        rsUser.Equip.Add(equip_arg);
                    }
                }
                ///
                if (null != rsUser.Legacy)
                {
                    rsUser.Legacy.Clear();
                    for (int i = 0; i < rui.LegacysCount; i++)
                    {
                        ItemTransmitArg legacy_arg = new ItemTransmitArg();
                        legacy_arg.ItemId             = rui.LegacysList[i].LegacyId;
                        legacy_arg.ItemLevel          = rui.LegacysList[i].LegacyLevel;
                        legacy_arg.ItemRandomProperty = rui.LegacysList[i].LegacyRandomProperty;
                        legacy_arg.IsUnlock           = rui.LegacysList[i].LegacyIsUnlock;
                        rsUser.Legacy.Add(legacy_arg);
                    }
                }
                ///
                if (null != rsUser.XSouls)
                {
                    rsUser.XSouls.GetAllXSoulPartData().Clear();
                    for (int i = 0; i < rui.XSoulsCount; i++)
                    {
                        ItemDataInfo item = new ItemDataInfo();
                        item.ItemId     = rui.XSoulsList[i].ItemId;
                        item.Level      = rui.XSoulsList[i].Level;
                        item.Experience = rui.XSoulsList[i].Experience;
                        ItemConfig configer = ItemConfigProvider.Instance.GetDataById(item.ItemId);
                        item.ItemConfig = configer;
                        if (configer != null)
                        {
                            XSoulPartInfo part_info = new XSoulPartInfo((XSoulPart)configer.m_WearParts, item);
                            part_info.ShowModelLevel = rui.XSoulsList[i].ModelLevel;
                            rsUser.XSouls.SetXSoulPartData((XSoulPart)configer.m_WearParts, part_info);
                        }
                    }
                }
                // partner
                if (null != rui.Partner)
                {
                    PartnerConfig partnerConfig = PartnerConfigProvider.Instance.GetDataById(rui.Partner.PartnerId);
                    if (null != partnerConfig)
                    {
                        PartnerInfo partnerInfo = new PartnerInfo(partnerConfig);
                        partnerInfo.CurAdditionLevel = rui.Partner.PartnerLevel;
                        partnerInfo.CurSkillStage    = rui.Partner.PartnerStage;
                        rsUser.Partner = partnerInfo;
                    }
                }
                users.Add(rsUser);
                LogSys.Log(LOG_TYPE.DEBUG, "enter room {0} scene {1} user info guid={2}, name={3}, key={4}, camp={5}", createRoomMsg.RoomId, createRoomMsg.SceneType, rui.Guid, rui.Nick, rui.Key, rui.Camp);
            }
            //临时测试人机机制

            /*
             * Data_SceneConfig sceneCfg = SceneConfigProvider.Instance.GetSceneConfigById(createRoomMsg.SceneType);
             * if (1 == createRoomMsg.UsersCount && null != sceneCfg && sceneCfg.m_Type == (int)SceneTypeEnum.TYPE_PVP) {
             * for (int i = 0; i < 9; ++i) {
             *  User rsUser = room_mgr_.NewUser();
             *  rsUser.Init();
             *  rsUser.SetKey(0xffffffff);
             *  rsUser.Guid = 0xffffffff;
             *  rsUser.Name = "Computer" + i;
             *  rsUser.HeroId = CrossEngineHelper.Random.Next(1, 3);
             *  rsUser.CampId = (i < 4 ? (int)CampIdEnum.Blue : (int)CampIdEnum.Red);
             *  rsUser.UserControlState = (int)UserControlState.Ai;
             *  users.Add(rsUser);
             *  LogSys.Log(LOG_TYPE.DEBUG, "Computer enter room");
             * }
             * }
             */
            bool ret = false;

            if (users.Count == 0)
            {
                LogSys.Log(LOG_TYPE.WARN, "no user enter room");
                ret = false;
            }
            else
            {
                ret = ActiveRoom(createRoomMsg.RoomId, createRoomMsg.SceneType, users.ToArray());
            }
            if (ret)
            {
                LogSys.Log(LOG_TYPE.DEBUG, "user enter room success.");
            }
            else
            {
                LogSys.Log(LOG_TYPE.DEBUG, "user enter room failed!");
            }
            Msg_RL_ReplyCreateBattleRoom.Builder replyBuilder = Msg_RL_ReplyCreateBattleRoom.CreateBuilder();
            replyBuilder.SetRoomId(createRoomMsg.RoomId);
            replyBuilder.SetIsSuccess(ret);
            channel.Send(replyBuilder.Build());
        }