当前位置: 首页>>代码示例>>C#>>正文


C# GameClient.GetMessageHandler方法代码示例

本文整理汇总了C#中Yupi.Game.GameClients.Interfaces.GameClient.GetMessageHandler方法的典型用法代码示例。如果您正苦于以下问题:C# GameClient.GetMessageHandler方法的具体用法?C# GameClient.GetMessageHandler怎么用?C# GameClient.GetMessageHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Yupi.Game.GameClients.Interfaces.GameClient的用法示例。


在下文中一共展示了GameClient.GetMessageHandler方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandlePurchase


//.........这里部分代码省略.........
                    session.GetHabbo().UpdateSeasonalCurrencyBalance();
                }
            }

            #endregion

            foreach (Item baseItem in item.Items.Keys)
            {
                #region Stack if Gift

                if (isGift)
                {
                    if ((DateTime.Now - session.GetHabbo().LastGiftPurchaseTime).TotalSeconds <= 15.0)
                    {
                        session.SendNotif(Yupi.GetLanguage().GetVar("user_send_gift"));

                        return;
                    }

                    if (!baseItem.AllowGift)
                        return;

                    DataRow row;

                    using (IQueryAdapter queryreactor3 = Yupi.GetDatabaseManager().GetQueryReactor())
                    {
                        queryreactor3.SetQuery("SELECT id FROM users WHERE username = @gift_user");
                        queryreactor3.AddParameter("gift_user", giftUser);
                        row = queryreactor3.GetRow();
                    }

                    if (row == null)
                    {
                        session.GetMessageHandler().GetResponse().Init(LibraryParser.OutgoingRequest("GiftErrorMessageComposer"));
                        session.GetMessageHandler().GetResponse().AppendString(giftUser);
                        session.GetMessageHandler().SendResponse();

                        return;
                    }

                    toUserId = (uint) row["id"];

                    if (toUserId == 0u)
                    {
                        session.GetMessageHandler().GetResponse().Init(LibraryParser.OutgoingRequest("GiftErrorMessageComposer"));
                        session.GetMessageHandler().GetResponse().AppendString(giftUser);
                        session.GetMessageHandler().SendResponse();

                        return;
                    }

                    if (item.CreditsCost > 0)
                    {
                        session.GetHabbo().Credits -= item.CreditsCost*totalPrice;
                        session.GetHabbo().UpdateCreditsBalance();
                    }

                    if (item.DucketsCost > 0)
                    {
                        session.GetHabbo().Duckets -= item.DucketsCost*totalPrice;
                        session.GetHabbo().UpdateActivityPointsBalance();
                    }

                    if (item.DiamondsCost > 0)
                    {
                        session.GetHabbo().Diamonds -= item.DiamondsCost*totalPrice;
开发者ID:ImNotSatan,项目名称:Yupi,代码行数:67,代码来源:CatalogManager.cs

示例2: RemoveUserFromRoom

        /// <summary>
        ///     Removes the user from room.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="notifyClient">if set to <c>true</c> [notify client].</param>
        /// <param name="notifyKick">if set to <c>true</c> [notify kick].</param>
        internal void RemoveUserFromRoom(GameClient session, bool notifyClient, bool notifyKick)
        {
            try
            {
                if (session == null || session.GetHabbo() == null || _userRoom == null)
                    return;
                uint userId = session.GetHabbo().Id;

                session.GetHabbo().GetAvatarEffectsInventoryComponent().OnRoomExit();
                //using (var queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                //    queryReactor.RunFastQuery("UPDATE users_rooms_visits SET exit_timestamp = '" + Yupi.GetUnixTimeStamp() + "' WHERE room_id = '" + _room.RoomId + "' AND user_id = '" + session.GetHabbo().Id + "' ORDER BY entry_timestamp DESC LIMIT 1");

                RoomUser roomUserByHabbo = GetRoomUserByHabbo(userId);
                if (roomUserByHabbo == null)
                    return;
                if (notifyKick)
                {
                    Room room = Yupi.GetGame().GetRoomManager().GetRoom(roomUserByHabbo.RoomId);
                    DynamicRoomModel model = room.GetGameMap().Model;
                    roomUserByHabbo.MoveTo(model.DoorX, model.DoorY);
                    roomUserByHabbo.CanWalk = false;
                    session.GetMessageHandler()
                        .GetResponse()
                        .Init(LibraryParser.OutgoingRequest("RoomErrorMessageComposer"));
                    session.GetMessageHandler().GetResponse().AppendInteger(4008);
                    session.GetMessageHandler().SendResponse();

                    session.GetMessageHandler()
                        .GetResponse()
                        .Init(LibraryParser.OutgoingRequest("OutOfRoomMessageComposer"));
                    session.GetMessageHandler().GetResponse().AppendShort(2);
                    session.GetMessageHandler().SendResponse();
                }
                else if (notifyClient)
                {
                    ServerMessage serverMessage =
                        new ServerMessage(LibraryParser.OutgoingRequest("UserIsPlayingFreezeMessageComposer"));
                    serverMessage.AppendBool(roomUserByHabbo.Team != Team.None);
                    roomUserByHabbo.GetClient().SendMessage(serverMessage);
                    session.GetMessageHandler()
                        .GetResponse()
                        .Init(LibraryParser.OutgoingRequest("OutOfRoomMessageComposer"));
                    session.GetMessageHandler().GetResponse().AppendShort(2);
                    session.GetMessageHandler().SendResponse();
                }
                if (roomUserByHabbo.Team != Team.None)
                {
                    _userRoom.GetTeamManagerForBanzai().OnUserLeave(roomUserByHabbo);
                    _userRoom.GetTeamManagerForFreeze().OnUserLeave(roomUserByHabbo);
                }
                if (roomUserByHabbo.RidingHorse)
                {
                    roomUserByHabbo.RidingHorse = false;
                    RoomUser horse = GetRoomUserByVirtualId((int) roomUserByHabbo.HorseId);
                    if (horse != null)
                    {
                        horse.RidingHorse = false;
                        horse.HorseId = 0u;
                    }
                }
                if (roomUserByHabbo.IsLyingDown || roomUserByHabbo.IsSitting)
                {
                    roomUserByHabbo.IsSitting = false;
                    roomUserByHabbo.IsLyingDown = false;
                }
                RemoveRoomUser(roomUserByHabbo);
                if (session.GetHabbo() != null && !roomUserByHabbo.IsSpectator)
                {
                    if (roomUserByHabbo.CurrentItemEffect != ItemEffectType.None)
                        roomUserByHabbo.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().CurrentEffect = -1;
                    if (session.GetHabbo() != null)
                    {
                        if (_userRoom.HasActiveTrade(session.GetHabbo().Id))
                            _userRoom.TryStopTrade(session.GetHabbo().Id);
                        session.GetHabbo().CurrentRoomId = 0;
                        if (session.GetHabbo().GetMessenger() != null)
                            session.GetHabbo().GetMessenger().OnStatusChanged(true);
                    }

                    using (IQueryAdapter queryreactor2 = Yupi.GetDatabaseManager().GetQueryReactor())
                        if (session.GetHabbo() != null)
                            queryreactor2.RunFastQuery(string.Concat(
                                "UPDATE users_rooms_visits SET exit_timestamp = '", Yupi.GetUnixTimeStamp(),
                                "' WHERE room_id = '", _userRoom.RoomId, "' AND user_id = '", userId,
                                "' ORDER BY exit_timestamp DESC LIMIT 1"));
                }
                UsersByUserId.Remove(roomUserByHabbo.UserId);
                if (session.GetHabbo() != null)
                    UsersByUserName.Remove(session.GetHabbo().UserName.ToLower());
                roomUserByHabbo.Dispose();
            }
            catch (Exception ex)
            {
                ServerLogManager.LogCriticalException($"Error during removing user from room:{ex}");
//.........这里部分代码省略.........
开发者ID:bblackv,项目名称:Yupi,代码行数:101,代码来源:RoomUserManager.cs

示例3: OnTrigger

        public override void OnTrigger(GameClient session, RoomItem item, int request, bool hasRights)
        {
            if (!item.ExtraData.Contains(Convert.ToChar(5).ToString()))
                return;

            string[] array = item.ExtraData.Split(Convert.ToChar(5));

            session.GetHabbo().Gender = array[0].ToUpper() == "F" ? "F" : "M";

            Dictionary<string, string> dictionary = new Dictionary<string, string>();

            dictionary.Clear();

            string[] array2 = array[1].Split('.');

            foreach (string text in array2)
            {
                string[] array3 = session.GetHabbo().Look.Split('.');

                foreach (string text2 in array3)
                {
                    if (text2.Split('-')[0] == text.Split('-')[0])
                    {
                        if (dictionary.ContainsKey(text2.Split('-')[0]) && !dictionary.ContainsValue(text))
                        {
                            dictionary.Remove(text2.Split('-')[0]);
                            dictionary.Add(text2.Split('-')[0], text);
                        }
                        else
                        {
                            if (!dictionary.ContainsKey(text2.Split('-')[0]) && !dictionary.ContainsValue(text))
                                dictionary.Add(text2.Split('-')[0], text);
                        }
                    }
                    else
                    {
                        if (!dictionary.ContainsKey(text2.Split('-')[0]))
                            dictionary.Add(text2.Split('-')[0], text2);
                    }
                }
            }

            string text3 = dictionary.Values.Aggregate("", (current1, current) => $"{current1}{current}.");

            session.GetHabbo().Look = text3.TrimEnd('.');

            using (IQueryAdapter commitableQueryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                commitableQueryReactor.SetQuery(
                    $"UPDATE users SET look = @look, gender = @gender WHERE id = {session.GetHabbo().Id}");
                commitableQueryReactor.AddParameter("look", session.GetHabbo().Look);
                commitableQueryReactor.AddParameter("gender", session.GetHabbo().Gender);
                commitableQueryReactor.RunQuery();
            }

            session.GetMessageHandler()
                .GetResponse()
                .Init(LibraryParser.OutgoingRequest("UpdateUserDataMessageComposer"));
            session.GetMessageHandler().GetResponse().AppendInteger(-1);
            session.GetMessageHandler().GetResponse().AppendString(session.GetHabbo().Look);
            session.GetMessageHandler().GetResponse().AppendString(session.GetHabbo().Gender.ToLower());
            session.GetMessageHandler().GetResponse().AppendString(session.GetHabbo().Motto);
            session.GetMessageHandler().GetResponse().AppendInteger(session.GetHabbo().AchievementPoints);
            session.GetMessageHandler().SendResponse();

            RoomUser roomUserByHabbo = item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(session.GetHabbo().Id);

            ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("UpdateUserDataMessageComposer"));

            serverMessage.AppendInteger(roomUserByHabbo.VirtualId);
            serverMessage.AppendString(session.GetHabbo().Look);
            serverMessage.AppendString(session.GetHabbo().Gender.ToLower());
            serverMessage.AppendString(session.GetHabbo().Motto);
            serverMessage.AppendInteger(session.GetHabbo().AchievementPoints);

            session.GetHabbo().CurrentRoom.SendMessage(serverMessage);
        }
开发者ID:weslley17w,项目名称:Yupi,代码行数:77,代码来源:InteractorMannequin.cs

示例4: ProgressUserAchievement


//.........这里部分代码省略.........
                // if progress isn't sufficient or, isn't new Achievement
                if (achievementProgress < achievementNextLevelData.Requirement || achievementCurrentLevel >= 1)
                    fromZero = false;

                // If progress is sufficient to next level, or is new Achievement
                if (achievementProgress >= achievementNextLevelData.Requirement || (achievementCurrentLevel < 1))
                    fromZero = true;

                // if is a new level (but level isn't 0)
                if (achievementProgress >= achievementNextLevelData.Requirement)
                    achievementProgress = 0;

                // If is new Level
                if (fromZero)
                {
                    // Set Level
                    userAchievement.SetLevel(achievementNextLevel);

                    // Set Progress
                    userAchievement.SetProgress(achievementProgress);

                    // Give Reward Points
                    user.AchievementPoints += achievementNextLevelData.RewardPoints;
                    user.NotifyNewPixels(achievementNextLevelData.RewardPixels);
                    user.Duckets += achievementNextLevelData.RewardPixels;

                    // Update Points Balance
                    user.UpdateActivityPointsBalance();

                    // Remove old Badge - (Is not problem if is First Level Badge, because if the user hasn't the badg, simply, will not remove.
                    user.GetBadgeComponent()
                        .RemoveBadge(Convert.ToString($"{achievementGroup}{achievementNextLevel - 1}"), session);

                    // Give new Badge
                    user.GetBadgeComponent().GiveBadge($"{achievementGroup}{achievementNextLevel}", true, session);

                    // Update in Database
                    using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                        queryReactor.RunFastQuery(
                            $"REPLACE INTO users_achievements VALUES ('{user.Id}', '{achievementGroup}', '{achievementNextLevel}', '{achievementProgress}')");

                    // Send Unlocked Composer
                    session.SendMessage(AchievementUnlockedComposer.Compose(achievement, achievementNextLevel,
                        achievementNextLevelData.RewardPoints, achievementNextLevelData.RewardPixels));

                    // Send Score Composer
                    session.SendMessage(AchievementScoreUpdateComposer.Compose(user.AchievementPoints));

                    // Send Progress Composer
                    session.SendMessage(AchievementProgressComposer.Compose(achievement, achievementNextLevel,
                        achievementNextLevelData, achievementLevelsCount, userAchievement));

                    // Set Talent
                    if (
                        Yupi.GetGame()
                            .GetTalentManager()
                            .Talents.Values.Any(talent => talent.AchievementGroup == achievementGroup))
                        Yupi.GetGame()
                            .GetTalentManager()
                            .CompleteUserTalent(session,
                                Yupi.GetGame().GetTalentManager().GetTalentData(achievementGroup));
                }
                else
                {
                    // Get Current Level Data
                    AchievementLevel achievementCurrentLevelData = achievement.Levels[achievementCurrentLevel];

                    // It's the Same Level
                    userAchievement.SetLevel(achievementCurrentLevel);

                    // But increase Progress
                    userAchievement.SetProgress(achievementProgress);

                    // Update in Database
                    using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                        queryReactor.RunFastQuery(
                            $"REPLACE INTO users_achievements VALUES ('{user.Id}', '{achievementGroup}', '{achievementCurrentLevel}', '{achievementProgress}')");

                    // Compose Current Data
                    session.SendMessage(AchievementProgressComposer.Compose(achievement, achievementCurrentLevel,
                        achievementCurrentLevelData, achievementLevelsCount, userAchievement));
                }

                // Send User New Data
                GameClientMessageHandler messageHandler = session.GetMessageHandler();

                messageHandler.GetResponse().Init(LibraryParser.OutgoingRequest("UpdateUserDataMessageComposer"));
                messageHandler.GetResponse().AppendInteger(-1);
                messageHandler.GetResponse().AppendString(user.Look);
                messageHandler.GetResponse().AppendString(user.Gender.ToLower());
                messageHandler.GetResponse().AppendString(user.Motto);
                messageHandler.GetResponse().AppendInteger(user.AchievementPoints);

                messageHandler.SendResponse();

                return true;
            }

            return false;
        }
开发者ID:ImNotSatan,项目名称:Yupi,代码行数:101,代码来源:AchievementManager.cs

示例5: Execute

 public override bool Execute(GameClient session, string[] pms)
 {
     session.GetMessageHandler().Sit();
     return true;
 }
开发者ID:sgf,项目名称:Yupi,代码行数:5,代码来源:Sit.cs


注:本文中的Yupi.Game.GameClients.Interfaces.GameClient.GetMessageHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。