コード例 #1
0
ファイル: CorvinusAnt.cs プロジェクト: solymosi/hangyaboly
 public ItemEventArgs(Items.ItemBase Item) { this.Item = Item; }
コード例 #2
0
ファイル: ItemBase.cs プロジェクト: solymosi/hangyaboly
 /// <summary>
 /// Kiszámolja ennek az elemnek a távolságát egy másiktól
 /// </summary>
 /// <param name="Item">A másik elem</param>
 /// <returns>A kiszámolt távolság</returns>
 public virtual int DistanceFrom(ItemBase Item)
 {
     switch (this.Type)
     {
         case ItemType.EnemyAnt:
             switch (Item.Type)
             {
                 case ItemType.EnemyAnt: return Coordinate.GetDistanceBetween(((EnemyAnt)this).UnderlyingAnt, ((EnemyAnt)Item).UnderlyingAnt);
                 case ItemType.Bug: return Coordinate.GetDistanceBetween(((EnemyAnt)this).UnderlyingAnt, ((Bug)Item).UnderlyingBug);
                 case ItemType.Fruit: return Coordinate.GetDistanceBetween(((EnemyAnt)this).UnderlyingAnt, ((Fruit)Item).UnderlyingFruit);
                 case ItemType.Sugar: return Coordinate.GetDistanceBetween(((EnemyAnt)this).UnderlyingAnt, ((Sugar)Item).UnderlyingSugar);
                 default:
                     throw new ArgumentException("Invalid item type");
             }
         case ItemType.Bug:
             switch (Item.Type)
             {
                 case ItemType.EnemyAnt: return Coordinate.GetDistanceBetween(((Bug)this).UnderlyingBug, ((EnemyAnt)Item).UnderlyingAnt);
                 case ItemType.Bug: return Coordinate.GetDistanceBetween(((Bug)this).UnderlyingBug, ((Bug)Item).UnderlyingBug);
                 case ItemType.Fruit: return Coordinate.GetDistanceBetween(((Bug)this).UnderlyingBug, ((Fruit)Item).UnderlyingFruit);
                 case ItemType.Sugar: return Coordinate.GetDistanceBetween(((Bug)this).UnderlyingBug, ((Sugar)Item).UnderlyingSugar);
                 default:
                     throw new ArgumentException("Invalid item type");
             }
         case ItemType.Fruit:
             switch (Item.Type)
             {
                 case ItemType.EnemyAnt: return Coordinate.GetDistanceBetween(((Fruit)this).UnderlyingFruit, ((EnemyAnt)Item).UnderlyingAnt);
                 case ItemType.Bug: return Coordinate.GetDistanceBetween(((Fruit)this).UnderlyingFruit, ((Bug)Item).UnderlyingBug);
                 case ItemType.Fruit: return Coordinate.GetDistanceBetween(((Fruit)this).UnderlyingFruit, ((Fruit)Item).UnderlyingFruit);
                 case ItemType.Sugar: return Coordinate.GetDistanceBetween(((Fruit)this).UnderlyingFruit, ((Sugar)Item).UnderlyingSugar);
                 default:
                     throw new ArgumentException("Invalid item type");
             }
         case ItemType.Sugar:
             switch (Item.Type)
             {
                 case ItemType.EnemyAnt: return Coordinate.GetDistanceBetween(((Sugar)this).UnderlyingSugar, ((EnemyAnt)Item).UnderlyingAnt);
                 case ItemType.Bug: return Coordinate.GetDistanceBetween(((Sugar)this).UnderlyingSugar, ((Bug)Item).UnderlyingBug);
                 case ItemType.Fruit: return Coordinate.GetDistanceBetween(((Sugar)this).UnderlyingSugar, ((Fruit)Item).UnderlyingFruit);
                 case ItemType.Sugar: return Coordinate.GetDistanceBetween(((Sugar)this).UnderlyingSugar, ((Sugar)Item).UnderlyingSugar);
                 default:
                     throw new ArgumentException("Invalid item type");
             }
         default:
             throw new ArgumentException("Invalid item type");
     }
 }