本文整理汇总了C#中System.Variant.GetStringOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# Variant.GetStringOrDefault方法的具体用法?C# Variant.GetStringOrDefault怎么用?C# Variant.GetStringOrDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Variant
的用法示例。
在下文中一共展示了Variant.GetStringOrDefault方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Task10004
/// <summary>
/// 判断是否存在要求回收的物品
/// </summary>
/// <param name="note"></param>
/// <param name="s"></param>
/// <returns>true表示发生变化</returns>
public static bool Task10004(UserNote note, Variant s)
{
if (s.GetIntOrDefault("Cur") == s.GetIntOrDefault("Total"))
return false;
if (!s.ContainsKey("GoodsID"))
return false;
if (s.GetIntOrDefault("Type") != 10004)
return false;
int m = GameConfigAccess.Instance.GetStactCount(s.GetStringOrDefault("GoodsID"));
if (m <= 0) return false;
PlayerEx burden = note.Player.B0;
IList c = burden.Value.GetValue<IList>("C");
int number = 0;
foreach (Variant d in c)
{
if (d.GetStringOrDefault("G") == s.GetStringOrDefault("GoodsID"))
{
number += d.GetIntOrDefault("A");
}
}
if (number >= s.GetIntOrDefault("Total"))
s["Cur"] = s.GetIntOrDefault("Total");
else
s["Cur"] = number;
return true;
}
示例2: Apc
public Apc(Variant config)
{
ID = config.GetStringOrDefault("_id");
this.Name = config.GetStringOrDefault("Name");
Name = config.GetStringOrDefault("Name");
m_value = config.GetVariantOrDefault("Value");
m_life = new PlayerProperty();
if (m_value != null)
{
m_life.Add(m_value);
this.Level = m_value.GetIntOrDefault("Level");
}
this.ApcType = FighterType.APC;
Variant ui = config.GetVariantOrDefault("UI");
if (ui != null)
{
this.Skin = ui.GetStringOrDefault("Skin");
string apcType = ui.GetStringOrDefault("Type");
if (apcType == "BB")
{
this.ApcType = FighterType.BB;
}
else if (apcType == "Boss")
{
this.ApcType = FighterType.Boss;
}
}
}
示例3: AddPetBook
/// <summary>
/// 学习宠物技能(御宠图鉴)
/// </summary>
/// <param name="variant"></param>
public bool AddPetBook(Variant c)
{
string skillID = c.GetStringOrDefault("SkillID");
if (string.IsNullOrEmpty(skillID)) return false;
int level = c.GetIntOrDefault("SkillLev");
var skill = m_petBook.Value.GetValueOrDefault<List<object>>(skillID);
if (skill == null)
{
skill = new List<object>();
m_petBook.Value[skillID] = skill;
}
if (skill.Contains(level))
{
return false;
}
int mustslevel = level - 1;
if (mustslevel > 0 && (!skill.Contains(mustslevel)))
{
return false;
}
skill.Add(level);
m_petBook.Save();
this.Call(ClientCommand.UpdateActorR, new PlayerExDetail(m_petBook));
return true;
}
示例4: Create
public static LimitGoods Create(string name, Variant v)
{
string goodsid = v.GetStringOrDefault("GoodsID");
if (!string.IsNullOrEmpty(goodsid))
{
return new LimitGoods(name, goodsid);
}
return null;
}
示例5: ScenePin
public ScenePin(Variant gc)
{
_id = gc.GetStringOrDefault("_id");
_autoPath = (gc.GetStringOrDefault("SubType") == "4");
Variant v = gc.GetVariantOrDefault("Value");
if (v != null)
{
_sceneA = v.GetStringOrDefault("SceneID");
_x = v.GetIntOrDefault("X");
_y = v.GetIntOrDefault("Y");
m_destination = new Destination(
v.GetStringOrDefault("SceneB"),
v.GetIntOrDefault("BX"),
v.GetIntOrDefault("BY")
);
const int s = 4;
m_range = new Rectangle(_x - s, _y - s, 2 * s, 2 * s);
}
}
示例6: HideApc
public HideApc(Variant config)
: base(config)
{
ID = config.GetStringOrDefault("_id");
Variant v = config.GetVariantOrDefault("Value");
if (v != null)
{
SceneID = v.GetStringOrDefault("SceneID");
Range = RangeHelper.NewRectangle(v["Range"] as Variant, true);
}
}
示例7: Create
public static LimitOpentime Create(string name, Variant v)
{
string openTime = v.GetStringOrDefault("OpenTime");
var result = InitOpenTime(name, openTime);
if (result != null && result.Count > 0)
{
string openTimeMsg = string.Format(TipManager.GetMessage(ClientReturn.IntoLimit6), name, openTime);
return new LimitOpentime(result, openTimeMsg);
}
return null;
}
示例8: Box
public Box(Variant config)
{
ID = config.GetStringOrDefault("_id");
Name = config.GetStringOrDefault("Name");
m_value = config.GetVariantOrDefault("Value");
if (m_value != null)
{
this.SceneID = m_value.GetStringOrDefault("SceneID");
this.GoodsID = m_value.GetStringOrDefault("GoodsID");
this.OpenMS = m_value.GetIntOrDefault("OpenMS");
this.GrowSecond = m_value.GetIntOrDefault("GrowSecond");
this.MaxOpen = m_value.GetIntOrDefault("MaxOpen");
m_range = RangeHelper.NewRectangle(m_value.GetVariantOrDefault("Range"), true);
}
Variant ui = config.GetVariantOrDefault("UI");
if (ui != null)
{
this.Skin = ui.GetStringOrDefault("Skin");
}
if (this.GrowSecond <= 0)
{
this.GrowSecond = 30;
}
}
示例9: GetPetSkin
private static string GetPetSkin(Variant v)
{
string skin = v.GetStringOrDefault("Skin");
int rank = v.GetIntOrDefault("PetsRank");
int index = skin.IndexOf('|');
if (index >= 0)
{
string[] skins = skin.Split('|');
if (rank < skins.Length)
{
return skins[rank];
}
}
return skin + rank.ToString();
}
示例10: FightAction
public FightAction(Variant v, int fightCount)
{
this.ActionType = (ActionType)(v.GetIntOrDefault("fType"));
this.Sender = v.GetStringOrDefault("handler");
object obj;
if (v.TryGetValueT("target", out obj))
{
this.Target = (obj == null ? string.Empty : obj.ToString());
}
if (v.TryGetValueT("parameter", out obj))
{
this.Parameter = (obj == null ? string.Empty : obj.ToString());
}
this.FightCount = fightCount;
}
示例11: Dress
/// <summary>
/// 换装操作
/// </summary>
/// <param name="note"></param>
private void Dress(UserNote note, Goods g)
{
//表示角色正在战斗中,客户端提交信息不进行处理
if (note.Player.AState == ActionState.Fight)
return;
string goodsid = note.GetString(0);
if (g == null)
{
note.Call(GoodsCommand.UseGoodsR, false, TipManager.GetMessage(GoodsReturn.NoGoodsInfo));
return;
}
int check = DressLimit(note.Player, g);
if (check != 0)
{
note.Call(GoodsCommand.UseGoodsR, false, TipManager.GetMessage(check));
return;
}
//得到装备面板
PlayerEx panel = note.Player.Equips;
if (panel == null)
{
panel = note.Player.Value["Equips"] as PlayerEx;
if (panel == null)
{
//LogWrapper.Error("角色:" + note.Player.Name + "装被面板为空");
return;
}
}
Variant pv = panel.Value;
PlayerEx b = note.Player.B0;
if (b == null)
{
note.Call(GoodsCommand.UseGoodsR, false, TipManager.GetMessage(GoodsReturn.EquipError));
return;
}
IList c = b.Value.GetValue<IList>("C");
string str = g.Value.GetStringOrDefault("GoodsType");
//得到装备可以存放的位置
GameConfig gc = GameConfigAccess.Instance.FindOneById(g.GoodsID);
if (gc == null)
{
note.Call(GoodsCommand.UseGoodsR, false, TipManager.GetMessage(GoodsReturn.EquipError));
return;
}
IDictionary<string, object> k = null;
string name = string.Empty;
switch (str)
{
case "111001"://武器
k = pv["P0"] as IDictionary<string, object>;
name = "P0";
break;
case "111002"://头盔
k = pv["P5"] as IDictionary<string, object>;
name = "P5";
break;
case "111003"://衣服
k = pv["P6"] as IDictionary<string, object>;
name = "P6";
break;
case "111004"://护腕
IDictionary<string, object> p3 = pv["P3"] as IDictionary<string, object>;
IDictionary<string, object> p8 = pv["P8"] as IDictionary<string, object>;
if (p3.GetStringOrEmpty("E") == string.Empty)
{
k = p3;
name = "P3";
}
else if (p8.GetStringOrEmpty("E") == string.Empty)
{
k = p8;
name = "P8";
}
else if (p111004 == 0)
{
k = p3;
name = "P3";
p111004 = p111004 == 0 ? 1 : 0;
}
else
{
k = p8;
name = "P8";
p111004 = p111004 == 0 ? 1 : 0;
}
break;
case "111005"://腰带
k = pv["P2"] as IDictionary<string, object>;
//.........这里部分代码省略.........
示例12: NeedSpace
/// <summary>
/// 得到一种道具,判断需要多少格子
/// </summary>
/// <param name="Content">包袱列表</param>
/// <param name="goodsid">道具id</param>
/// <param name="number0">非绑定道具数量</param>
/// <param name="number1">绑定道具数量</param>
/// <returns>需要空格子数量</returns>
public static int NeedSpace(IList Content, string goodsid, Variant v, int sc)
{
int space = 0;
for (int isbinding = 0; isbinding <= 1; isbinding++)
{
//0为非绑定,1为绑定
int number = v.GetIntOrDefault("Number" + isbinding);
if (number <= 0)
continue;
int cur = 0;//当前该物品所占的格子数
foreach (Variant k in Content)
{
if (k.GetStringOrDefault("G") != goodsid)
continue;
if (k.GetIntOrDefault("H") != isbinding)
continue;
if (v.ContainsKey("EndTime"))
{
Variant t = k.GetVariantOrDefault("T");
if (t == null)
continue;
if (t.GetStringOrDefault("EndTime") != v.GetStringOrDefault("EndTime"))
continue;
}
number += k.GetIntOrDefault("A");
cur++;
}
int m = 0;//余数
int n = Math.DivRem(number, sc, out m);
n = m > 0 ? n + 1 : n;
space += (n > cur) ? (n - cur) : 0;
}
return space;
}
示例13: BaseConfig
public BaseConfig(Variant config)
{
this.BaseDirectory = AppDomain.CurrentDomain.BaseDirectory;
this.Platform = config.GetStringOrDefault("Platform", Sinan.Entity.Platform.Tencent);
this.DirConfig = Path.Combine(this.BaseDirectory, fixPath(config.GetStringOrDefault("DirConfig", "Config")));
this.Crossdomain = Path.Combine(DirConfig, fixPath(config.GetStringOrDefault("Crossdomain", "crossdomain.txt")));
this.DirBase = Path.Combine(DirConfig, fixPath(config.GetStringOrDefault("DirBase", "base")));
this.DirGame = Path.Combine(DirConfig, fixPath(config.GetStringOrDefault("DirGame", "game")));
this.DirDB = Path.Combine(DirConfig, fixPath(config.GetStringOrDefault("DirDB", "db")));
this.Language = config.GetStringOrDefault("Language");
if (!string.IsNullOrWhiteSpace(Language))
{
string path = Path.Combine(DirConfig, fixPath(Language));
if (Directory.Exists(path))
{
this.DirBase = path;
}
}
this.DirPlugin = Path.Combine(BaseDirectory, fixPath(config.GetStringOrDefault("DirPlugin", "Plugins")));
this.Log4Config = Path.Combine(BaseDirectory, fixPath(config.GetStringOrDefault("Log4Config", "log4net.config")));
this.DbBase = config.GetStringOrDefault("DbBase");
this.DbLog = config.GetStringOrDefault("DbLog");
this.DbPlayer = config.GetStringOrDefault("DbPlayer");
string epGame = config.GetStringOrDefault("EpGame");
this.EpGame = CreateEndPoint(epGame);
string epGM = config.GetStringOrDefault("EpGM");
this.EpGM = CreateEndPoint(epGM);
string epGMM = config.GetStringOrDefault("EpGMM");
this.EpGMM = CreateEndPoint(epGMM);
string epShip = config.GetStringOrDefault("EpShip");
this.EpShip = CreateEndPoint(epShip);
this.MaxClient = config.GetIntOrDefault("MaxClient", 500);
this.SendQueueSize = config.GetIntOrDefault("SendQueueSize", 100);
this.MaxLevel = config.GetIntOrDefault("MaxLevel", 100);
this.MaxNameLen = config.GetIntOrDefault("MaxNameLen", 16);
this.Zoneid = config.GetIntOrDefault("Zoneid");
this.ZoneEpoch = config.GetUtcTimeOrDefault("ZoneEpoch");
this.DesKey = config.GetStringOrDefault("DESKey");
this.LoginKey = config.GetStringOrDefault("LoginKey") ?? config.GetStringOrDefault("MD5Key");
this.RechargeKey = config.GetStringOrDefault("RechargeKey");
this.GMKey = config.GetStringOrEmpty("GMKey");
this.ReportSIP = config.GetStringOrDefault("ReportSIP");
this.WebAddress = config.GetStringOrDefault("WebAddress");
this.FreeCoin = config.GetBooleanOrDefault("FreeCoin", false);
}
示例14: TaskFinish10003
/// <summary>
/// 检查物品是否存在
/// </summary>
/// <param name="note"></param>
/// <param name="s"></param>
public static void TaskFinish10003(UserNote note, Variant s)
{
PlayerEx b0 = note.Player.B0;
IList c = b0.Value.GetValue<IList>("C");
int num = BurdenManager.BurdenGoodsCount(c, s.GetStringOrDefault("GoodsID"));
s["Cur"] = Math.Min(s.GetIntOrDefault("Total"), num);
}
示例15: TaskFinish10010
/// <summary>
/// 接收任务时发方道具
/// </summary>
/// <param name="note"></param>
/// <param name="s"></param>
public static bool TaskFinish10010(UserNote note, Variant s)
{
if (s.GetIntOrDefault("Cur") >= s.GetIntOrDefault("Total"))
return true;
Dictionary<string, Variant> dic = new Dictionary<string, Variant>();
Variant v = new Variant();
v.Add("Number1", s.GetIntOrDefault("Total"));
dic.Add(s.GetStringOrDefault("GoodsID"), v);
if (BurdenManager.IsFullBurden(note.Player.B0, dic))
return false;
note.Player.AddGoods(dic, GoodsSource.TaskFinish10010);
s["Cur"] = s.GetIntOrDefault("Total");
return true;
}