本文整理汇总了C#中System.Variant.GetDoubleOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# Variant.GetDoubleOrDefault方法的具体用法?C# Variant.GetDoubleOrDefault怎么用?C# Variant.GetDoubleOrDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Variant
的用法示例。
在下文中一共展示了Variant.GetDoubleOrDefault方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AttackParameter
public AttackParameter(GameConfig gc, int level)
{
m_gc = gc;
this.Level = level;
this.BufferID = gc.Value.GetStringOrDefault("BufferID");
this.AddHitRate = gc.Value.GetDoubleOrDefault("AddHitRate");
m_gcl = gc.Value.GetVariantOrDefault(level.ToString());
this.A = m_gcl.GetDoubleOrDefault("A");
this.B = m_gcl.GetDoubleOrDefault("B");
this.C = m_gcl.GetDoubleOrDefault("C");
}
示例2: CreatePlayerProperty
public static PlayerProperty CreatePlayerProperty(Variant v)
{
PlayerProperty life = new PlayerProperty();
life.LiLiang = v.GetIntOrDefault("LiLiang");
life.TiZhi = v.GetIntOrDefault("TiZhi");
life.ZhiLi = v.GetIntOrDefault("ZhiLi");
life.JingShen = v.GetIntOrDefault("JingShen");
life.KangShangHai = v.GetIntOrDefault("KangShangHai");
//-----------------------
life.WuLiXiShou = v.GetDoubleOrDefault("WuLiXiShou");
life.MoFaXiShou = v.GetDoubleOrDefault("MoFaXiShou");
life.FanJiLv = v.GetDoubleOrDefault("FanJiLv");
life.HeJiLv = v.GetDoubleOrDefault("HeJiLv");
life.TaoPaoLv = v.GetDoubleOrDefault("TaoPaoLv");
life.BaoJiShangHai = v.GetDoubleOrDefault("BaoJiShangHai");
life.HeJiShangHai = v.GetDoubleOrDefault("HeJiShangHai");
life.SuDu = v.GetIntOrDefault("SuDu");
life.BaoJi = v.GetIntOrDefault("BaoJi");
life.MingZhong = v.GetIntOrDefault("MingZhong");
life.ShanBi = v.GetIntOrDefault("ShanBi");
life.BaoJiLv = v.GetDoubleOrDefault("BaoJiLv");
life.MingZhongLv = v.GetDoubleOrDefault("MingZhongLv");
life.ShanBiLv = v.GetDoubleOrDefault("ShanBiLv");
//----------------------------------
life.ShengMing = v.GetVariantOrDefault("ShengMing").GetIntOrDefault("M");
life.MoFa = v.GetVariantOrDefault("MoFa").GetIntOrDefault("M");
life.GongJi = v.GetVariantOrDefault("GongJi").GetIntOrDefault("V");
life.MoFaGongJi = v.GetVariantOrDefault("MoFaGongJi").GetIntOrDefault("V");
life.FangYu = v.GetVariantOrDefault("FangYu").GetIntOrDefault("V");
life.MoFaFangYu = v.GetVariantOrDefault("MoFaFangYu").GetIntOrDefault("V");
return life;
}
示例3: NewTalk
/// <summary>
/// 创建说话
/// </summary>
/// <param name="talk"></param>
/// <returns></returns>
static int NewTalk(Variant talk)
{
int say = 0;
if (talk != null)
{
double tp = talk.GetDoubleOrDefault("P");
if (Sinan.Extensions.NumberRandom.RandomHit(tp))
{
object s;
if (talk.TryGetValue("Say", out s))
{
if (s is int)
{
say = (int)s;
}
else
{
say = Convert.ToInt32(s);
}
}
}
}
return say;
}
示例4: SupplyRole
/// <summary>
/// 补充玩家的HP/MP
/// </summary>
/// <param name="v"></param>
/// <returns></returns>
public bool SupplyRole(Variant v)
{
double dhp = v.GetDoubleOrDefault("HP");
double dmp = v.GetDoubleOrDefault("MP");
int hp, mp;
if (dhp <= 1)
{
hp = (int)(dhp * m_life.ShengMing); //百分比方式
}
else
{
hp = (int)(dhp);
}
if (dmp <= 1)
{
mp = (int)(dmp * m_life.MoFa); //百分比方式
}
else
{
mp = (int)(dmp);
}
bool use = false;
if (hp > 0)
{
int need = m_life.ShengMing - this.HP;
if (need > 0)
{
this.HP += Math.Min(need, hp);
use = true;
}
}
if (mp > 0)
{
int need = m_life.MoFa - this.MP;
if (need > 0)
{
this.MP += Math.Min(need, mp);
use = true;
}
}
if (use)
{
Variant changed = new Variant(3);
if (hp > 0) changed["ShengMing"] = new MVPair(m_life.ShengMing, this.HP);
if (mp > 0) changed["MoFa"] = new MVPair(m_life.MoFa, this.MP);
UpdataActorR(changed);
}
return use;
}
示例5: SupplyPet
/// <summary>
/// 补充宠物的HP/MP
/// </summary>
/// <param name="v"></param>
/// <returns></returns>
public bool SupplyPet(Variant v)
{
bool use = false;
//庞物
if (m_pet == null) return use;
Variant pet = m_pet.Value;
if (pet == null) return use;
Variant moFa = pet.GetVariantOrDefault("MoFa");
Variant shengMing = pet.GetVariantOrDefault("ShengMing");
double dhp = v.GetDoubleOrDefault("HP");
double dmp = v.GetDoubleOrDefault("MP");
int hp, mp;
if (dhp <= 1)
{
hp = (int)(dhp * shengMing.GetIntOrDefault("M")); //百分比方式
}
else
{
hp = (int)(dhp);
}
if (dmp <= 1)
{
mp = (int)(dmp * moFa.GetIntOrDefault("M")); //百分比方式
}
else
{
mp = (int)(dmp);
}
if (hp > 0)
{
int sv = shengMing.GetIntOrDefault("V");
int need = shengMing.GetIntOrDefault("M") - sv;
if (need > 0)
{
m_pet.HP = Math.Min(need, hp) + sv;
shengMing["V"] = m_pet.HP;
use = true;
}
}
if (mp > 0)
{
int mv = moFa.GetIntOrDefault("V");
int need = moFa.GetIntOrDefault("M") - mv;
if (need > 0)
{
m_pet.MP = Math.Min(need, mp) + mv;
moFa["V"] = m_pet.MP;
use = true;
}
}
if (hp > 0 || mp > 0)
{
this.Call(PetsCommand.UpdatePetR, true, m_pet);
m_pet.Save();
}
return use;
}
示例6: SetDoubleExp
public bool SetDoubleExp(Variant v, int number = 1)
{
double a = v.GetDoubleOrDefault("A");
int second = v.GetIntOrDefault("S") * number;
if (a > 0 && second > 0)
{
SetASTBuffer("RExp", a, second);
}
return true;
}
示例7: AddPet
public void AddPet(Variant v, int level)
{
//ShengMing: double //生命
//GongJi: double //物理攻击
//MoFaGongJi: double //魔法攻击
//SuDu: double //速度
//BaoJi: double //暴击
//MingZhong: double //命中
//ShanBi: double //闪避
ShengMing += (int)(v.GetDoubleOrDefault("ShengMing") * level);
GongJi += (int)(v.GetDoubleOrDefault("GongJi") * level);
MoFaGongJi += (int)(v.GetDoubleOrDefault("MoFaGongJi") * level);
SuDu += (int)(v.GetDoubleOrDefault("SuDu") * level);
BaoJi += (int)(v.GetDoubleOrDefault("BaoJi") * level);
MingZhong += (int)(v.GetDoubleOrDefault("MingZhong") * level);
ShanBi += (int)(v.GetDoubleOrDefault("ShanBi") * level);
BaoJiShangHai += (v.GetDoubleOrDefault("BaoJiShangHai") * level);
WuLiXiShou += (v.GetDoubleOrDefault("WuLiXiShou") * level);
MoFaXiShou += (v.GetDoubleOrDefault("MoFaXiShou") * level);
KangShangHai += (int)(v.GetDoubleOrDefault("KangShangHai") * level);
MoFa += (int)(v.GetDoubleOrDefault("MoFa") * level);
FangYu += (int)(v.GetDoubleOrDefault("FangYu") * level);
MoFaFangYu += (int)(v.GetDoubleOrDefault("MoFaFangYu") * level);
LiLiang += (int)(v.GetDoubleOrDefault("LiLiang") * level);
TiZhi += (int)(v.GetDoubleOrDefault("TiZhi") * level);
ZhiLi += (int)(v.GetDoubleOrDefault("ZhiLi") * level);
JingShen += (int)(v.GetDoubleOrDefault("JingShen") * level);
TaoPaoLv += (v.GetDoubleOrDefault("TaoPaoLv") * level);
//this.FanJiLv += (v.GetDoubleOrDefault("FanJiLv") * level);
//this.HeJiLv += (v.GetDoubleOrDefault("HeJiLv") * level);
//this.HeJiShangHai += (v.GetDoubleOrDefault("HeJiShangHai") * level);
//this.BaoJiLv += (v.GetDoubleOrDefault("BaoJiLv") * level);
//this.MingZhongLv += (v.GetDoubleOrDefault("MingZhongLv") * level);
//this.ShanBiLv += (v.GetDoubleOrDefault("ShanBiLv") * level);
}
示例8: Add
/// <summary>
/// 加成.
/// </summary>
/// <param name="v"></param>
/// <returns></returns>
public virtual void Add(Variant v)
{
if (v != null && v.Count > 0)
{
ShengMing += v.GetIntOrDefault("ShengMing");
MoFa += v.GetIntOrDefault("MoFa");
GongJi += v.GetIntOrDefault("GongJi");
MoFaGongJi += v.GetIntOrDefault("MoFaGongJi");
FangYu += v.GetIntOrDefault("FangYu");
MoFaFangYu += v.GetIntOrDefault("MoFaFangYu");
WuLiXiShou += v.GetDoubleOrDefault("WuLiXiShou");
MoFaXiShou += v.GetDoubleOrDefault("MoFaXiShou");
FanJiLv += v.GetDoubleOrDefault("FanJiLv");
HeJiLv += v.GetDoubleOrDefault("HeJiLv");
TaoPaoLv += v.GetDoubleOrDefault("TaoPaoLv");
BaoJiShangHai += v.GetDoubleOrDefault("BaoJiShangHai");
HeJiShangHai += v.GetDoubleOrDefault("HeJiShangHai");
SuDu += v.GetIntOrDefault("SuDu");
BaoJi += v.GetIntOrDefault("BaoJi");
MingZhong += v.GetIntOrDefault("MingZhong");
ShanBi += v.GetIntOrDefault("ShanBi");
BaoJiLv += v.GetDoubleOrDefault("BaoJiLv");
MingZhongLv += v.GetDoubleOrDefault("MingZhongLv");
ShanBiLv += v.GetDoubleOrDefault("ShanBiLv");
}
}
示例9: SupplyPet
/// <summary>
/// 补充宠物的HP/MP
/// </summary>
/// <param name="v"></param>
/// <returns></returns>
private static bool SupplyPet(Variant v, Pet m_pet, ArenaBase model, string name)
{
bool use = false;
//庞物
if (m_pet == null) return use;
Variant pet = m_pet.Value;
if (pet == null) return use;
Variant moFa = pet.GetVariantOrDefault("MoFa");
Variant shengMing = pet.GetVariantOrDefault("ShengMing");
double dhp = v.GetDoubleOrDefault("HP");
double dmp = v.GetDoubleOrDefault("MP");
int hp, mp;
if (dhp <= 1)
{
hp = (int)(dhp * shengMing.GetIntOrDefault("M")); //百分比方式
}
else
{
hp = (int)(dhp);
}
if (dmp <= 1)
{
mp = (int)(dmp * moFa.GetIntOrDefault("M")); //百分比方式
}
else
{
mp = (int)(dmp);
}
if (hp > 0)
{
int sv = shengMing.GetIntOrDefault("V");
int need = shengMing.GetIntOrDefault("M") - sv;
if (need > 0)
{
m_pet.HP = Math.Min(need, hp) + sv;
shengMing["V"] = m_pet.HP;
use = true;
}
}
if (mp > 0)
{
int mv = moFa.GetIntOrDefault("V");
int need = moFa.GetIntOrDefault("M") - mv;
if (need > 0)
{
m_pet.MP = Math.Min(need, mp) + mv;
moFa["V"] = m_pet.MP;
use = true;
}
}
if (hp > 0 || mp > 0)
{
List<PetDetail> list = new List<PetDetail>();
PetDetail detail = new PetDetail(m_pet, name);
list.Add(detail);
model.CallAll(ArenaCommand.ArenaGoodsR, true, list);
m_pet.Save();
}
return use;
}
示例10: GetAwardCount
/// <summary>
/// 获取奖励数量
/// P: double //几率
/// Min: int //最小值
/// Max: int //最大值
/// </summary>
/// <param name="v">格式:{P:0.8,Min:2,Max:10}</param>
/// <returns></returns>
public static int GetAwardCount(Variant v)
{
if (v != null)
{
double p = v.GetDoubleOrDefault("P");
if (NumberRandom.RandomHit(p))
{
int min = v.GetIntOrDefault("Min");
int max = v.GetIntOrDefault("Max");
if (min >= max) return Math.Max(0, min);
return NumberRandom.Next(min, max + 1);
}
}
return 0;
}
示例11: GetPacketAwards
/// <summary>
/// 计算单个奖励包裹
/// P: double //获得的概率..
/// TMax :6 //最大获得数量
/// G_*1: P:double, Min:1,Max:2 //物品g1获得的概率为0.8...可获得1-2个..
/// G_*2: P:double, Min:1,Max:5 //...............
/// </summary>
/// <param name="packate">格式:{P:0.8,TMax:6,G_*1:{P:0.2,Min:1,Max:2},G_*2:{P:0.3, Min:1,Max:5},...}</param>
/// <param name="awards">奖励结果(物品ID:数量)</param>
public static void GetPacketAwards(Variant packate, Dictionary<string, int> awards)
{
//P: double 获得的概率.
double p = packate.GetDoubleOrDefault("P");
if (!NumberRandom.RandomHit(p)) return;
// TMax 最大获得数量
int maxCount = packate.GetIntOrDefault("TMax");
if (maxCount <= 0)
{
maxCount = 5;
}
maxCount = NumberRandom.Next(maxCount) + 1;
var awardP = GetPacketAwards(maxCount, packate);
foreach (var v in awardP)
{
awards.SetOrInc(v.Key, v.Value);
}
//// 已获得的物品数
//int currentCount = 0;
//foreach (var gg in packate)
//{
// if (maxCount <= currentCount)
// {
// return;
// }
// if (gg.Value is Variant)
// {
// int count = GetAwardCount(gg.Value as Variant);
// if (count > 0)
// {
// if (count + currentCount > maxCount)
// {
// count = maxCount - currentCount;
// }
// int rc;
// awards.TryGetValue(gg.Key, out rc);
// awards[gg.Key] = rc + count;
// currentCount += count;
// }
// }
//}
}
示例12: CheckMingZhong
/// <summary>
/// 检查是否命中
/// </summary>
/// <param name="p">攻击者</param>
/// <param name="target">接受攻击者</param>
/// <returns></returns>
protected bool CheckMingZhong(Variant p, Variant target)
{
return RandomHit(0.9 + (p.GetDoubleOrDefault("MingZhongLv") - target.GetDoubleOrDefault("ShanBiLv")) +
0.01 * (p.GetIntOrDefault("PetsLevel") - target.GetIntOrDefault("PetsLevel")));
}
示例13: CheckBaoJi
/// <summary>
/// 检查暴击,2倍受害
/// </summary>
/// <param name="p">攻击者</param>
/// <param name="target">接受攻击者</param>
/// <returns></returns>
protected bool CheckBaoJi(Variant p, Variant target)
{
return RandomHit(p.GetDoubleOrDefault("BaoJiLv") + 0.02 * (p.GetIntOrDefault("PetsLevel") - target.GetIntOrDefault("PetsLevel")));
}
示例14: GetAssistDouble
private double GetAssistDouble(Variant v)
{
if (v == null) return 0;
if (v.GetDateTimeOrDefault("T") >= DateTime.UtcNow)
{
return v.GetDoubleOrDefault("A");
}
return 0;
}