Exemple #1
0
        private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); //

        #endregion

        #region 初始化

        public void InitByBase(GroupShopOne _this, GroupShopRecord tbTable)
        {
            _this.mDbData = new DBGroupShopOne();
            if (_this.mDbData.ItemData == null)
            {
                _this.mDbData.ItemData = new ItemBaseData();
            }
            _this.tbGroupShop         = tbTable;
            _this.mDbData.GroupShopId = tbTable.Id;
            _this.OverTime            = DateTime.Now.AddHours(tbTable.ExistTime);
            var items = new Dictionary <int, int>();

            ShareDrop.DropMother(tbTable.MotherID, items);
            var itemsCount = items.Count;

            if (itemsCount < 1)
            {
                ShareItemFactory.Create(22000, _this.mDbData.ItemData);
            }
            else
            {
                var itemT = items.First();
                var item  = ShareItemFactory.Create(itemT.Key, _this.mDbData.ItemData);
                item.SetCount(itemT.Value);
                if (itemsCount > 1)
                {
                    Logger.Warn("GroupShopOne InitByBase itemsCount ={0} GroupShopRecord={1}", itemsCount, tbTable.Id);
                }
            }
            _this.overTrigger = TeamServerControl.tm.CreateTrigger(_this.OverTime, () => TimeOver(_this));
        }
Exemple #2
0
        private void Reset(GroupShopOne _this)
        {
            if (_this.overTrigger != null)
            {
                TeamServerControl.tm.DeleteTrigger(_this.overTrigger);
                _this.overTrigger = null;
            }
            var guid = GroupShop.GetNextGuid();

            GroupShop.ResetShopItem(_this, guid);
            var items = new Dictionary <int, int>();

            ShareDrop.DropMother(_this.tbGroupShop.MotherID, items);
            var itemsCount = items.Count;

            if (itemsCount < 1)
            {
                ShareItemFactory.Create(22000, _this.mDbData.ItemData);
            }
            else
            {
                var itemT = items.First();
                var item  = ShareItemFactory.Create(itemT.Key, _this.mDbData.ItemData);
                item.SetCount(itemT.Value);
                if (itemsCount > 1)
                {
                    Logger.Warn("GroupShopOne InitByBase itemsCount ={0} GroupShopRecord={1}", itemsCount,
                                _this.tbGroupShop.Id);
                }
            }
            _this.OverTime    = DateTime.Now.AddHours(_this.tbGroupShop.ExistTime);
            _this.overTrigger = TeamServerControl.tm.CreateTrigger(_this.OverTime, () => TimeOver(_this));
        }
Exemple #3
0
        //通知玩家被谁杀死
        public void PushMail(MailManager _this, int tableId, int ExtendType, string ExtendPara0, string ExtendPara1)
        {
            var tbMail = Table.GetMail(tableId);

            if (tbMail == null)
            {
                Logger.Fatal("null==Table.GetMail({0})", tableId);
                return;
            }
            //  if (tbMail.Flag < 0)
            //  {
            //      PlayerLog.WriteLog((int)LogType.MailConfigError, "PushMail tbMail[{0}] Flag is -1", tbMail.Id);
            //       return;
            //  }
            // if (_this.mCharacter.GetFlag(tbMail.Flag))
            //  {
            //     return;
            //  }
            if (_this.mCharacter.CheckCondition(tbMail.Condition) != -2)
            {
                return;
            }
            var nextId   = _this.GetNextId();
            var tempmail = new Mail(_this.mCharacter, nextId);

            tempmail.Name        = tbMail.Title;
            tempmail.Text        = tbMail.Text;
            tempmail.Send        = tbMail.Sender;
            tempmail.ExtendType  = ExtendType;
            tempmail.ExtendPara0 = ExtendPara0;
            tempmail.ExtendPara1 = ExtendPara1;

            for (var i = 0; i != 5; ++i)
            {
                if (tbMail.ItemId[i] < 0)
                {
                    continue;
                }
                if (tbMail.ItemCount[i] < 1)
                {
                    continue;
                }
                var itemDb = new ItemBaseData();
                ShareItemFactory.Create(tbMail.ItemId[i], itemDb);
                itemDb.Count = tbMail.ItemCount[i];
                tempmail.Reward.Add(itemDb);
                //tempmail.Reward.Add(tbMail.ItemId[i],tbMail.ItemCount[i]);
            }
            tempmail.OverTime = DateTime.Now.AddDays(15).ToBinary();
            _this.Mails.Add(tempmail.Guid, tempmail);
            _this.AddChild(tempmail);
            _this.mDbData.mData.Add(tempmail.mDbData);
            tempmail.MarkDirty();
            //  _this.mCharacter.SetFlag(tbMail.Flag);
        }
        public ShareItem Create(int blobId)
        {
            if (!DoesBlobIdExists(blobId))
            {
                return(null);
            }
            ShareItem s = ShareItemFactory.Create(CreateId(), blobId);

            _context.ShareItems.Add(s);
            _context.SaveChanges();
            return(s);
        }
Exemple #5
0
        //分发邮件
        private Mail PushMail(MailManager _this,
                              string name,
                              string text,
                              List <KeyValuePair <int, int> > reward,
                              string sender             = "",
                              List <ItemBaseData> datas = null, int type = 0)
        {
            if (_this.Mails.Count >= StaticParam.MaxMailCount)
            {
                var minMail = GetTimeMin(_this);
                if (minMail == null)
                {
                    return(null);
                }
                minMail.Name      = name;
                minMail.Text      = text;
                minMail.Send      = sender;
                minMail.StartTime = DateTime.Now.ToBinary();
                minMail.OverTime  = DateTime.Now.AddDays(15).ToBinary();
                minMail.State     = 0;
                minMail.Type      = type;
                if (reward == null)
                {
                    minMail.Reward.Clear();
                }
                else
                {
                    minMail.Reward.Clear();
                    foreach (var i in reward)
                    {
                        var itemDb = new ItemBaseData();
                        ShareItemFactory.Create(i.Key, itemDb);
                        itemDb.Count = i.Value;
                        minMail.Reward.Add(itemDb);
                        if (datas != null)
                        {
                            datas.Add(itemDb);
                        }
                    }
                    //foreach (KeyValuePair<int, int> i in reward)
                    //{
                    //    ItemBaseData itemDb = new ItemBaseData();
                    //    ItemFactory.Create(i.Key, itemDb);
                    //    itemDb.Count = i.Value;
                    //    minMail.Reward.Clear();
                    //    minMail.Reward.Add(itemDb);
                    //}
                }
                minMail.MarkDirty();
                return(minMail);
            }
            var nextId   = _this.GetNextId();
            var tempmail = new Mail(_this.mCharacter, nextId);

            tempmail.Name = name;
            tempmail.Send = sender;
            tempmail.Text = text;
            tempmail.Type = type;
            if (reward != null)
            {
                foreach (var i in reward)
                {
                    var itemDb = new ItemBaseData();
                    ShareItemFactory.Create(i.Key, itemDb);
                    itemDb.Count = i.Value;
                    tempmail.Reward.Add(itemDb);
                    if (datas != null)
                    {
                        datas.Add(itemDb);
                    }
                }
                //foreach (KeyValuePair<int, int> i in reward)
                //{
                //    ItemBaseData itemDb = new ItemBaseData();
                //    ItemFactory.Create(i.Key, itemDb);
                //    itemDb.Count = i.Value;
                //    tempmail.Reward.Add(itemDb);
                //    if (datas != null)
                //    {
                //        datas.Add(itemDb);
                //    }
                //}
            }
            tempmail.OverTime = DateTime.Now.AddDays(15).ToBinary();
            //tempmail.OverTime = DateTime.Now.AddHours(15).ToBinary();
            _this.Mails.Add(tempmail.Guid, tempmail);
            _this.AddChild(tempmail);
            _this.mDbData.mData.Add(tempmail.mDbData);
            tempmail.MarkDirty();
            return(tempmail);
        }