本文整理汇总了C#中Equipment.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Equipment.GetType方法的具体用法?C# Equipment.GetType怎么用?C# Equipment.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Equipment
的用法示例。
在下文中一共展示了Equipment.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddEquipment
public List<Equipment> AddEquipment(Equipment equipment)
{
List<Equipment> toBeRemoved = new List<Equipment>();
for(int i=0;i<equipped.Count;i++){
if(equipped[i].GetType() == equipment.GetType()){
AddToInventory(equipped[i],1);
equipped[i] = equipment;
toBeRemoved.Add(equipped[i]);
return null;
}
if(equipment is TwoHanded){
if(equipped[i] is OneHanded)
toBeRemoved.Add(equipped[i]);
}
if(equipment is OneHanded){
if(equipped[i] is TwoHanded)
toBeRemoved.Add(equipped[i]);
}
}
foreach(Equipment equip in toBeRemoved){
AddToInventory(equip,1);
equipped.Remove(equip);
}
equipped.Add(equipment);
return null;
}
示例2: GetCopy
static public Equipment GetCopy(Equipment e)
{
object copy = Activator.CreateInstance(e.GetType());
Equipment output = (Equipment)copy;
output.Name = e.Name;
output.Health = e.Health;
output.Mana = e.Mana;
output.MoveSpeed = e.MoveSpeed;
output.MagicDMGMultiplication = e.MagicDMGMultiplication;
output.PhysDMGMultiplication = e.PhysDMGMultiplication;
output.JumpForce = e.JumpForce;
output.Slot = e.Slot;
output.Quality = e.Quality;
output.StaticIDEquipment = e.StaticIDEquipment;
return output;
}
示例3: AddEquipment
public void AddEquipment(Equipment equipment)
{
if(equipment is Armor) {
foreach(Armor armor in armors) {
if(armor.GetType()==equipment.GetType()){
int index = armors.IndexOf(armor);
AddToInventory(armor,1);
armors[index] = equipment as Armor;
RemoveFromInventory(equipment,1);
return;
}
}
armors.Add(equipment as Armor);
}else if(equipment is Weapon){
if(equipment is TwoHanded){
foreach(Weapon weapon in weapons){
AddToInventory(weapon,1);
}
weapons.Clear();
weapons.Add(equipment as Weapon);
}else if(equipment is OneHanded){
if(weapons.Count < 2){
if(weapons.Count==1&&weapons[0] is TwoHanded){
AddToInventory(weapons[0] as Weapon,1);
weapons[0] = equipment as Weapon;
}
else
weapons.Add(equipment as Weapon);
}else{
AddToInventory(weapons[0] as Weapon,1);
weapons[0] = weapons[1];
weapons[1] = equipment as Weapon;
}
}
}
RemoveFromInventory(equipment,1);
}