Пример #1
0
 public void Handle(BinaryReader reader, int playerNumber)
 {
     // 如果在服务器端
     if (Main.netMode == 2)
     {
         var  id      = reader.ReadUInt64();
         var  slotid  = reader.ReadByte();
         var  player  = Main.player[playerNumber].GetServerPlayer();
         var  mailist = player.MailList;
         Mail target  = null;
         foreach (var mail in mailist)
         {
             if (mail.MailHead.MailID == id)
             {
                 target = mail;
                 break;
             }
         }
         if (target == null)
         {
             player.SendMessageBox("这个邮件不存在", 180, Color.Yellow);
             return;
         }
         target.AttachedItems[slotid] = ItemInfo.Create();
         return;
     }
 }
Пример #2
0
 public void ServerSendMail(ServerPlayer target, string title, string content, List <Item> items, int gucoin = 0)
 {
     if (Main.netMode == 2)
     {
         Mail mail = new Mail
         {
             MailHead = MailHead.GenerateHead(title, "<系统>", target.Name),
             Content  = content
         };
         foreach (var item in items)
         {
             var info = ItemInfo.Create();
             info.FromItem(item);
             mail.AttachedItems.Add(info);
         }
         mail.AttachedGuCoin = gucoin;
         lock (target.MailList)
         {
             MailList.Add(mail.MailHead.MailID, mail);
             target.MailList.Add(mail);
             if (target.MailList.Count > ServerSideCharacter2.Config.MaxMailsPerPlayer)
             {
                 MailList.Remove(target.MailList.ElementAt(0).MailHead.MailID);
                 target.MailList.RemoveAt(0);
             }
         }
         target.SendMailList();
     }
 }
Пример #3
0
        public static void CopyToItemData(Item[] src, ItemInfo[] dest)
        {
            var size = src.Length;

            for (var i = 0; i < size; i++)
            {
                dest[i] = ItemInfo.Create();
                dest[i].FromItem(src[i]);
            }
        }
        private void InternalShowItem(int itemId, string itemAssetName, ItemGroup itemGroup, object itemInstance, bool isNewInstance, float duration, object userData)
        {
            try
            {
                IItem item = m_ItemHelper.CreateItem(itemInstance, itemGroup, userData);
                if (item == null)
                {
                    throw new GameFrameworkException("Can not create item in helper.");
                }

                ItemInfo itemInfo = ItemInfo.Create(item);
                m_ItemInfos.Add(itemId, itemInfo);
                itemInfo.Status = ItemStatus.WillInit;
                item.OnInit(itemId, itemAssetName, itemGroup, isNewInstance, userData);
                itemInfo.Status = ItemStatus.Inited;
                itemGroup.AddItem(item);
                itemInfo.Status = ItemStatus.WillShow;
                item.OnShow(userData);
                itemInfo.Status = ItemStatus.Showed;

                if (m_ShowItemSuccessEventHandler != null)
                {
                    ShowItemSuccessEventArgs showItemSuccessEventArgs = ShowItemSuccessEventArgs.Create(item, duration, userData);
                    m_ShowItemSuccessEventHandler(this, showItemSuccessEventArgs);
                    ReferencePool.Release(showItemSuccessEventArgs);
                }
            }
            catch (Exception exception)
            {
                if (m_ShowItemFailureEventHandler != null)
                {
                    ShowItemFailureEventArgs showItemFailureEventArgs = ShowItemFailureEventArgs.Create(itemId, itemAssetName, itemGroup.Name, exception.ToString(), userData);
                    m_ShowItemFailureEventHandler(this, showItemFailureEventArgs);
                    ReferencePool.Release(showItemFailureEventArgs);
                    return;
                }

                throw;
            }
        }