本文整理汇总了C#中System.Collections.Hashtable.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Hashtable.Equals方法的具体用法?C# Hashtable.Equals怎么用?C# Hashtable.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Hashtable
的用法示例。
在下文中一共展示了Hashtable.Equals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SlotToSlot
private bool SlotToSlot(int prevSlotNo, Hashtable prevArmies, int slotNo, Hashtable armies)
{
// get previous army InCastle
if (!prevArmies.ContainsKey(prevSlotNo))
{
// error
return false;
}
Army prevArmy = (Army)prevArmies[prevSlotNo];
if (armies.ContainsKey(slotNo))
{
// merge / exchange slot
Army army = (Army)armies[slotNo];
if (army._id == prevArmy._id)
{
// merge
if (prevArmies.Count <= 1)
{
// hero must has at least one slot
if (IsHeroEmptyAfterRemove(prevArmies))
{
MessageBox.Show("Hero must has a least 1 army.");
return false;
}
}
army._qty += prevArmy._qty;
prevArmies.Remove(prevSlotNo);
// set hero Id
army._heroId = GetHeroId(armies);
}
else
{
// exchange slot
prevArmy._slotNo = slotNo;
army._slotNo = prevSlotNo;
armies[slotNo] = prevArmy;
prevArmies[prevSlotNo] = army;
// set hero Id
prevArmy._heroId = GetHeroId(armies);
army._heroId = GetHeroId(prevArmies);
}
}
else
{
// move
// if not move in same armies, check empy armies
if (!prevArmies.Equals(armies) && prevArmies.Count <= 1)
{
// hero must has at least one slot
if (IsHeroEmptyAfterRemove(prevArmies))
{
MessageBox.Show("Hero must has a least 1 army.");
return false;
}
}
prevArmy._slotNo = slotNo;
if (armies.ContainsKey(slotNo))
armies[slotNo] = prevArmy;
else
armies.Add(slotNo, prevArmy);
prevArmies.Remove(prevSlotNo);
// set hero Id
prevArmy._heroId = GetHeroId(armies);
}
return true;
}
示例2: IsHeroEmptyAfterRemove
private bool IsHeroEmptyAfterRemove(Hashtable prevArmies)
{
// hero must has at least one slot
if ((this._town._heroVisit != null && prevArmies.Equals(this._town._heroVisit._armyKSlots))
|| (this._town._heroInCastle != null && prevArmies.Equals(this._town._heroInCastle._armyKSlots)))
return true;
return false;
}