本文整理汇总了C#中System.Variant.SetOrInc方法的典型用法代码示例。如果您正苦于以下问题:C# Variant.SetOrInc方法的具体用法?C# Variant.SetOrInc怎么用?C# Variant.SetOrInc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Variant
的用法示例。
在下文中一共展示了Variant.SetOrInc方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TaskType
/// <summary>
/// 记录不同任务类型每天完成情况
/// </summary>
/// <param name="pb">任务id</param>
/// <param name="tasktype">任务类型</param>
private static void TaskType(PlayerBusiness pb, string tasktype)
{
PlayerEx fx = pb.TaskDay;
Variant v = fx.Value;
if (v == null)
{
fx.Value = new Variant();
v = fx.Value;
}
DateTime dt = DateTime.Now;
//保留7天记录
int delKey = Convert.ToInt32(dt.AddDays(-10).Date.ToString("yyyyMMdd"));
//需要移除的Key
List<string> keys = new List<string>();
foreach (var item in v)
{
if (Convert.ToInt32(item.Key) < delKey)
{
keys.Add(item.Key);
}
}
if (keys.Count > 0)
{
foreach (string k in keys)
{
v.Remove(k);
}
}
string day = dt.Date.ToString("yyyyMMdd");
Variant info;
if (v.TryGetValueT(day, out info))
{
info.SetOrInc(tasktype, 1);
}
else
{
info = new Variant();
info.SetOrInc(tasktype, 1);
v.Add(day, info);
}
fx.Save();
pb.Call(ClientCommand.UpdateActorR, new PlayerExDetail(fx));
}
示例2: AddStar
/// <summary>
/// 星座加成
/// </summary>
private void AddStar(PlayerProperty p)
{
if (Star == null || Star.Value == null)
return;
GameConfig gc = GameConfigAccess.Instance.FindOneById("ST_00001");
if (gc == null)
return;
Variant life = new Variant();
for (int j = 1; j < 13; j++)
{
IList o = Star.Value.GetValue<IList>(j.ToString());
if (o == null)
continue;
//得到某个星座配置
Variant v = gc.Value.GetVariantOrDefault(j.ToString());
if (v == null)
continue;
//得到要加的属性
string name = v.GetStringOrDefault("Name");
double num = 0;
Variant c = v.GetVariantOrDefault("B");
if (c != null)
{
foreach (int i in o)
{
//num += PartAccess.Instance.StarForm(c.GetDoubleOrDefault("A"), i + 1, c.GetIntOrDefault("B"), c.GetDoubleOrDefault("C"));
//num * Math.Pow(v.GetDoubleOrDefault("A"), n * (n - 1) / 2)
//星阵属性加成
double b = c.GetDoubleOrDefault("B");
double a = c.GetDoubleOrDefault("A");
double n = (i + 1) * i / 2;
num += Convert.ToInt32(b * Math.Pow(a, n));
}
}
if (o.Count == 14)
{
//激活所有的守护星额外加成
Variant other = v.GetVariantOrDefault("Life");
if (other != null)
{
foreach (var k in other)
{
life.SetOrInc(k.Key, Convert.ToDouble(k.Value));
}
}
}
if (name == "BaoJiShangHai")
{
num = num / 100;
}
life.SetOrInc(name, num);
}
p.Add(life);
}
示例3: HomeProduce
//.........这里部分代码省略.........
IList r = v.GetValue<IList>("ProduceList");
if (r.Count > 0)
{
for (int i = r.Count - 1; i >=0; i--)
{
DateTime t = ((DateTime)r[i]).ToUniversalTime();
if (t < dt)
{
//移除过期对列
r.Remove(r[i]);
}
}
}
if (r.Count >= produce)
{
note.Call(HomeCommand.HomeProduceR, false, TipManager.GetMessage(HomeReturn.HomeProduce2));
return;
}
}
int totaltime = producetime * number;
if (v.ContainsKey("ProduceList"))
{
IList pl = v.GetValue<IList>("ProduceList");
pl.Add(dt.AddSeconds(totaltime));
}
else
{
v.Add("ProduceList", new List<DateTime>() { dt.AddSeconds(totaltime) });
}
int b = 0;
BurdenManager.Remove(b0, goods, out b);
Variant us = new Variant();
foreach (var item in goods)
{
us.SetOrInc(item.Key,Convert.ToInt32(item.Value));
//生产消耗
note.Player.AddLog(Actiontype.GoodsUse, item.Key, Convert.ToInt32(item.Value), GoodsSource.HomeProduce, goodsid, number);
note.Player.UpdateTaskGoods(item.Key);
}
//判断以前是否正在生产
//string gid = v.GetStringOrDefault("GoodsID");
//int num = v.GetIntOrDefault("Number");
//if (num > 0)
//{
// GameConfig gcm = GameConfigAccess.Instance.FindOneById(gid);
// if (gcm != null)
// {
// string title = TipManager.GetMessage(HomeReturn.HomeProduce3);
// string content = string.Format(TipManager.GetMessage(HomeReturn.HomeProduce4), gcm.Name, num);
// Variant gs = new Variant();
// gs.Add("G", gcm.ID);
// gs.Add("A", num);
// gs.Add("E", gcm.ID);
// gs.Add("H", v.GetIntOrDefault("IsBinding"));
// List<Variant> goodsList = new List<Variant>();
// if (number > 0)
// {
// goodsList.Add(gs);
// }
// else
// {
// goodsList = null;
// }
// int reTime = Convert.ToInt32(TipManager.GetMessage(EmailReturn.HameDay));
// if (EmailAccess.Instance.SendEmail(title, TipManager.GetMessage(PetsReturn.StealPet12), note.PlayerID, note.Player.Name, content, string.Empty, goodsList, reTime))
// {
// note.Call(EmailCommand.NewEmailTotalR, EmailAccess.Instance.NewTotal(note.PlayerID));
// }
// v["GoodsID"] = "";
// v["Number"] = 0;
// }
//}
Variant gs1 = new Variant();
if (home.Save())
{
gs1[goodsid] = number;
note.Player.AddGoods(info, GoodsSource.HomeProduce);
Variant tmp = new Variant();
tmp.Add(subType, v);
note.Call(HomeCommand.HomeProduceR, true, tmp);
Variant os=new Variant();
os["TotalTime"] = totaltime;
note.Player.AddLogVariant(Actiontype.HomeProduce, us, gs1, os);
}
else
{
note.Call(HomeCommand.HomeProduceR, false, "");
}
}
finally
{
m_dic.TryRemove(soleid, out soleid);
}
}
示例4: Award
//.........这里部分代码省略.........
bool noGoods = false;//非道具的情况
///宠物
Dictionary<string, int> pets = new Dictionary<string, int>();
Dictionary<string, Variant> dic = new Dictionary<string, Variant>();
foreach (Variant fix in fixAward)
{
if (fix.GetStringOrDefault("Type") != "20002")
{
noGoods = true;
continue;
}
string goodsid = fix.GetStringOrDefault("GoodsID");
int count = fix.GetIntOrDefault("Count");
if (fix.GetStringOrDefault("GoodsType") == "112009")
{
if (!pets.ContainsKey(goodsid))
{
pets.Add(goodsid, count);
}
else
{
pets[goodsid] += count;
}
continue;
}
Variant tmp;
if (dic.TryGetValue(goodsid, out tmp))
{
tmp.SetOrInc("Number1", count);
}
else
{
tmp = new Variant();
tmp.Add("Number1", count);
GameConfig gc1 = GameConfigAccess.Instance.FindOneById(goodsid);
if (gc1 == null)
continue;
GoodsAccess.Instance.TimeLines(gc1, tmp);
dic.Add(goodsid, tmp);
}
}
if (dic.Count > 0)
{
if (BurdenManager.IsFullBurden(burden, dic))
{
note.Call(TaskCommand.AwardR, false, null, TipManager.GetMessage(TaskReturn.BurdenFull));
return;
}
}
#endregion
#region 任务奖励处理
task.Value["Status"] = 3;
if (!task.Save())
return;
//领奖成功
note.Call(TaskCommand.AwardR, true, null, task.ID);
int tasktype = task.Value.GetIntOrDefault("TaskType");
示例5: Fuse
//.........这里部分代码省略.........
//判断目标道具是否为绑定状态
isBinding = 1;
}
total += con.GetIntOrDefault("A");
}
}
if (total < numCount)
{
note.Call(FuseCommand.FuseR, false, TipManager.GetMessage(FuseReturn.FuseLessNo));
return;
}
}
#endregion
if (note.Player.Score < score || (!note.Player.AddScore(-score, FinanceType.Fuse)))
{
note.Call(FuseCommand.FuseR, false, TipManager.GetMessage(FuseReturn.FuseScore));
return;
}
#region 得到当前成功率
double lv = gc.Value.GetDoubleOrDefault("ChengGongLv");
if (upCount != 0)
{
lv = lv + GoodsAccess.Instance.GetSuccess(upCount);
}
int ml = note.Player.MLevel;
Variant mv = MemberAccess.MemberInfo(ml);
if (mv != null)
{
lv *= (1 + mv.GetDoubleOrDefault("FuseLv"));
}
//表示成功
bool isSuccess = NumberRandom.RandomHit(lv);
#endregion
//消耗道具数量
Variant us = new Variant();
#region 移除道具
foreach (Variant d in mixNeed)
{
int count = d.GetIntOrDefault("Number") * number;
string gid = d.GetStringOrDefault("GoodsID");
if (!note.Player.RemoveGoods(gid, count,GoodsSource.Fuse))
{
note.Call(FuseCommand.FuseR, false, TipManager.GetMessage(FuseReturn.FuseLessNo));
return;
}
us.SetOrInc(gid, count);
}
#endregion
if (upCount > 0)
{
if (!note.Player.RemoveGoods(upid, upCount,GoodsSource.Fuse))
{
note.Call(FuseCommand.FuseR, false, TipManager.GetMessage(FuseReturn.FuseGoodsLv));
return;
}
us.SetOrInc(upid, upCount);
}
//取得的物品
Variant gs = new Variant();
if (isSuccess)
{
Variant doc = new Variant();
doc.Add("Number" + isBinding, number);
Dictionary<string, Variant> goods = new Dictionary<string, Variant>();
goods.Add(fuseGC.ID, doc);
note.Player.AddGoods(goods, GoodsSource.Fuse);
gs.SetOrInc(fuseGC.ID, number);
}
note.Player.UpdateBurden();
if (isSuccess)
{
note.Player.FinishNote(FinishCommand.HeChen, 1);
string str = string.Format(TipManager.GetMessage(FuseReturn.FuseSuccess), fuseGC.Name, number);
note.Call(FuseCommand.FuseR, true, str);
}
else
{
note.Call(FuseCommand.FuseR, false, TipManager.GetMessage(FuseReturn.FuseFail));
}
Variant os = new Variant();
os["IsSuccess"] = isSuccess;
os["Lv"] = lv;
os["Score"] = -score;
note.Player.AddLogVariant(Actiontype.Fuse, us, gs, os);
}
示例6: TaskAward20001
/// <summary>
/// 奖励类型[经验,晶币,游戏币]
/// </summary>
/// <param name="note"></param>
/// <param name="award">奖励</param>
/// <param name="isdouble">该是否可以任务</param>
public static Variant TaskAward20001(UserNote note, IList award, bool isdouble = false)
{
bool isp = false;//是否双倍
PlayerEx assist = note.Player.Assist;
Variant avs = assist.Value;
//表示双倍日常任务经验
if (isdouble)
{
if (avs.ContainsKey("TSP"))
{
int tsp = avs.GetIntOrDefault("TSP");
if (tsp > 1)
{
avs["TSP"] = tsp - 1;
}
else
{
avs.Remove("TSP");
}
assist.Save();
isp = true;
note.Call(ClientCommand.UpdateActorR, new PlayerExDetail(assist));
}
}
Variant os = new Variant();
bool isfamily = false;
foreach (Variant d in award)
{
if (d.GetStringOrDefault("Type") == "20001")
{
string name = d.GetStringOrDefault("Name");
int count = d.GetIntOrDefault("Count");
switch (name)
{
case "Experience":
count = isp ? count * 2 : count;
note.Player.AddExperience(count, FinanceType.Task);
break;
case "PetExperience":
count = isp ? count * 2 : count;
Pet p = note.Player.Pet;
if (p != null)
{
note.Player.AddPetExp(note.Player.Pet, count, true, (int)FinanceType.Task);
}
if (note.Player.Mounts != null)
{
note.Player.AddMounts(count, GoodsSource.TaskAward);
}
break;
case "Bond":
note.Player.AddBond(count, FinanceType.Task);
break;
case "Score":
note.Player.AddScore(count, FinanceType.Task);
break;
case "Dev":
isfamily = Dev(note.Player, count);
break;
}
if (name == "Dev")
{
if (isfamily)
{
os.SetOrInc(name, count);
}
}
else
{
os.SetOrInc(name, count);
}
}
}
return os;
}
示例7: SendEmail
/// <summary>
/// 发送邮件
/// </summary>
/// <param name="note"></param>
public static void SendEmail(UserNote note)
{
Variant d = note.GetVariant(0);
//标题
string title = d.GetStringOrDefault("mailtitle");
if (title.Length > 20)
{
note.Call(EmailCommand.SendEmailR, false, TipManager.GetMessage(EmailReturn.EmailTitalLength));
return;
}
if (d.GetStringOrEmpty("mailMess").Length > 300)
{
note.Call(EmailCommand.SendEmailR, false, TipManager.GetMessage(EmailReturn.EmailContent));
return;
}
//mailMess
IList goodsList = d.GetValue<IList>("goodsList");
int fee = 5;//要扣除的邮费
int score = 0;
if (d.ContainsKey("moneyGoods"))
{
Variant mg = d.GetVariantOrDefault("moneyGoods");
score = mg.GetIntOrDefault("Score");
if (mg != null)
{
fee += Convert.ToInt32(Math.Ceiling(score * 0.01));
}
}
if (goodsList.Count > 0)
{
fee += goodsList.Count * 10;
}
//发送物品物数量
if (note.Player.Score < (fee + score))
{
//游戏币不足
note.Call(EmailCommand.SendEmailR, false, TipManager.GetMessage(EmailReturn.NoScore));
return;
}
PlayerEx b0 = note.Player.B0;
IList c = b0.Value.GetValue<IList>("C");
if (!IsCheck(note.Player, goodsList, c))
return;
string name = d.GetStringOrDefault("playerName");
if (note.Player.Name == name)
{
note.Call(EmailCommand.SendEmailR, false, TipManager.GetMessage(EmailReturn.NoSelf));
return;
}
PlayerBusiness pb = PlayersProxy.FindPlayerByName(name);
if (pb == null)
{
note.Call(EmailCommand.SendEmailR, false, TipManager.GetMessage(EmailReturn.NoExists));
return;
}
if (!note.Player.AddScore(-(fee + score), FinanceType.EmailFee, string.Format("{0},{1},{2}", fee, score, pb.ID)))
{
note.Call(EmailCommand.SendEmailR, false, TipManager.GetMessage(EmailReturn.NoScore));
return;
}
Variant dic = new Variant();
//bool isChange = false;
foreach (Variant gs in goodsList)
{
foreach (Variant con in c)
{
if (con.GetIntOrDefault("P") != gs.GetIntOrDefault("P"))
continue;
//如果道具非绑定不能发送
string goodsid = con.GetStringOrDefault("G");
int num = con.GetIntOrDefault("A");
BurdenManager.BurdenClear(con);
note.Player.UpdateTaskGoods(goodsid);
//记录邮寄道具情况
dic.SetOrInc(goodsid, num);
}
}
string mid = "";
if (b0.Save())
{
Email model = new Email();
model.ID = ObjectId.GenerateNewId().ToString();
model.Name = string.IsNullOrEmpty(title) ? string.Format(TipManager.GetMessage(EmailReturn.SendEmail1), note.Player.Name) : title;
model.Status = 0;
model.Ver = 1;
//.........这里部分代码省略.........
示例8: GetEmailGoods
//.........这里部分代码省略.........
if (goodslist.Count > count)
{
note.Call(EmailCommand.ExtractGoodsR, false, TipManager.GetMessage(EmailReturn.BurdenFull));
return;
}
}
model.Status = 2;
if (model.Save())
{
int score = v.GetIntOrDefault("Score");
if (score > 0)
{
note.Player.AddScore(score, FinanceType.ExtractGoods);
}
if (goodslist != null)
{
Dictionary<string, Variant> dic = new Dictionary<string, Variant>();
foreach (Variant item in goodslist)
{
string gid = item.GetStringOrDefault("SoleID");
if (gid != item.GetStringOrDefault("GoodsID"))
{
Goods g = GoodsAccess.Instance.FindOneById(item.GetStringOrDefault("SoleID"));
if (g == null)
continue;
g.PlayerID = note.PlayerID;
if (!g.Save())
continue;
Variant gv = g.Value;
Variant m = BurdenManager.GetBurdenSpace(c);
if (m == null)
continue;
m["E"] = g.ID;
m["G"] = g.GoodsID;
m["A"] = 1;//只能一件物品
m["S"] = gv.GetIntOrDefault("Sort");
m["H"] = 0;
m["D"] = 0;
m["T"] = null;
//任务更新
note.Player.UpdateTaskGoods(g.GoodsID);
//邮件日志
PlayerLog log = new PlayerLog(ServerLogger.zoneid, Actiontype.AddGoods);
log.itemcnt = 1;
log.itemtype = g.GoodsID;
log.reserve_1 = (int)GoodsSource.ExtractGoods;
log.remark = emailid;
note.Player.WriteLog(log);
}
else
{
GameConfig gc = GameConfigAccess.Instance.FindOneById(gid);
if (gc == null)
continue;
int num = item.GetIntOrDefault("Number");
int h = item.GetIntOrDefault("H");
h = h > 0 ? 1 : 0;
Variant tmp;
if (dic.TryGetValue(gid, out tmp))
{
tmp.SetOrInc("Number" + h, num);
}
else
{
tmp = new Variant();
tmp.SetOrInc("Number" + h, num);
dic.Add(gid, tmp);
}
}
}
//判断邮件状态
if (model.Ver == 10)
{
BurdenManager.BurdenBatchInsert(note.Player.B0, dic);
model.Ver = 5;
model.Save();
}
else
{
note.Player.AddGoods(dic, GoodsSource.ExtractGoods, emailid);
}
}
note.Call(EmailCommand.ExtractGoodsR, true, emailid);
if (goodslist != null && goodslist.Count > 0)
{
note.Player.UpdateBurden();
}
}
}
finally
{
m_dic.TryRemove(soleid, out soleid);
}
}
示例9: StartStarShared
/// <summary>
/// 暴星分享
/// </summary>
/// <param name="note"></param>
public static void StartStarShared(UserNote note)
{
string share = note.PlayerID + "Share";
try
{
if (!m_dic.ContainsKey(share))
return;
string m = "";
//暴星
IList o = note.GetValue<IList>(0);
int power = note.GetInt32(1);
if (m_dic.TryGetValue(share, out m))
{
int n=0;
if (int.TryParse(m, out n))
{
if (power > n)
{
power = n;
}
}
}
power = power > 30000 ? 30000 : power;
int exp = 10 * power + 1000;
List<string> shareList = new List<string>();
foreach (string id in o)
{
PlayerBusiness pb = PlayersProxy.FindPlayerByID(id);
if (pb.SceneID != note.Player.SceneID)
continue;
if (note.Player.AState == ActionState.Fight)
continue;
PlayerEx star = pb.Star;
Variant v = star.Value;
Variant tmp;
if (v.TryGetValue("Share", out tmp))
{
//分享总次数
string msg = "";
if (tmp.GetIntOrDefault("Total") >= PartAccess.Instance.MedConfig("Total"))
{
msg = TipManager.GetMessage(StarReturn.StartStarShared1); //"你已经达到星力爆发分享次数总上限,无法获得经验值!";
pb.Call(ClientCommand.SendActivtyR, new object[] { "T02", msg });
continue;
}
//如果是同一开
if (tmp.GetLocalTimeOrDefault("ShareTime").Date == DateTime.Now.Date)
{
//每天最多分享10次暴星经验
if (tmp.GetIntOrDefault("Count") >= PartAccess.Instance.MedConfig("EveryDay"))
{
msg = TipManager.GetMessage(StarReturn.StartStarShared2);// "你已经达到当天的星力爆发分享次数上限,无法获得经验";
pb.Call(ClientCommand.SendActivtyR, new object[] { "T02", msg });
continue;
}
tmp.SetOrInc("Count", 1);
}
else
{
tmp["Count"] = 1;
}
tmp.SetOrInc("Exp", exp);
tmp["ShareTime"] = DateTime.UtcNow;
tmp.SetOrInc("Total", 1);
}
else
{
tmp = new Variant();
tmp.SetOrInc("Exp", exp);//总共
tmp.SetOrInc("Count", 1);//
tmp["ShareTime"] = DateTime.UtcNow;//上次分享时间
tmp.SetOrInc("Total", 1);//当前分享次数
v.Add("Share", tmp);
}
star.Save();
pb.AddExperience(exp, FinanceType.StartStarShared);
pb.Call(ClientCommand.UpdateActorR, new PlayerExDetail(star));
shareList.Add(pb.ID);
}
PlayersProxy.CallAll(StarCommand.StartStarSharedR, new object[] { note.PlayerID, shareList });
}
finally
{
m_dic.TryRemove(share, out share);
}
}
示例10: Bottles
/// <summary>
/// 星力空瓶的使用
/// </summary>
/// <param name="player"></param>
/// <param name="gc"></param>
/// <param name="p"></param>
private static void Bottles(PlayerBusiness player, GameConfig gc, Variant p)
{
Variant v = gc.Value;
//需要星力值
int outstar = v.GetIntOrDefault("OutStar");
if (player.StarPower < outstar)
{
player.UseGoodsR(false, TipManager.GetMessage(GoodsReturn.GoodsWashing6));
return;
}
Dictionary<string, Variant> dic = new Dictionary<string, Variant>();
//目标道具
string goodsid = v.GetStringOrDefault("GoodsID");
Variant tmp = new Variant();
tmp.SetOrInc("Number" + p.GetIntOrDefault("H"), 1);
dic.Add(goodsid, tmp);
if (BurdenManager.IsFullBurden(player.B0, dic))
{
player.UseGoodsR(false, TipManager.GetMessage(GoodsReturn.BurdenB0Full));
return;
}
if (!player.AddStarPower(-outstar, FinanceType.UseGoods))
{
player.UseGoodsR(false, TipManager.GetMessage(GoodsReturn.GoodsWashing6));
return;
}
if (player.RemoveGoods(p.GetIntOrDefault("P"), GoodsSource.DoubleUse))
{
player.AddGoods(dic, GoodsSource.Bottles);
player.UseGoodsR(true, goodsid);
player.FinishNote(FinishCommand.StarBottle);
}
else
{
player.UseGoodsR(false, TipManager.GetMessage(GoodsReturn.UseGoods2));
}
}
示例11: TaskFinish10004
/// <summary>
/// 回收一定数量的道具,表示在领奖的时候回
/// </summary>
/// <param name="note">角色对象</param>
/// <param name="s"></param>
public static Variant TaskFinish10004(UserNote note, IList s)
{
Variant us = new Variant();
List<string> list = new List<string>();
bool ischange = false;
foreach (Variant d in s)
{
//表示回收物品
if (d.GetIntOrDefault("Type") == 10004)
{
PlayerEx burden = note.Player.B0;
IList c = burden.Value.GetValue<IList>("C");
//回收数量
int num = d.GetIntOrDefault("Total");
if (num == d.GetIntOrDefault("Cur"))
{
string goodsid = d.GetStringOrDefault("GoodsID");
note.Player.RemoveGoods(goodsid, num, GoodsSource.TaskFinish10004);
us.SetOrInc(goodsid, num);
ischange = true;
}
burden.Save();
}
}
if (ischange)
{
note.Player.UpdateBurden();
}
return us;
}