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


C# PlayerBussiness.AddFriends方法代码示例

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


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

示例1: HandlePacket

        //0友好,1黑名单
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            GSPacketIn pkg = packet.Clone();
            pkg.ClearContext();

            string nickName = packet.ReadString();
            int relation = packet.ReadInt();
            if (relation < 0 || relation > 1)
                return 1;

            using (PlayerBussiness db = new PlayerBussiness())
            {
                PlayerInfo user = null;
                GamePlayer player = Managers.WorldMgr.GetClientByPlayerNickName(nickName);
                if (player != null)
                    user = player.PlayerCharacter;
                else
                    user = db.GetUserSingleByNickName(nickName);
                if (!string.IsNullOrEmpty(nickName) && user != null)
                {
                    if (!client.Player.Friends.ContainsKey(user.ID) || client.Player.Friends[user.ID] != relation)
                    {
                        FriendInfo friend = new FriendInfo();
                        friend.FriendID = user.ID;
                        friend.IsExist = true;
                        friend.Remark = "";
                        friend.UserID = client.Player.PlayerCharacter.ID;
                        friend.Relation = relation;
                        if (db.AddFriends(friend))
                        {
                            client.Player.FriendsAdd(user.ID, relation);
                            pkg.WriteInt(user.ID);
                            pkg.WriteString(user.NickName);
                            pkg.WriteBoolean(user.Sex);
                            pkg.WriteString(user.Style);
                            pkg.WriteString(user.Colors);
                            pkg.WriteString(user.Skin);
                            pkg.WriteInt(user.State == 1 ? 1 : 0);
                            pkg.WriteInt(user.Grade);
                            pkg.WriteInt(user.Hide);
                            pkg.WriteString(user.ConsortiaName);
                            pkg.WriteInt(user.Total);
                            pkg.WriteInt(user.Escape);
                            pkg.WriteInt(user.Win);
                            pkg.WriteInt(user.Offer);
                            pkg.WriteInt(user.Repute);
                            pkg.WriteInt(relation);
                            pkg.WriteString(user.UserName);
                            pkg.WriteInt(user.Nimbus);
                            pkg.WriteInt(user.FightPower);
                            pkg.WriteInt(500);
                            pkg.WriteString("Honor");
                            if (relation != 1 && user.State != 0)
                            {
                                GSPacketIn response = new GSPacketIn((byte)ePackageType.FRIEND_RESPONSE, client.Player.PlayerCharacter.ID);
                                response.WriteInt(user.ID);
                                response.WriteString(client.Player.PlayerCharacter.NickName);
                                if (player != null)
                                    player.Out.SendTCP(response);
                                else
                                    GameServer.Instance.LoginServer.SendPacket(response);
                            }
                            client.Out.SendTCP(pkg);
                        }
                    }
                    else
                    {
                        client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("FriendAddHandler.Falied"));
                    }
                }
                else
                {
                    client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("FriendAddHandler.Success"));
                }
            }
            return 0;
        }
开发者ID:geniushuai,项目名称:DDTank-3.0,代码行数:78,代码来源:FriendAddHandler.cs


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