Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 20th, 2012  |  syntax: C#  |  size: 1.76 KB  |  hits: 24  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. class Program
  2.     {
  3.         private static UnitType _unitType;
  4.  
  5.         static void Main(string[] args)
  6.         {
  7.             if(args != null)
  8.             {
  9.                 if(!Enum.TryParse(args[0], out _unitType))
  10.                 {
  11.                     Game.Print(string.Format("Could not parse {0} as a unit type allowed unit types are: ", args[0]));
  12.                     foreach(var type in Enum.GetNames(typeof(UnitType)))
  13.                     {
  14.                         Game.Print(type);
  15.                     }
  16.                     return;
  17.                 }
  18.             }
  19.             else
  20.             {
  21.                 Game.Print("No unit type provided");
  22.                 return;
  23.             }
  24.             Game.OnDrawEvent += GameOnOnDrawEvent;
  25.         }
  26.  
  27.         private static void GameOnOnDrawEvent(EventArgs eventArgs)
  28.         {
  29.             if (Game.Ingame)
  30.             {
  31.                 int counter = 0;
  32.                 var gizmos = Unit.Get().Where(x => x.Type == _unitType).ToArray();
  33.                 foreach (var gizmo in gizmos)
  34.                 {
  35.                     if (gizmo.Name.StartsWith("!!"))
  36.                         continue;
  37.  
  38.                     var text = string.Format(
  39.                         "{0}. {1}, ActorID = {2}, Range = {3}",
  40.                         counter,
  41.                         gizmo.Name.Replace("\n", ""),
  42.                         gizmo.ActorId,
  43.                         Range(gizmo)
  44.                     );
  45.                     Draw.DrawText(10.0f, 10.0f + 27.0f * counter++, 0x16A, 0x16, 0xFFFFFFFF, text);
  46.                 }
  47.             }
  48.         }
  49.  
  50.         private static float Range(Unit unit)
  51.         {
  52.             return (float)Math.Sqrt(Math.Pow(Me.X - unit.X, 2) + Math.Pow(Me.Y - unit.Y, 2));
  53.         }
  54.     }