示例#1
0
 public Direction Directionto(Unit u)
 {
     if (u.GetType() == typeof(deadshot))
     {
         deadshot d = (deadshot)u;
         if (d.Xpos < Xpos)
         {
             return(Direction.North);
         }
         else if (d.Ypos > Ypos)
         {
             return(Direction.East);
         }
         else if (d.Xpos > xpos)
         {
             return(Direction.South);
         }
         else
         {
             return(Direction.West);
         }
     }
     else
     {
         return(Direction.North);
     }
 }
示例#2
0
 private int Distance(Unit u)
 {
     if (u.GetType() == typeof(deadshot))
     {
         deadshot ds = (deadshot)u;
         int      d  = Math.Abs(Xpos - ds.Xpos) + Math.Abs(Ypos - ds.Ypos);
         return(d);
     }
     else
     {
         return(0);
     }
 }
示例#3
0
 public override bool Range(Unit u)
 {
     if (u.GetType() == typeof(deadshot))
     {
         deadshot d = (deadshot)u;
         if (Distance(u) <= Attackrange)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }