Example #1
0
        public void Activate()
        {
            if (!Active)
            {
                enemycontroller.NewEnemyAddedEvent += new EnemyController.NewEnemyAddedHandler(EnemyAdded);
                enemycontroller.EnemyRemovedEvent  += new EnemyController.EnemyRemovedHandler(EnemyRemoved);

                csai.TickEvent     += new CSAI.TickHandler(Tick);
                csai.UnitIdleEvent += new CSAI.UnitIdleHandler(UnitIdle);

                if (csai.DebugOn)
                {
                    csai.RegisterVoiceCommand("tankscount", new CSAI.VoiceCommandHandler(VoiceCommandCountTanks));
                    csai.RegisterVoiceCommand("tanksmoveto", new CSAI.VoiceCommandHandler(VoiceCommandMoveTo));
                    csai.RegisterVoiceCommand("tanksattackpos", new CSAI.VoiceCommandHandler(VoiceCommandAttackPos));
                    csai.RegisterVoiceCommand("dumptanks", new CSAI.VoiceCommandHandler(VoiceCommandDumpTanks));
                }

                //unitcontroller.UnitAddedEvent += new UnitController.UnitAddedHandler( UnitAdded );
                //unitcontroller.UnitRemovedEvent += new UnitController.UnitRemovedHandler( UnitRemoved );
                //TankDefsById.Clear(); // note, dont just make a new one, because searchpackcoordinator wont get new one
                //unitcontroller.RefreshMyMemory( new UnitController.UnitAddedHandler( UnitAdded ) );

                //PackCoordinatorSelector.Activate();
                Active = true;
            }
        }
Example #2
0
        //  int BuildOffsetDistance = 25;
        // protected constructor to enforce Singleton pattern
        CommanderController()
        {
            random = new Random();

            csai = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile = LogFile.GetInstance();
            unitcontroller = UnitController.GetInstance();
            buildtable = BuildTable.GetInstance();
            metal = Metal.GetInstance();

            //            factorycontroller = PlayStyleManager.GetInstance().GetCurrentPlayStyle().GetFirstControllerOfType( typeof( IFactoryController ) ) as FactoryController;

            //csai.UnitFinishedEvent += new CSAI.UnitFinishedHandler( UnitFinished );
            //csai.UnitDestroyedEvent += new CSAI.UnitDestroyedHandler( UnitDestroyed );
            csai.UnitIdleEvent += new CSAI.UnitIdleHandler( UnitIdle );
            //csai.UnitDamagedEvent += new CSAI.UnitDamagedHandler( UnitDamaged );
            csai.TickEvent += new CSAI.TickHandler( Tick );

            unitcontroller.UnitAddedEvent += new UnitController.UnitAddedHandler( UnitAdded );
            unitcontroller.UnitRemovedEvent += new UnitController.UnitRemovedHandler( UnitRemoved );

            csai.RegisterVoiceCommand( "commandermove", new CSAI.VoiceCommandHandler( VoiceCommandMoveCommander ) );
            csai.RegisterVoiceCommand( "commandergetpos", new CSAI.VoiceCommandHandler( VoiceCommandCommanderGetPos ) );
            csai.RegisterVoiceCommand( "commanderbuildat", new CSAI.VoiceCommandHandler( VoiceCommandCommanderBuildAt ) );
            csai.RegisterVoiceCommand( "commanderbuild", new CSAI.VoiceCommandHandler( VoiceCommandCommanderBuild ) );
            csai.RegisterVoiceCommand( "commanderbuildpower", new CSAI.VoiceCommandHandler( VoiceCommandCommanderBuildPower ) );
            csai.RegisterVoiceCommand( "commanderbuildextractor", new CSAI.VoiceCommandHandler( VoiceCommandCommanderBuildExtractor ) );
            csai.RegisterVoiceCommand( "commanderisactive", new CSAI.VoiceCommandHandler( VoiceCommandCommanderIsActive ) );
        }
Example #3
0
        public void Activate()
        {
            if (!Active)
            {
                logfile.WriteLine("Activating Constructorcontroller");

                foreach (IFactoryController factorycontroller in playstyle.GetControllersOfType(typeof(IFactoryController)))
                {
                    factorycontroller.RegisterRequester(this);
                }

                radarcontroller = playstyle.GetFirstControllerOfType(typeof(IRadarController)) as IRadarController;

                csai.UnitIdleEvent       += new CSAI.UnitIdleHandler(UnitIdle);
                csai.TickEvent           += new CSAI.TickHandler(Tick);
                csai.UnitMoveFailedEvent += new CSAI.UnitMoveFailedHandler(UnitMoveFailed);

                csai.RegisterVoiceCommand("constructorshownextbuildsiteon", new CSAI.VoiceCommandHandler(VoiceCommandShowNextBuildSiteOn));
                csai.RegisterVoiceCommand("constructorshownextbuildsiteoff", new CSAI.VoiceCommandHandler(VoiceCommandShowNextBuildSiteOff));

                unitcontroller.UnitAddedEvent   += new UnitController.UnitAddedHandler(UnitAdded);
                unitcontroller.UnitRemovedEvent += new UnitController.UnitRemovedHandler(UnitRemoved);
                UnitDefByUnitId.Clear(); // note, dont just make a new one, because searchpackcoordinator wont get new one
                unitcontroller.RefreshMyMemory(new UnitController.UnitAddedHandler(UnitAdded));

                CheckIdleUnits();

                logfile.WriteLine("Constructorcontroller activated");
                Active = true;
            }
        }
Example #4
0
        public void Activate()
        {
            if (!Active)
            {
                factorycontroller = playstyle.GetFirstControllerOfType(typeof(IFactoryController)) as IFactoryController;
                factorycontroller.RegisterRequester(this);

                enemycontroller.NewEnemyAddedEvent += new EnemyController.NewEnemyAddedHandler(EnemyAdded);
                enemycontroller.EnemyRemovedEvent  += new EnemyController.EnemyRemovedHandler(EnemyRemoved);

                csai.TickEvent     += new CSAI.TickHandler(Tick);
                csai.UnitIdleEvent += new CSAI.UnitIdleHandler(UnitIdle);

                csai.RegisterVoiceCommand("tankscount", new CSAI.VoiceCommandHandler(VoiceCommandCountTanks));
                csai.RegisterVoiceCommand("tanksmoveto", new CSAI.VoiceCommandHandler(VoiceCommandMoveTo));
                csai.RegisterVoiceCommand("tanksattackpos", new CSAI.VoiceCommandHandler(VoiceCommandAttackPos));

                //      unitcontroller.UnitAddedEvent += new UnitController.UnitAddedHandler( UnitAdded );
                unitcontroller.UnitRemovedEvent += new UnitController.UnitRemovedHandler(UnitRemoved);
                TankDefsById.Clear(); // note, dont just make a new one, because searchpackcoordinator wont get new one
                unitcontroller.RefreshMyMemory(new UnitController.UnitAddedHandler(UnitAdded));

                //PackCoordinatorSelector.Activate();
                Active = true;
            }
        }
        public void Go()
        {
            csai = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile = LogFile.GetInstance();

            csai.RegisterVoiceCommand( "dumppoints", new CSAI.VoiceCommandHandler( this.DumpPoints ) );
            csai.RegisterVoiceCommand( "drawradii", new CSAI.VoiceCommandHandler( this.DrawRadii ) );
        }
        // string defaultplaystylename = "tankrush";

        PlayStyleManager()
        {
            csai       = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile    = LogFile.GetInstance();

            csai.RegisterVoiceCommand("showplaystyles", new CSAI.VoiceCommandHandler(this.VoiceCommandListPlayStyles));
            csai.RegisterVoiceCommand("chooseplaystyle", new CSAI.VoiceCommandHandler(this.VoiceCommandChoosePlayStyle));
        }
Example #7
0
        // string defaultplaystylename = "tankrush";
        PlayStyleManager()
        {
            csai = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile = LogFile.GetInstance();

            csai.RegisterVoiceCommand( "showplaystyles", new CSAI.VoiceCommandHandler( this.VoiceCommandListPlayStyles ) );
            csai.RegisterVoiceCommand( "chooseplaystyle", new CSAI.VoiceCommandHandler( this.VoiceCommandChoosePlayStyle ) );
        }
        // do we need this???  handled by specific controllers???
        //IntArrayList commanders = new IntArrayList();
        //IntArrayList constructors = new IntArrayList();
        //IntArrayList metalcollectors = new IntArrayList();
        //IntArrayList energycollectors = new IntArrayList();
        //IntArrayList groundattack = new IntArrayList();
        
        UnitController()
        {
            csai = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile = LogFile.GetInstance();
            unitdefhelp = new UnitDefHelp( aicallback );
            
            csai.UnitFinishedEvent += new CSAI.UnitFinishedHandler( this.NewUnitFinished );
            csai.UnitDestroyedEvent += new CSAI.UnitDestroyedHandler( this.UnitDestroyed );   

            csai.RegisterVoiceCommand( "killallfriendly", new CSAI.VoiceCommandHandler( this.VoiceCommandKillAllFriendly ) );
            csai.RegisterVoiceCommand( "countunits", new CSAI.VoiceCommandHandler( this.VoiceCommandCountUnits ) );
            
            logfile.WriteLine ("*UnitController initialized*");
        }
Example #9
0
        // do we need this???  handled by specific controllers???
        //IntArrayList commanders = new IntArrayList();
        //IntArrayList constructors = new IntArrayList();
        //IntArrayList metalcollectors = new IntArrayList();
        //IntArrayList energycollectors = new IntArrayList();
        //IntArrayList groundattack = new IntArrayList();

        UnitController()
        {
            csai        = CSAI.GetInstance();
            aicallback  = csai.aicallback;
            logfile     = LogFile.GetInstance();
            unitdefhelp = new UnitDefHelp(aicallback);

            csai.UnitFinishedEvent  += new CSAI.UnitFinishedHandler(this.NewUnitFinished);
            csai.UnitDestroyedEvent += new CSAI.UnitDestroyedHandler(this.UnitDestroyed);

            csai.RegisterVoiceCommand("killallfriendly", new CSAI.VoiceCommandHandler(this.VoiceCommandKillAllFriendly));
            csai.RegisterVoiceCommand("countunits", new CSAI.VoiceCommandHandler(this.VoiceCommandCountUnits));

            logfile.WriteLine("*UnitController initialized*");
        }
Example #10
0
        LosMap()
        {
            csai       = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile    = LogFile.GetInstance();

            unitcontroller = UnitController.GetInstance();
            unitcontroller.UnitAddedEvent   += new UnitController.UnitAddedHandler(UnitAdded);
            unitcontroller.UnitRemovedEvent += new UnitController.UnitRemovedHandler(UnitRemoved);

            friendlyunitpositionobserver = FriendlyUnitPositionObserver.GetInstance();

            csai.TickEvent += new CSAI.TickHandler(Tick);

            mapwidth  = aicallback.GetMapWidth();
            mapheight = aicallback.GetMapHeight();

            logfile.WriteLine("LosMap, create losarray");
            LastSeenFrameCount = new int[mapwidth / 2, mapheight / 2];
            logfile.WriteLine("losarray created, initializing...");
            for (int y = 0; y < mapheight / 2; y++)
            {
                for (int x = 0; x < mapwidth / 2; x++)
                {
                    LastSeenFrameCount[x, y] = -1000000;
                }
            }
            logfile.WriteLine("losarray initialized");

            if (csai.DebugOn)
            {
                csai.RegisterVoiceCommand("dumplosmap", new CSAI.VoiceCommandHandler(DumpLosMap));
            }
        }
        //  int BuildOffsetDistance = 25;

        // protected constructor to enforce Singleton pattern
        CommanderController()
        {
            random = new Random();

            csai           = CSAI.GetInstance();
            aicallback     = csai.aicallback;
            logfile        = LogFile.GetInstance();
            unitcontroller = UnitController.GetInstance();
            buildtable     = BuildTable.GetInstance();
            metal          = Metal.GetInstance();

//            factorycontroller = PlayStyleManager.GetInstance().GetCurrentPlayStyle().GetFirstControllerOfType( typeof( IFactoryController ) ) as FactoryController;

            //csai.UnitFinishedEvent += new CSAI.UnitFinishedHandler( UnitFinished );
            //csai.UnitDestroyedEvent += new CSAI.UnitDestroyedHandler( UnitDestroyed );
            csai.UnitIdleEvent += new CSAI.UnitIdleHandler(UnitIdle);
            //csai.UnitDamagedEvent += new CSAI.UnitDamagedHandler( UnitDamaged );
            csai.TickEvent += new CSAI.TickHandler(Tick);

            unitcontroller.UnitAddedEvent   += new UnitController.UnitAddedHandler(UnitAdded);
            unitcontroller.UnitRemovedEvent += new UnitController.UnitRemovedHandler(UnitRemoved);

            csai.RegisterVoiceCommand("commandermove", new CSAI.VoiceCommandHandler(VoiceCommandMoveCommander));
            csai.RegisterVoiceCommand("commandergetpos", new CSAI.VoiceCommandHandler(VoiceCommandCommanderGetPos));
            csai.RegisterVoiceCommand("commanderbuildat", new CSAI.VoiceCommandHandler(VoiceCommandCommanderBuildAt));
            csai.RegisterVoiceCommand("commanderbuild", new CSAI.VoiceCommandHandler(VoiceCommandCommanderBuild));
            csai.RegisterVoiceCommand("commanderbuildpower", new CSAI.VoiceCommandHandler(VoiceCommandCommanderBuildPower));
            csai.RegisterVoiceCommand("commanderbuildextractor", new CSAI.VoiceCommandHandler(VoiceCommandCommanderBuildExtractor));
            csai.RegisterVoiceCommand("commanderisactive", new CSAI.VoiceCommandHandler(VoiceCommandCommanderIsActive));
        }
Example #12
0
        Dictionary <int, int> AssistingConstructors = new Dictionary <int, int>(); // id of assisted keyed by id of assistor

        public Workflow()
        {
            csai       = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile    = LogFile.GetInstance();

            if (csai.DebugOn)
            {
                csai.RegisterVoiceCommand("dumpworkflow", new CSAI.VoiceCommandHandler(DumpWorkFlow));
            }
        }
        public Workflow()
        {
            csai = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile = LogFile.GetInstance();

            if (csai.DebugOn)
            {
                csai.RegisterVoiceCommand("dumpworkflow", new CSAI.VoiceCommandHandler(DumpWorkFlow));
            }
        }
        List<CommandInfo> recentcommands = new List<CommandInfo>(); // for debugging, logging

        #endregion Fields

        #region Constructors

        GiveOrderWrapper()
        {
            csai = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile = LogFile.GetInstance();

            csai.TickEvent += new CSAI.TickHandler(csai_TickEvent);
            if (csai.DebugOn)
            {
                csai.RegisterVoiceCommand("dumporders", new CSAI.VoiceCommandHandler(DumpOrders));
            }
        }
Example #15
0
        GiveOrderWrapper()
        {
            csai       = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile    = LogFile.GetInstance();

            csai.TickEvent += new CSAI.TickHandler(csai_TickEvent);
            if (csai.DebugOn)
            {
                csai.RegisterVoiceCommand("dumporders", new CSAI.VoiceCommandHandler(DumpOrders));
            }
        }
Example #16
0
        HeightMapPersistence()
        {
            LogFile logfile = LogFile.GetInstance();

            logfile.WriteLine("HeightMapPersistence");
            CSAI csai = CSAI.GetInstance();

            CSAI.VoiceCommandHandler handler = new CSAI.VoiceCommandHandler(this.SaveHandler);
            logfile.WriteLine("csai == null? " + (csai == null).ToString());
            logfile.WriteLine("handler == null? " + (handler == null).ToString());
            csai.RegisterVoiceCommand("saveheightmap", handler);
        }
Example #17
0
        EnemyController()
        {
            csai       = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile    = LogFile.GetInstance();

            autoshowenemies = csai.DebugOn;

            unitcontroller = UnitController.GetInstance();

            csai.TickEvent            += new CSAI.TickHandler(Tick);
            csai.EnemyEnterRadarEvent += new CSAI.EnemyEnterRadarHandler(this.EnemyEnterRadar);
            csai.EnemyEnterLOSEvent   += new CSAI.EnemyEnterLOSHandler(this.EnemyEnterLOS);
            csai.EnemyLeaveRadarEvent += new CSAI.EnemyLeaveRadarHandler(this.EnemyLeaveRadar);
            csai.EnemyDestroyedEvent  += new CSAI.EnemyDestroyedHandler(this.EnemyDestroyed);

            csai.RegisterVoiceCommand("enemiescount", new CSAI.VoiceCommandHandler(VoiceCommandCountEnemies));
            csai.RegisterVoiceCommand("showenemies", new CSAI.VoiceCommandHandler(VoiceCommandShowEnemies));
            csai.RegisterVoiceCommand("autoshowenemieson", new CSAI.VoiceCommandHandler(VoiceCommandAutoShowEnemiesOn));
            csai.RegisterVoiceCommand("autoshowenemiesoff", new CSAI.VoiceCommandHandler(VoiceCommandAutoShowEnemiesOff));

            unitdefhelp = new UnitDefHelp(aicallback);
        }
Example #18
0
        public Hashtable FactoriesByTypeName        = new Hashtable(); // deployedid of factories hashed by typename (eg "armvp")

        public FactoryController(IPlayStyle playstyle)
        {
            this.playstyle = playstyle;

            csai           = CSAI.GetInstance();
            aicallback     = csai.aicallback;
            logfile        = LogFile.GetInstance();
            buildtable     = BuildTable.GetInstance();
            unitcontroller = UnitController.GetInstance();

            unitdefhelp = new UnitDefHelp(aicallback);

            csai.RegisterVoiceCommand("dumpfactories", new CSAI.VoiceCommandHandler(DumpFactories));
        }
Example #19
0
        public FactoryController( IPlayStyle playstyle )
        {
            this.playstyle = playstyle;

            csai = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile = LogFile.GetInstance();
            buildtable = BuildTable.GetInstance();
            unitcontroller = UnitController.GetInstance();

            unitdefhelp = new UnitDefHelp( aicallback );

            csai.RegisterVoiceCommand( "dumpfactories", new CSAI.VoiceCommandHandler( DumpFactories ) );
        }
        EnemyController()
        {
            csai = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile = LogFile.GetInstance();

            autoshowenemies = csai.DebugOn;

            unitcontroller = UnitController.GetInstance();

            csai.TickEvent += new CSAI.TickHandler( Tick );
            csai.EnemyEnterRadarEvent += new CSAI.EnemyEnterRadarHandler( this.EnemyEnterRadar );
            csai.EnemyEnterLOSEvent += new CSAI.EnemyEnterLOSHandler( this.EnemyEnterLOS );
            csai.EnemyLeaveRadarEvent += new CSAI.EnemyLeaveRadarHandler( this.EnemyLeaveRadar );
            csai.EnemyDestroyedEvent += new CSAI.EnemyDestroyedHandler( this.EnemyDestroyed );

            csai.RegisterVoiceCommand( "enemiescount", new CSAI.VoiceCommandHandler( VoiceCommandCountEnemies ) );
            csai.RegisterVoiceCommand( "showenemies", new CSAI.VoiceCommandHandler( VoiceCommandShowEnemies ) );
            csai.RegisterVoiceCommand( "autoshowenemieson", new CSAI.VoiceCommandHandler( VoiceCommandAutoShowEnemiesOn ) );
            csai.RegisterVoiceCommand( "autoshowenemiesoff", new CSAI.VoiceCommandHandler( VoiceCommandAutoShowEnemiesOff ) );

            unitdefhelp = new UnitDefHelp( aicallback );
        }
Example #21
0
        Ownership()
        {
            csai       = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile    = LogFile.GetInstance();

            csai.UnitCreatedEvent   += new CSAI.UnitCreatedHandler(csai_UnitCreatedEvent);
            csai.UnitDestroyedEvent += new CSAI.UnitDestroyedHandler(csai_UnitDestroyedEvent);
            csai.UnitFinishedEvent  += new CSAI.UnitFinishedHandler(csai_UnitFinishedEvent);

            if (csai.DebugOn)
            {
                csai.RegisterVoiceCommand("dumpownership", new CSAI.VoiceCommandHandler(DumpOwnership));
            }
        }
        Dictionary<int, OwnershipOrder> ordersbyconstructorid = new Dictionary<int, OwnershipOrder>(); // index of orders by constructorid, to allow removal later

        #endregion Fields

        #region Constructors

        Ownership()
        {
            csai = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile = LogFile.GetInstance();

            csai.UnitCreatedEvent += new CSAI.UnitCreatedHandler(csai_UnitCreatedEvent);
            csai.UnitDestroyedEvent += new CSAI.UnitDestroyedHandler(csai_UnitDestroyedEvent);
            csai.UnitFinishedEvent += new CSAI.UnitFinishedHandler(csai_UnitFinishedEvent);

            if (csai.DebugOn)
            {
                csai.RegisterVoiceCommand("dumpownership", new CSAI.VoiceCommandHandler(DumpOwnership));
            }
        }
Example #23
0
        // protected constructor to force Singleton instantiation
        Metal()
        {
            csai = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile = LogFile.GetInstance();
            unitcontroller = UnitController.GetInstance();

            unitdefhelp = new UnitDefHelp( aicallback );

            ExtractorRadius = aicallback.GetExtractorRadius();

            unitcontroller.UnitAddedEvent += new UnitController.UnitAddedHandler( UnitAdded );
            unitcontroller.UnitRemovedEvent += new UnitController.UnitRemovedHandler( UnitRemoved );

            csai.RegisterVoiceCommand( "showmetalspots", new CSAI.VoiceCommandHandler( this.DrawMetalSpotsCommand ) );
        }
Example #24
0
        }       // Singleton pattern

        Metal() // protected constructor to force Singleton instantiation
        {
            csai           = CSAI.GetInstance();
            aicallback     = csai.aicallback;
            logfile        = LogFile.GetInstance();
            unitcontroller = UnitController.GetInstance();

            unitdefhelp = new UnitDefHelp(aicallback);

            ExtractorRadius = aicallback.GetExtractorRadius();

            unitcontroller.UnitAddedEvent   += new UnitController.UnitAddedHandler(UnitAdded);
            unitcontroller.UnitRemovedEvent += new UnitController.UnitRemovedHandler(UnitRemoved);

            csai.RegisterVoiceCommand("showmetalspots", new CSAI.VoiceCommandHandler(this.DrawMetalSpotsCommand));
        }
Example #25
0
        public void Activate()
        {
            if (!Active)
            {
                csai.TickEvent += new CSAI.TickHandler(Tick);
                csai.RegisterVoiceCommand("countscouts", new CSAI.VoiceCommandHandler(VoiceCommandCountScouts));

                enemycontroller.NewEnemyAddedEvent += new EnemyController.NewEnemyAddedHandler(EnemyAdded);

                unitcontroller.UnitAddedEvent   += new UnitController.UnitAddedHandler(UnitAdded);
                unitcontroller.UnitRemovedEvent += new UnitController.UnitRemovedHandler(UnitRemoved);
                ScoutUnitDefsById.Clear(); // note, dont just make a new one, because searchpackcoordinator wont get new one
                unitcontroller.RefreshMyMemory(new UnitController.UnitAddedHandler(UnitAdded));

                searchcoordinator.Activate();
                Active = true;
            }
        }
        public void Activate()
        {
            if (!Active)
            {
                foreach (IFactoryController factorycontroller in playstyle.GetControllersOfType(typeof(IFactoryController)))
                {
                    factorycontroller.RegisterRequester(this);
                }

                csai.TickEvent += new CSAI.TickHandler(Tick);
                csai.RegisterVoiceCommand("countscouts", new CSAI.VoiceCommandHandler(VoiceCommandCountScouts));

                unitcontroller.UnitAddedEvent   += new UnitController.UnitAddedHandler(UnitAdded);
                unitcontroller.UnitRemovedEvent += new UnitController.UnitRemovedHandler(UnitRemoved);
                ScoutUnitDefsById.Clear(); // note, dont just make a new one, because searchpackcoordinator wont get new one
                unitcontroller.RefreshMyMemory(new UnitController.UnitAddedHandler(UnitAdded));

                searchcoordinator.Activate();
                Active = true;
            }
        }
Example #27
0
        BuildMap()
        {
            csai       = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile    = LogFile.GetInstance();

            unitdefhelp    = new UnitDefHelp(aicallback);
            unitcontroller = UnitController.GetInstance();

            csai.UnitCreatedEvent   += new CSAI.UnitCreatedHandler(UnitCreated);
            csai.UnitDestroyedEvent += new CSAI.UnitDestroyedHandler(UnitDestroyed);

            unitcontroller.UnitAddedEvent += new UnitController.UnitAddedHandler(UnitCreated);

            if (csai.DebugOn)
            {
                csai.RegisterVoiceCommand("dumpbuildmap", new CSAI.VoiceCommandHandler(DumpBuildMap));
            }

            Init();
        }
        // note: sector size for scout probably should be 4 times larger than radar map squaresize, ie should be 256 * 256 mappos
        public void Go()
        {
            csai = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile = LogFile.GetInstance();

            csai.TickEvent+= new CSAI.TickHandler( Tick );

            csai.RegisterVoiceCommand( "dumplos", new CSAI.VoiceCommandHandler( this.DumpLos ) );
            csai.RegisterVoiceCommand( "dumpradar", new CSAI.VoiceCommandHandler( this.DumpRadar ) );
            csai.RegisterVoiceCommand( "dumpcentreheights", new CSAI.VoiceCommandHandler( this.DumpCentreHeights ) );
            csai.RegisterVoiceCommand( "dumpfeatures", new CSAI.VoiceCommandHandler( this.DumpFeaturesMap ) );
            csai.RegisterVoiceCommand( "dumpslopes", new CSAI.VoiceCommandHandler( this.DumpSlopes ) );
            csai.RegisterVoiceCommand( "dumpbuildmap", new CSAI.VoiceCommandHandler( this.DumpBuildMap ) );
            csai.RegisterVoiceCommand( "dumpmovementareas", new CSAI.VoiceCommandHandler( this.DumpMovementAreas ) );
            csai.RegisterVoiceCommand( "dumplosmap", new CSAI.VoiceCommandHandler( this.DumpLosMap ) );
        }
Example #29
0
        LosMap()
        {
            csai = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile = LogFile.GetInstance();

            unitcontroller = UnitController.GetInstance();
            unitcontroller.UnitAddedEvent += new UnitController.UnitAddedHandler( UnitAdded );
            unitcontroller.UnitRemovedEvent += new UnitController.UnitRemovedHandler( UnitRemoved );

            friendlyunitpositionobserver = FriendlyUnitPositionObserver.GetInstance();

            csai.TickEvent += new CSAI.TickHandler( Tick );

            mapwidth = aicallback.GetMapWidth();
            mapheight = aicallback.GetMapHeight();

            logfile.WriteLine( "LosMap, create losarray" );
            LastSeenFrameCount = new int[ mapwidth / 2, mapheight / 2 ];
            logfile.WriteLine( "losarray created, initializing..." );
            for( int y = 0; y < mapheight / 2; y++ )
            {
                for( int x = 0; x < mapwidth / 2; x++ )
                {
                    LastSeenFrameCount[ x, y ] = -1000000;
                }
            }
            logfile.WriteLine( "losarray initialized" );

            if (csai.DebugOn)
            {
                csai.RegisterVoiceCommand("dumplosmap", new CSAI.VoiceCommandHandler(DumpLosMap));
            }
        }