Beispiel #1
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);
        }
Beispiel #2
0
        //接收邮件
        public Mail PushMail(MailManager _this, string name, string text, List <ItemBaseData> datas, int type, string sender)
        {
            if (_this.Mails.Count >= StaticParam.MaxMailCount)
            {
                var minMail = GetTimeMin(_this);
                if (minMail == null)
                {
                    return(null);
                }
                minMail.Name      = name;
                minMail.Text      = text;
                minMail.StartTime = DateTime.Now.ToBinary();
                minMail.OverTime  = DateTime.Now.AddDays(15).ToBinary();
                minMail.State     = 0;
                minMail.Type      = type;
                minMail.Send      = sender;
                if (datas == null)
                {
                    minMail.Reward.Clear();
                }
                else
                {
                    minMail.Reward.Clear();
                    foreach (var data in datas)
                    {
                        minMail.Reward.Add(data);
                    }
                }
                minMail.MarkDirty();
                return(minMail);
            }
            var nextId   = _this.GetNextId();
            var tempmail = new Mail(_this.mCharacter, nextId);

            tempmail.Name = name;
            tempmail.Text = text;
            tempmail.Type = type;
            foreach (var data in datas)
            {
                tempmail.Reward.Add(data);
            }
            tempmail.OverTime = DateTime.Now.AddDays(15).ToBinary();
            _this.Mails.Add(tempmail.Guid, tempmail);
            _this.AddChild(tempmail);
            _this.mDbData.mData.Add(tempmail.mDbData);
            tempmail.MarkDirty();
            return(tempmail);
        }
Beispiel #3
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);
        }