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


C# User.Send方法代码示例

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


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

示例1: ForceSynchronizeTo

 public virtual void ForceSynchronizeTo(User user)
 {
     using (var pw = ServerPacket.GetWriter())
     {
         ServerPacket.SetCharacterHPPercent(pw, _character.MapEntityIndex, _lastSentHPPercent);
         ServerPacket.SetCharacterMPPercent(pw, _character.MapEntityIndex, _lastSentMPPercent);
         user.Send(pw, ServerMessageType.MapCharacterSP);
     }
 }
开发者ID:mateuscezar,项目名称:netgore,代码行数:9,代码来源:CharacterSPSynchronizer.cs

示例2: RecoverLostTradeItems

        /// <summary>
        /// Recovers items from the <see cref="ActiveTradeItemTable"/> for a character, and gives them to the character. Items can
        /// get stuck in this table when the server unexpectedly shuts down during a peer trade session. Calling this method
        /// will attempt to give the <see cref="Character"/> any items they might have in this table. This cannot be done if the
        /// <paramref name="character"/> is currently trading.
        /// </summary>
        /// <param name="character">The <see cref="Character"/> to get the lost items for.</param>
        /// <param name="recovered">The number of items that were able to be given back to the <paramref name="character"/>.</param>
        /// <param name="remaining">The number of items still remaining in the table for the <paramref name="character"/>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="character"/> is null.</exception>
        public static void RecoverLostTradeItems(User character, out int recovered, out int remaining)
        {
            recovered = 0;

            if (character == null)
                throw new ArgumentNullException("character");

            // Make sure that we do not try executing this while they are trading! Doing so would be very, very ugly.
            if (character.IsPeerTrading)
            {
                const string errmsg = "Tried to recover lost trade items for `{0}` while they were trading. Very bad idea...";
                if (log.IsWarnEnabled)
                    log.WarnFormat(errmsg, character);
                remaining = 0;
                return;
            }

            // Get the list of lost items
            var lostItemIDs = _getLostItemsQuery.Execute(character.ID);

            // Check if there are even any items to recover
            remaining = lostItemIDs.Count();
            if (remaining == 0)
                return;

            // One by one, try to add the lost items back to the character
            foreach (var lostItemID in lostItemIDs)
            {
                // Create the item instance
                var lostItem = ItemEntity.LoadFromDatabase(lostItemID);

                // Remove the entry from the table containing the lost items
                _removeItemQuery.Execute(lostItemID);

                remaining--;

                // Make sure the item was valid (which it should always be unless something went horribly wrong)
                // We do NOT try to add it back again, since who knows what is wrong with the item... its just not worth risking
                if (lostItem == null)
                {
                    Debug.Fail("Why did we fail to load the item... from a RELATIONAL database!?");
                    continue;
                }

                recovered++;

                // Try to give the item to the character
                var lostItemRemainder = character.TryGiveItem(lostItem);

                // If there was a remainder when we tried to give the character the item, then we will have to put it back into the
                // database table so we can try to give it to them again another time.
                if (lostItemRemainder != null)
                {
                    _insertItemQuery.Execute(new PeerTradingInsertItemQuery.QueryArgs(lostItemRemainder.ID, character.ID));
                    remaining++;
                    break;
                }
            }

            // Notify the character about the items recovered and remaining
            if (remaining > 0)
                character.Send(GameMessage.PeerTradingItemsRecovered, ServerMessageType.GUI, recovered, remaining);
            else
                character.Send(GameMessage.PeerTradingItemsRecoveredNoRemaining, ServerMessageType.GUI, recovered);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:75,代码来源:PeerTradingHelper.cs

示例3: SendMapData

        /// <summary>
        /// Sends the data to the specified user of all existing content on the map.
        /// </summary>
        /// <param name="user">User to send the map data to.</param>
        void SendMapData(User user)
        {
            using (var pw = ServerPacket.GetWriter())
            {
                // Tell the user to change the map
                ServerPacket.SetMap(pw, ID);
                user.Send(pw, ServerMessageType.Map);

                // Send dynamic entities
                foreach (var dynamicEntity in DynamicEntities)
                {
                    pw.Reset();
                    ServerPacket.CreateDynamicEntity(pw, dynamicEntity);
                    user.Send(pw, ServerMessageType.Map);

                    // Perform special synchronizations for Characters
                    var character = dynamicEntity as Character;
                    if (character != null)
                    {
                        character.SynchronizeSPTo(user);
                        character.SynchronizePaperdollTo(user);
                    }
                }

                // Now that the user know about the Map and every Entity on it, tell them which one is theirs
                pw.Reset();
                ServerPacket.SetUserChar(pw, user.MapEntityIndex);
                user.Send(pw, ServerMessageType.Map);
            }
        }
开发者ID:wtfcolt,项目名称:game,代码行数:34,代码来源:Map.cs

示例4: Send

 /// <summary>
 /// 向某客户端发送信息
 /// </summary>
 /// <param name="toSend">欲接受信息的客户端</param>
 /// <param name="msg">欲发送的信息</param>
 /// <returns></returns>
 public bool Send(User toSend, string msg)
 {
     return toSend.Send(msg);
 }
开发者ID:LostTemple1990,项目名称:TouHouExploding,代码行数:10,代码来源:THEServer.cs


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