当前位置: 首页>>代码示例>>C#>>正文


C# Equipment.GetType方法代码示例

本文整理汇总了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;
 }
开发者ID:hitnoodle,项目名称:TGK-RPG,代码行数:26,代码来源:FighterInventory.cs

示例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;
    }
开发者ID:SuperJura,项目名称:RPGGame,代码行数:17,代码来源:Equipment.cs

示例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);
 }
开发者ID:hitnoodle,项目名称:TGK-RPG,代码行数:37,代码来源:FighterInventory.cs


注:本文中的Equipment.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。