本文整理汇总了C#中Sinan.FrontServer.UserNote.GetVariant方法的典型用法代码示例。如果您正苦于以下问题:C# UserNote.GetVariant方法的具体用法?C# UserNote.GetVariant怎么用?C# UserNote.GetVariant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sinan.FrontServer.UserNote
的用法示例。
在下文中一共展示了UserNote.GetVariant方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LiBao
/// <summary>
/// 礼包
/// </summary>
/// <param name="note"></param>
/// <param name="gc"></param>
private void LiBao(UserNote note, GameConfig gc)
{
Variant package = note.GetVariant(0);
int p = package.GetIntOrDefault("P");
Variant tmp = BurdenManager.BurdenPlace(note.Player.B0, p);
if (tmp == null)
{
note.Call(GoodsCommand.UseGoodsR, false, string.Format(TipManager.GetMessage(GoodsReturn.LiBao1), gc.Name));
return;
}
//判断物品是否绑定
int isBinding = tmp.GetIntOrDefault("H");
Variant libao = gc.Value.GetVariantOrDefault("LiBao");
if (libao == null)
{
note.Call(GoodsCommand.UseGoodsR, false, string.Format(TipManager.GetMessage(GoodsReturn.LiBao1), gc.Name));
return;
}
Dictionary<string, Variant> dic = new Dictionary<string, Variant>();
int bond = 0;
int score = 0;
int coin = 0;
if (!libao.ContainsKey("Award"))
{
#region 固定奖励礼包
foreach (var item in libao)
{
switch (item.Key)
{
case "Bond":
bond = libao.GetIntOrDefault(item.Key);
break;
case "Score":
score = libao.GetIntOrDefault(item.Key);
break;
case "Coin":
coin = libao.GetIntOrDefault(item.Key);
break;
default:
GetLiBaoAward(dic, item.Key, (int)item.Value, isBinding);
break;
}
}
#endregion
}
else
{
#region 随机奖励礼包
Variant award = libao.GetValue<Variant>("Award");
Dictionary<string, int> goods = new Dictionary<string, int>();
Award.GetPackets(award, goods);
if (goods.Count > 0)
{
foreach (var item in goods)
{
GetLiBaoAward(dic, item.Key, item.Value, isBinding);
}
}
#endregion
}
PlayerEx burden = note.Player.B0;
if (dic.Count > 0)
{
if (BurdenManager.IsFullBurden(burden, dic))
{
note.Call(GoodsCommand.UseGoodsR, false, TipManager.GetMessage(BurdenReturn.BurdenFull));
return;
}
}
//移除成功
if (note.Player.RemoveGoods(p, GoodsSource.LiBao))
{
if (dic.Count > 0)
{
//得到新物品
note.Player.AddGoods(dic, GoodsSource.LiBao);
}
if (bond > 0)
{
//添加
note.Player.AddBond(bond, FinanceType.LiBao);
}
if (score > 0)
{
//添加
note.Player.AddScore(score, FinanceType.LiBao);
}
if (ConfigLoader.Config.FreeCoin)
//.........这里部分代码省略.........
示例2: UpdateTeam
/// <summary>
/// 更新队伍信息
/// </summary>
/// <param name="note"></param>
/// <param name="team"></param>
private void UpdateTeam(UserNote note, PlayerTeam team)
{
Variant v = note.GetVariant(0);
team.AutoInto = v.GetBooleanOrDefault("AutoAgree");
team.ShieldAutoApply = v.GetBooleanOrDefault("ShieldAutoApply");
team.Explain = v.GetStringOrDefault("Explain");
team.Icon = v.GetStringOrDefault("Icon");
var buffer = AmfCodec.Encode(TeamCommand.UpdateTeamR, new object[] { team });
note.Player.CallAll(buffer);
team.CallAway(buffer, note.Player.SceneID);
}
示例3: NewOrder
private void NewOrder(UserNote note)
{
UserSession user = note.Session;
Variant v = note.GetVariant(0);
string vs = JsonConvert.SerializeObject(v);
//LogWrapper.Warn("请求:" + vs);
BuyGoodsRequest request = new BuyGoodsRequest();
string meta = v.GetStringOrDefault("goodsmeta");
request.goodsmeta = Convert.ToBase64String(Encoding.UTF8.GetBytes(meta));
request.goodsurl = v.GetStringOrDefault("goodsurl");
request.openid = user.UserID.PadLeft(32, '0');
request.openkey = user.key;
request.payitem = v.GetStringOrDefault("payitem");
request.pf = v.GetStringOrDefault("platform") ?? v.GetStringOrDefault("pf");
request.pfkey = v.GetStringOrDefault("pfkey");
request.appmode = v.GetIntOrDefault("appmode", 2);
request.device = v.GetIntOrDefault("device");
request.zoneid = ServerLogger.zoneid;
string host = ServerManager.BuyHost;
string uri = ServerManager.BuyUri;
StringBuilder sb = new StringBuilder(512);
string quest = request.Build(sb, null).ToString();
string sign = AppSign.Sign(uri, quest);
sb.Clear();
sb.Append(uri + "?");
request.Build(sb, UrlUtility.UrlEncode);
sb.Append("&sig=");
sb.Append(sign);
HttpArgs a = new HttpArgs();
a.Host = host;
a.Url = sb.ToString();
//LogWrapper.Warn("请求Url:" + a.Url);
IPEndPoint ipadd = IPHelper.CreateEndPoint(host, 443);
byte[] bin = SslHttpClient.Get(ipadd, a, null);
string result = Encoding.UTF8.GetString(bin);
Variant re = JsonConvert.DeserializeObject<Variant>(result);
if (re.GetIntOrDefault("ret", -1) == 0)
{
string token = re.GetStringOrDefault("token");
if (!string.IsNullOrEmpty(token))
{
if (CreateOrder(note.Player, token))
{
user.Call(MallCommand.NewTokenR, true, re);
return;
}
}
}
user.Call(MallCommand.NewTokenR, false, re);
//LogWrapper.Warn("请求结果:" + result);
}
示例4: CreateOrder
//保存订单到数据库
private void CreateOrder(UserNote note)
{
if (note == null || note.Player == null)
{
return;
}
Variant v = note.GetVariant(0);
if (v == null)
{
note.Call(MallCommand.CoinOrderR, false, v);
return;
}
string token = v.GetStringOrDefault("token");
if (string.IsNullOrEmpty(token))
{
note.Call(MallCommand.CoinOrderR, false, v);
return;
}
bool result = CreateOrder(note.Player, token);
note.Call(MallCommand.CoinOrderR, result, v);
}
示例5: 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;
//.........这里部分代码省略.........
示例6: CreateArena
/// <summary>
/// 创建竞技场
/// </summary>
/// <param name="note"></param>
public static void CreateArena(UserNote note)
{
string soleid = note.PlayerID + "CreateArena";
if (!m_dic.TryAdd(soleid, soleid))
return;
try
{
Variant m = note.GetVariant(0);
if (m == null)
{
//参数为不能为空
note.Call(ArenaCommand.CreateArenaR, false, TipManager.GetMessage(ArenaReturn.CreateArena1));
return;
}
ArenaBase model = new ArenaBase();
model.PlayerID = note.PlayerID;
model.ArenaID = m.GetStringOrDefault("ID");
GameConfig gc = GameConfigAccess.Instance.FindOneById(model.ArenaID);
if (gc == null)
{
//竞技场基本配置不正确
note.Call(ArenaCommand.CreateArenaR, false, TipManager.GetMessage(ArenaReturn.CreateArena2));
return;
}
Variant v = gc.Value;
if (v == null)
{
note.Call(ArenaCommand.CreateArenaR, false, TipManager.GetMessage(ArenaReturn.CreateArena2));
return;
}
//ArenaConfig.ArenaInfo(gc);
model.Group = m.GetIntOrDefault("Group");
//if (!ArenaConfig.IsGroup(model.Group))
//{
// note.Call(ArenaCommand.CreateArenaR, false, "分组数量不正确");
// return;
//}
//Variant group = v.GetValueOrDefault<Variant>("Group").GetValueOrDefault<Variant>(model.Group.ToString());
string petlevel = m.GetStringOrDefault("PetLevel");
//if (!ArenaConfig.IsPetLevel(petlevel))
//{
// note.Call(ArenaCommand.CreateArenaR, false, "请选择宠物等级限制");
// return;
//}
int petmix = 0;
int petmax = 0;
string[] strs = petlevel.Split('-');
if (!int.TryParse(strs[0], out petmix))
{
//请选择宠物最底等级限制
note.Call(ArenaCommand.CreateArenaR, false, TipManager.GetMessage(ArenaReturn.CreateArena3));
return;
}
if (!int.TryParse(strs[1], out petmax))
{
//请选择宠物最高等级限制
note.Call(ArenaCommand.CreateArenaR, false, TipManager.GetMessage(ArenaReturn.CreateArena4));
return;
}
model.PetMin = petmix;
model.PetMax = petmax;
model.WarType = m.GetIntOrDefault("WinType");
if (model.WarType == 0)
{
for (int i = 0; i < model.Group; i++)
{
model.GroupName.Add(i.ToString());
}
}
model.IsOtherInto = m.GetBooleanOrDefault("IsOtherInto");
model.IsWatch = m.GetBooleanOrDefault("IsWatch");
if (model.IsOtherInto && (!model.IsWatch))
{
//允许中途参战必须可以观战
note.Call(ArenaCommand.CreateArenaR, false, TipManager.GetMessage(ArenaReturn.CreateArena5));
return;
}
model.IsGoods = m.GetBooleanOrDefault("IsGoods");
model.WinType = m.GetIntOrDefault("WinType");
model.Scene = m.GetStringOrDefault("Scene");
GameConfig sc = GameConfigAccess.Instance.FindOneById(model.Scene);
//.........这里部分代码省略.........
示例7: RobFamilyAward
/// <summary>
/// 夺宝奇兵家族奖励分配
/// </summary>
/// <param name="note"></param>
public static void RobFamilyAward(UserNote note)
{
Variant v = note.GetVariant(0);
PlayerEx familyEx = note.Player.Family;
string familyID = familyEx.Value.GetStringOrDefault("FamilyID");
if (string.IsNullOrEmpty(familyID))
return;
Family model = FamilyAccess.Instance.FindOneById(familyID);
if (model == null)
return;
IList persons = model.Value.GetValue<IList>("Persons");
long TotalDevote = 0;//总的共献度
foreach (Variant k in persons)
{
TotalDevote += k.GetIntOrDefault("Devote");
}
foreach (Variant k in persons)
{
long countL = (k.GetIntOrDefault("Devote") * v.GetIntOrDefault("Count")) / TotalDevote;
int count = (int)countL;
if (count > 0)
{
PlayerBusiness pb = PlayersProxy.FindPlayerByID(k.GetStringOrDefault("PlayerID"));
if (pb != null)
{
string title = TipManager.GetMessage(EmailReturn.RobFamilyAward1);
string content = TipManager.GetMessage(EmailReturn.RobFamilyAward2);
int reTime = Convert.ToInt32(TipManager.GetMessage(EmailReturn.HameDay));
Variant gs = new Variant();
gs.Add("G", v.GetStringOrDefault("Goods"));
gs.Add("A", count);
gs.Add("E", v.GetStringOrDefault("Goods"));
List<Variant> goodsList = new List<Variant>() { gs };
if (EmailAccess.Instance.SendEmail(title, TipManager.GetMessage(EmailReturn.RobFamilyAward3), pb.ID, pb.Name, content, string.Empty, goodsList, reTime))
{
if (pb.Online)
{
pb.Call(EmailCommand.NewEmailTotalR, EmailAccess.Instance.NewTotal(pb.ID));
}
}
}
}
}
}
示例8: AuctionSell
/// <summary>
/// 出售
/// </summary>
public static void AuctionSell(UserNote note)
{
int num = Convert.ToInt32(TipManager.GetMessage(AuctionReturn.AuctionSellerCount));
if (AuctionAccess.Instance.AuctionSellerCount(note.PlayerID) >= num)
{
string msg = string.Format(TipManager.GetMessage(AuctionReturn.SellerCount), num);
note.Call(AuctionCommand.AuctionSellR, false, msg);
return;
}
Variant d = note.GetVariant(0);
string npcid = note.GetString(1);//NPC
if (!note.Player.EffectActive(npcid, ""))
return;
PlayerEx b0 = note.Player.B0;
if (b0 == null)
{
note.Call(AuctionCommand.AuctionSellR, false, TipManager.GetMessage(AuctionReturn.BurdenTypeError));
return;
}
if (d.GetStringOrDefault("PackageType") != "B0")
{
note.Call(AuctionCommand.AuctionSellR, false, TipManager.GetMessage(AuctionReturn.BurdenTypeError));
return;
}
Variant tmp = BurdenManager.BurdenPlace(b0, d.GetIntOrDefault("Postion"));
if (tmp == null)
{
note.Call(AuctionCommand.AuctionSellR, false, TipManager.GetMessage(AuctionReturn.PostionError));
return;
}
string soleid = tmp.GetStringOrDefault("E");
string goodsid = tmp.GetStringOrDefault("G");
int nu = tmp.GetIntOrDefault("A");
//物品发生变化
if (soleid != d.GetStringOrDefault("SoleID"))
{
note.Call(AuctionCommand.AuctionSellR, false, TipManager.GetMessage(DealReturn.NumberError));
return;
}
//数量发生变化
if (nu != d.GetIntOrDefault("Number"))
{
note.Call(AuctionCommand.AuctionSellR, false, TipManager.GetMessage(DealReturn.NumberError));
return;
}
Variant t = tmp.GetVariantOrDefault("T");
if (t != null)
{
if (t.ContainsKey("EndTime"))
{
note.Call(AuctionCommand.AuctionSellR, false, TipManager.GetMessage(AuctionReturn.AuctionFreezeDate));
return;
}
}
if (tmp.GetIntOrDefault("H") == 1)
{
note.Call(AuctionCommand.AuctionSellR, false, TipManager.GetMessage(AuctionReturn.NoSellIsBinding));
return;
}
Variant dy = new Variant(20);
dy.Add("Number", d.GetIntOrDefault("Number"));
dy.Add("Price", d.GetIntOrDefault("Price"));
dy.Add("LimitTime", d.GetIntOrDefault("LimitTime"));
string name = "";
int startScore = 0;//起拍价
if (soleid != tmp.GetStringOrDefault("G"))
{
Goods g = GoodsAccess.Instance.FindOneById(soleid);
if (g == null)
{
note.Call(AuctionCommand.AuctionSellR, false, TipManager.GetMessage(DealReturn.NumberError));
return;
}
dy.Add("SoleID", g.ID);
dy.Add("GoodsID", g.GoodsID);
dy.Add("GoodsType", g.Value.GetStringOrDefault("GoodsType"));
dy.Add("Sort", g.Value.GetIntOrDefault("Sort"));
Variant Price = g.Value.GetVariantOrDefault("Price");
startScore = Price.GetIntOrDefault("StallScore");
name = g.Name;
}
else
{
//.........这里部分代码省略.........
示例9: UseGoods
/// <summary>
/// 商品的使用
/// </summary>
/// <param name="note"></param>
private void UseGoods(UserNote note)
{
//商品的使用
Variant package = note.GetVariant(0);
int check = DateLimit(note.Player, package);
if (check != 0)
{
note.Call(GoodsCommand.UseGoodsR, false, TipManager.GetMessage(check));
return;
}
string goodsid = package.GetStringOrDefault("E");
string gid = string.Empty;
Goods g = GoodsAccess.Instance.GetGoodsByID(goodsid);
if (g != null)
{
string goodsType = g.Value.GetStringOrDefault("GoodsType");
if (g.PlayerID != note.PlayerID) return;
//表示装备的使用
if (goodsType.StartsWith("111"))
{
Dress(note, g);
return;
}
if (goodsType == "112011")
{
LiBao(note, g);
return;
}
//112001 药品类
//112002 材料类
//112003 宠物道具
//112004 辅助类
//112005 技能类
//112006 任务类
//112007 家园类
//112008 特殊类
//112009 宠物
//112010 宠物蛋
//112011 礼包
//药品类
}
GameConfig gc = GameConfigAccess.Instance.FindOneById(g == null ? goodsid : g.GoodsID);
if (gc == null)
{
return;
}
if (gc.Value.GetStringOrDefault("GoodsType") == "112011")
{
LiBao(note, gc);
}
else
{
UseGoods(note, package, gc, false);
}
}
示例10: AddKey
/// <summary>
/// 添加快捷键
/// </summary>
/// <param name="note"></param>
public static void AddKey(UserNote note)
{
string playerpetid = note.GetString(0);
Variant o = note.GetVariant(1);
Pet p = null;
if (note.Player.Pet != null)
{
if (note.Player.Pet.ID == playerpetid)
{
p = note.Player.Pet;
}
}
if (p == null)
{
p = PetAccess.Instance.FindOneById(playerpetid);
}
if (p == null)
{
note.Call(PetsCommand.AddKeyR, false, TipManager.GetMessage(PetsReturn.NoPets));
return;
}
if (!p.Value.ContainsKey("HotKeys"))
{
Variant v = new Variant();
for (int i = 0; i < 10; i++)
{
v.Add(i.ToString(), string.Empty);
}
p.Value.Add("HotKeys", v);
}
else
{
Variant h = p.Value.GetVariantOrDefault("HotKeys");
string[] strs = new string[h.Count];
h.Keys.CopyTo(strs, 0);
for (int i = 0; i < strs.Length; i++)
{
if (h.ContainsKey(strs[i]))
{
h[strs[i]] = string.Empty;
}
}
}
//宠物技能槽
IList SkillGroove = p.Value.GetValue<IList>("SkillGroove");
Dictionary<string, string> dic = new Dictionary<string, string>();
foreach (var item in o)
{
string value = (string)item.Value;
bool IsHave = false;
foreach (Variant v in SkillGroove)
{
if (v.GetStringOrDefault("SkillID") == value)
{
IsHave = true;
break;
}
}
if (IsHave)
{
if (!dic.ContainsKey(value))
{
//去除相同技能
dic.Add(value, item.Key);
}
}
}
Variant HotKeys = p.Value.GetVariantOrDefault("HotKeys");
foreach (string k in dic.Keys)
{
if (HotKeys.ContainsKey(dic[k]))
{
HotKeys[dic[k]] = k;
}
}
p.Save();
note.Call(PetsCommand.UpdatePetR, true, p);
note.Call(PetsCommand.AddKeyR, true, TipManager.GetMessage(PetsReturn.AddKey));
}
示例11: LockDeal
/// <summary>
/// 锁定交易
/// </summary>
/// <param name="note"></param>
public static void LockDeal(UserNote note)
{
Variant goods = note.GetVariant(0);
int Score = goods.GetIntOrDefault("Score");
//int Coin = goods.GetIntOrDefault("Coin");
if (note.Player.Score < Score)
{
note.Call(DealCommand.LockDealR, false, TipManager.GetMessage(DealReturn.NoScore));
return;
}
//if (note.Player.Coin < Coin)
//{
// note.Call(DealCommand.LockDealR, false, TipManager.GetMessage(DealReturn.NoCoin));
// return;
//}
IList gs = goods.GetValue<IList>("Goods");
if (!note.Player.Value.ContainsKey("Deal"))
{
note.Call(DealCommand.LockDealR, false, TipManager.GetMessage(DealReturn.StopDeal));
return;
}
Variant d = note.Player.Value.GetVariantOrDefault("Deal");
PlayerBusiness OnLineBusiness = PlayersProxy.FindPlayerByID(d.GetStringOrDefault("PlayerID"));
if (OnLineBusiness == null || (!OnLineBusiness.Online))
{
note.Player.Value.Remove("Deal");
note.Call(DealCommand.LockDealR, false, TipManager.GetMessage(DealReturn.NoLine));
return;
}
//接收物品的一方
PlayerEx burdenOther = OnLineBusiness.B0;
if (BurdenManager.BurdenDealFull(burdenOther, gs))
{
OnLineBusiness.Call(DealCommand.LockDealR, false, TipManager.GetMessage(DealReturn.LockBurdenFull_0));
note.Call(DealCommand.LockDealR, false, TipManager.GetMessage(DealReturn.LockBurdenFull_1));
return;
}
//对方包袱已满,请先整理才能交易
PlayerEx burden = note.Player.B0;
IList c = burden.Value.GetValue<IList>("C");
if (!IsCheck(gs, c, note.Player))
return;
d["Goods"] = goods;
d["Status"] = 2;
Variant deal = OnLineBusiness.Value.GetVariantOrDefault("Deal");
OnLineBusiness.Call(DealCommand.LockDealR, true, goods);
note.Call(DealCommand.LockDealR, true, 0);
}