Exemple #1
0
        public override bool TakeAction()
        {
            PlayerMailLogic pm = new PlayerMailLogic();

            pm.SetUser(m_UserId);
            Dictionary <int, int> itemReward = new Dictionary <int, int>();
            PlayerLogic           p          = new PlayerLogic();

            p.SetUser(m_UserId);
            m_ResponsePacket.AllSuccessful = true;
            foreach (int id in m_RequestPacket.OpenEmailIds)
            {
                var reward = pm.OpenMail(id);
                if (reward == null)
                {
                    m_ResponsePacket.AllSuccessful = false;
                    continue;
                }
                else
                {
                    m_ResponsePacket.OpenedEmailIds.Add(id);
                }
                if (reward.Id < GameConsts.MinGearId)
                {
                    GetPlayerReward(reward, p);
                }
                else
                {
                    if (itemReward.ContainsKey(reward.Id))
                    {
                        itemReward[reward.Id] += reward.Count;
                    }
                    else
                    {
                        itemReward.Add(reward.Id, reward.Count);
                    }
                }
            }
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            PBReceivedItems receivedItems;

            pp.GetItems(itemReward, ReceiveItemMethodType.None, out receivedItems);
            m_ResponsePacket.ReceivedItems = receivedItems;
            m_ResponsePacket.PlayerInfo    = new PBPlayerInfo()
            {
                Id             = m_UserId,
                Coin           = p.MyPlayer.Coin,
                Money          = p.MyPlayer.Money,
                Energy         = p.MyPlayer.Energy,
                MeridianEnergy = p.MyPlayer.StarEnergy
            };
            return(true);
        }
 public void AddSoul(int soulId, int soulType)
 {
     if (m_Package.Souls.Count >= GameConfigs.GetInt("Inventory_Slots_Per_Tab", 200))
     {
         PlayerMailLogic pm = new PlayerMailLogic();
         pm.SetUser(m_UserId);
         pm.AddNewMail("package full", soulType, 1);
         pm.SendNotification();
     }
     m_Package.Souls.Add(soulId, soulType);
 }
 public void AddGear(int gear, int gearType)
 {
     if(m_Package.Gears.Count >= GameConfigs.GetInt("Inventory_Slots_Per_Tab", 200))
     {
         PlayerMailLogic pm = new PlayerMailLogic();
         pm.SetUser(m_UserId);
         pm.AddNewMail("package full", gearType, 1);
         pm.SendNotification();
     }
     m_Package.Gears.Add(gear, gearType);
 }
 public void AddEpigraph(int Type, int Level)
 {
     if (m_Package.Epigraphs.Count >= GameConfigs.GetInt("Inventory_Slots_Per_Tab", 200))
     {
         PlayerMailLogic pm = new PlayerMailLogic();
         pm.SetUser(m_UserId);
         pm.AddNewMail("package full", Type, 1);
         pm.SendNotification();
     }
     m_Package.Epigraphs.Add(Type, Level);
 }
 public void AddInventory(ItemListItem item)
 {
     if (m_Package.Inventories.ContainsKey(item.Id))
     {
         m_Package.Inventories[item.Id] += item.Count;
         if (m_Package.Inventories[item.Id] > GameConfigs.GetInt("Inventory_Item_Max_Count", 9999))
         {
             int count = m_Package.Inventories[item.Id] - GameConfigs.GetInt("Inventory_Item_Max_Count", 9999);
             m_Package.Inventories[item.Id] = GameConfigs.GetInt("Inventory_Item_Max_Count", 9999);
             PlayerMailLogic pm = new PlayerMailLogic();
             pm.SetUser(m_UserId);
             pm.AddNewMail("package full", item.Id, item.Count);
             pm.SendNotification();
         }
     }
     else
     {
         m_Package.Inventories.Add(item.Id, item.Count);
     }
 }
Exemple #6
0
        public override bool TakeAction()
        {
            PlayerMailLogic pm = new PlayerMailLogic();

            pm.SetUser(m_UserId);
            var mails = pm.GetMails();

            foreach (var mail in mails)
            {
                m_ResponsePacket.EmailList.Add(new PBEmailInfo()
                {
                    Id         = mail.Key,
                    Message    = mail.Value.Message,
                    ItemType   = mail.Value.AttachedId,
                    ItemCount  = mail.Value.AttachedCount,
                    ExpireTime = mail.Value.ExpireTime,
                    SendTime   = mail.Value.StartTime,
                });
            }
            return(true);
        }