Пример #1
0
 async Task<bool> ScoutPosition(Position position) 
 {
     current_position = position;
     ScoutingProbe.theUnit.move(position);
     current_task = new TaskCompletionSource<bool>();
     return await current_task.Task;
 }
Пример #2
0
 public void onEnemyShown(object sender, UnitArgs args)
 {
     Unit unit = args.Unit.theUnit;
     foreach (var location in State.BaseLocations)
     {
         if (enemy_position == null && location.getRegion().getPolygon().isInside(unit.getPosition()))
         {
             enemy_position = location.getPosition();
             bwapi.Broodwar.printf(String.Format("Enemy base spotted"));
         }
     }
 }
Пример #3
0
 public static UnitCommand attackMove(Unit unit, Position target) {
   UnitCommand ret = new UnitCommand(bwapiPINVOKE.UnitCommand_attackMove(Unit.getCPtr(unit), Position.getCPtr(target)), true);
   if (bwapiPINVOKE.SWIGPendingException.Pending) throw bwapiPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
Пример #4
0
 public Position getTargetPosition() {
   Position ret = new Position(bwapiPINVOKE.UnitCommand_getTargetPosition(swigCPtr), true);
   return ret;
 }
Пример #5
0
 public static UnitCommand useTech(Unit unit, TechType tech, Position target) {
   UnitCommand ret = new UnitCommand(bwapiPINVOKE.UnitCommand_useTech__SWIG_1(Unit.getCPtr(unit), TechType.getCPtr(tech), Position.getCPtr(target)), true);
   if (bwapiPINVOKE.SWIGPendingException.Pending) throw bwapiPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
Пример #6
0
 public virtual Position getScreenPosition() {
   Position ret = new Position(bwapiPINVOKE.Game_getScreenPosition(swigCPtr), true);
   return ret;
 }
Пример #7
0
 public virtual bool useTech(TechType tech, Position target) {
   bool ret = bwapiPINVOKE.Unit_useTech__SWIG_1(swigCPtr, TechType.getCPtr(tech), Position.getCPtr(target));
   if (bwapiPINVOKE.SWIGPendingException.Pending) throw bwapiPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
Пример #8
0
 public virtual bool unloadAll(Position target) {
   bool ret = bwapiPINVOKE.Unit_unloadAll__SWIG_1(swigCPtr, Position.getCPtr(target));
   if (bwapiPINVOKE.SWIGPendingException.Pending) throw bwapiPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
Пример #9
0
 public virtual Position getRallyPosition() {
   Position ret = new Position(bwapiPINVOKE.Unit_getRallyPosition(swigCPtr), true);
   return ret;
 }
Пример #10
0
        public virtual AIState Run()
        {
            foreach (var choke in bwta.getChokepoints())
            {
                var pos = choke.getCenter();                
                bwapi.Broodwar.drawCircleMap(pos.xConst(), pos.yConst(), Convert.ToInt32(choke.getSides().first.getDistance(choke.getSides().second)), new Color(255, 0, 0));
                bwapi.Broodwar.drawLineMap(choke.getSides().first.xConst(), choke.getSides().first.yConst(), choke.getSides().second.xConst(), choke.getSides().second.yConst(), new Color(0, 255, 0));
            }

            foreach (var item in State.buildingQueue)
            {
                int tile_width = bwapi.getUnitType(item.Type).tileWidth();
                int tile_height = bwapi.getUnitType(item.Type).tileHeight();

                var pos = new Position(32 * item.TilePosition.xConst() + (tile_width * 32) / 2, 32 * item.TilePosition.yConst() + (tile_height * 32) / 2);
                bwapi.Broodwar.drawCircleMap(pos.xConst(), pos.yConst(), Math.Max(tile_width, tile_height) * 16, new Color(0, 255, 255));

                pos = new Position(32 * item.ActualPosition.xConst() + (tile_width * 32) / 2, 32 * item.ActualPosition.yConst() + (tile_height * 32) / 2);
                bwapi.Broodwar.drawCircleMap(pos.xConst(), pos.yConst(), Math.Max(tile_width, tile_height) * 16, new Color(0, 255, 0));
            }

            // Old format
            var tmp = new Dictionary<TilePosition, TaskCompletionSource<bool>>();
            foreach (var rev_task in RevelationTasks)
            {
                if (bwapi.Broodwar.isVisible(rev_task.Key) && bwapi.Broodwar.isVisible(new TilePosition(rev_task.Key.xConst() + 3, rev_task.Key.yConst() + 3)))
                {
                    var task = rev_task.Value;
                    task.SetResult(true);
                }
                else
                {
                    tmp.Add(rev_task.Key, rev_task.Value);
                }
            }
            RevelationTasks = tmp;
            //

            foreach (var module in running_modules)
            {
                module.Run();
            }
            processBuildingQueue();
            return this;
        }
Пример #11
0
        //

        public async virtual void Scout()
        {
            if (State.analysis_complete && !is_scouting)
            {                
                var probe = requestUnit(EcoAI);
                using (Scouter scouter = new Scouter(State))
                {
                    transferUnitTo(probe, scouter);
                    running_modules.Add(scouter);
                    is_scouting = true;
                    enemy_position = await scouter.Scout();
                    scouter.YieldUnit();
                    // is_scouting = false;
                    running_modules.Remove(scouter);
                    if (probe.Alive)
                    {
                        transferUnitTo(probe, EcoAI);
                    }
                }               
            }
        }
Пример #12
0
        public void onNukeDetect(Position target)
        {

        }
Пример #13
0
 public virtual void pingMinimap(Position p) {
   bwapiPINVOKE.Game_pingMinimap__SWIG_1(swigCPtr, Position.getCPtr(p));
   if (bwapiPINVOKE.SWIGPendingException.Pending) throw bwapiPINVOKE.SWIGPendingException.Retrieve();
 }
Пример #14
0
 public virtual void setScreenPosition(Position p) {
   bwapiPINVOKE.Game_setScreenPosition__SWIG_1(swigCPtr, Position.getCPtr(p));
   if (bwapiPINVOKE.SWIGPendingException.Pending) throw bwapiPINVOKE.SWIGPendingException.Retrieve();
 }
Пример #15
0
 public TilePosition(Position position) : this(bwapiPINVOKE.new_TilePosition__SWIG_1(Position.getCPtr(position)), true) {
   if (bwapiPINVOKE.SWIGPendingException.Pending) throw bwapiPINVOKE.SWIGPendingException.Retrieve();
 }
Пример #16
0
 public virtual double getDistance(Position target) {
   double ret = bwapiPINVOKE.Unit_getDistance__SWIG_1(swigCPtr, Position.getCPtr(target));
   if (bwapiPINVOKE.SWIGPendingException.Pending) throw bwapiPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
Пример #17
0
 public virtual Position getTargetPosition() {
   Position ret = new Position(bwapiPINVOKE.Bullet_getTargetPosition(swigCPtr), true);
   return ret;
 }
Пример #18
0
 public virtual bool attackMove(Position target) {
   bool ret = bwapiPINVOKE.Unit_attackMove(swigCPtr, Position.getCPtr(target));
   if (bwapiPINVOKE.SWIGPendingException.Pending) throw bwapiPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
Пример #19
0
 void IStarcraftBot.onNukeDetect(SWIG.BWAPI.Position target)
 {
     //throw new NotImplementedException();
 }
Пример #20
0
 public virtual bool rightClick(Position target) {
   bool ret = bwapiPINVOKE.Unit_rightClick__SWIG_0(swigCPtr, Position.getCPtr(target));
   if (bwapiPINVOKE.SWIGPendingException.Pending) throw bwapiPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
Пример #21
0
 public static UnitCommand setRallyPoint(Unit unit, Position target) {
   UnitCommand ret = new UnitCommand(bwapiPINVOKE.UnitCommand_setRallyPoint__SWIG_0(Unit.getCPtr(unit), Position.getCPtr(target)), true);
   if (bwapiPINVOKE.SWIGPendingException.Pending) throw bwapiPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
Пример #22
0
 public virtual void onNukeDetect(Position target) {
   bwapiPINVOKE.AIModule_onNukeDetect(swigCPtr, Position.getCPtr(target));
   if (bwapiPINVOKE.SWIGPendingException.Pending) throw bwapiPINVOKE.SWIGPendingException.Retrieve();
 }
Пример #23
0
 public static Event NukeDetect(Position target) {
   Event ret = new Event(bwapiPINVOKE.Event_NukeDetect(Position.getCPtr(target)), true);
   if (bwapiPINVOKE.SWIGPendingException.Pending) throw bwapiPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }