Exemplo n.º 1
0
        // protected constructor to force Singleton instantiation
        BuildTable()
        {
            CSAI = CSAI.GetInstance();
            aicallback = CSAI.aicallback;
            logfile = LogFile.GetInstance();

            modname = aicallback.GetModName();

            int numunitdefs = aicallback.GetNumUnitDefs();
            logfile.WriteLine( "calling GetUnitDefList, for " + numunitdefs + " units ... " );
            //availableunittypes = aicallback.GetUnitDefList();
            availableunittypes = new IUnitDef[numunitdefs + 1];
            for (int i = 1; i <= numunitdefs; i++)
            {
                availableunittypes[i] = aicallback.GetUnitDefByTypeId(i);
                logfile.WriteLine( i + " " + availableunittypes[i].name + " " + availableunittypes[i].humanName );
            }
            logfile.WriteLine( "... done" );

            if( !LoadCache( modname ) )
            {
                aicallback.SendTextMsg( "Creating new cachefile for mod " + modname, 0 );
                GenerateBuildTable( modname );
                SaveCache( modname );
            }
        }
        //  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));
        }
Exemplo n.º 3
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));
            }
        }
Exemplo n.º 4
0
        // protected constructor to force Singleton instantiation
        BuildTable()
        {
            CSAI = CSAI.GetInstance();
            aicallback = CSAI.aicallback;
            logfile = LogFile.GetInstance();

            modname = aicallback.GetModName();

            logfile.WriteLine( "calling GetUnitDefList... " );
            List<IUnitDef> unittypeslist = new List<IUnitDef>();
            int numunittypes = aicallback.GetNumUnitDefs();
            for (int i = 1; i <= numunittypes; i++)
            {
                unittypeslist.Add( aicallback.GetUnitDefByTypeId( i ) );
            }
            availableunittypes = unittypeslist.ToArray();
            logfile.WriteLine( "... done" );

            if( !LoadCache( modname ) )
            {
                aicallback.SendTextMsg( "Creating new cachefile for mod " + modname, 0 );
                GenerateBuildTable( modname );
                SaveCache( modname );
            }
        }
Exemplo n.º 5
0
        public TankController(IPlayStyle playstyle)
        {
            this.playstyle = playstyle;

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

            unitdefhelp     = new UnitDefHelp(aicallback);
            unitcontroller  = UnitController.GetInstance();
            enemycontroller = EnemyController.GetInstance();
            buildtable      = BuildTable.GetInstance();

            enemyselector = new EnemySelector(110, false, false);

            attackpackcoordinator       = new AttackPackCoordinator(TankDefsById);
            spreadsearchpackcoordinator = new SpreadSearchPackCoordinator(TankDefsById);
            movetopackcoordinator       = new MoveToPackCoordinator(TankDefsById);
            guardpackcoordinator        = new GuardPackCoordinator(TankDefsById);

            packcoordinatorselector = new PackCoordinatorSelector();
            packcoordinatorselector.LoadCoordinator(attackpackcoordinator);
            packcoordinatorselector.LoadCoordinator(spreadsearchpackcoordinator);
            packcoordinatorselector.LoadCoordinator(movetopackcoordinator);
            packcoordinatorselector.LoadCoordinator(guardpackcoordinator);

            logfile.WriteLine("*TankController Initialized*");
        }
Exemplo n.º 6
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 ) );
        }
        public TankController( IPlayStyle playstyle )
        {
            this.playstyle = playstyle;

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

            unitdefhelp = new UnitDefHelp( aicallback );
            unitcontroller = UnitController.GetInstance();
            enemycontroller = EnemyController.GetInstance();
            buildtable = BuildTable.GetInstance();

            enemyselector = new EnemySelector( 110, false, false );

            attackpackcoordinator = new AttackPackCoordinator( TankDefsById );
            spreadsearchpackcoordinator = new SpreadSearchPackCoordinator( TankDefsById );
            movetopackcoordinator = new MoveToPackCoordinator( TankDefsById );
            guardpackcoordinator = new GuardPackCoordinator( TankDefsById );

            packcoordinatorselector = new PackCoordinatorSelector();
            packcoordinatorselector.LoadCoordinator( attackpackcoordinator );
            packcoordinatorselector.LoadCoordinator( spreadsearchpackcoordinator );
            packcoordinatorselector.LoadCoordinator( movetopackcoordinator );
            packcoordinatorselector.LoadCoordinator( guardpackcoordinator );

            logfile.WriteLine( "*TankController Initialized*" );
        }
        public TankController( Dictionary< int,IUnitDef>UnitDefsById, IUnitDef typicalunitdef)
        {
            csai = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile = LogFile.GetInstance();

            this.DefsById = UnitDefsById;
            this.typicalunitdef = typicalunitdef;
            
            unitcontroller = UnitController.GetInstance();
            enemycontroller = EnemyController.GetInstance();
            buildtable = BuildTable.GetInstance();

            enemyselector = new EnemySelector2( typicalunitdef.speed * 2, typicalunitdef );
            // speed here is experimental

            attackpackcoordinator = new AttackPackCoordinator(DefsById);
            spreadsearchpackcoordinator = new SpreadSearchPackCoordinator(DefsById);
            movetopackcoordinator = new MoveToPackCoordinator(DefsById);
            guardpackcoordinator = new GuardPackCoordinator(DefsById);
            
            packcoordinatorselector = new PackCoordinatorSelector();
            packcoordinatorselector.LoadCoordinator( attackpackcoordinator );
            packcoordinatorselector.LoadCoordinator( spreadsearchpackcoordinator );
            packcoordinatorselector.LoadCoordinator( movetopackcoordinator );
            packcoordinatorselector.LoadCoordinator( guardpackcoordinator );

            logfile.WriteLine( "*TankController Initialized*" );
        }
Exemplo n.º 9
0
 public void InitAI( IAICallback aicallback, int team )
 {
     this.aicallback = aicallback;
     this.team = team;
     aicallback.SendTextMsg( "Hello from Mono AbicWrappers", 0 );
     aicallback.SendTextMsg( "The map name is: " + aicallback.GetMapName(), 0 );
     aicallback.SendTextMsg( "Our ally team is: " + aicallback.GetMyTeam(), 0 );
     
     //int features[10000 + 1];
     //int numfeatures = IAICallback_GetFeatures( aicallback, features, 10000 );
     //sprintf( buffer, "Num features is: %i", numfeatures );
     //IAICallback_SendTextMsg( aicallback, buffer, 0 );
     
     //const FeatureDef *featuredef = IAICallback_GetFeatureDef( aicallback, features[0] );
     //sprintf( buffer, "First feature: %s", FeatureDef_get_myName( featuredef ) );
     //IAICallback_SendTextMsg( aicallback, buffer, 0 );    
     
     IUnitDef unitdef = aicallback.GetUnitDefByTypeId( 34 );
     aicallback.SendTextMsg( "gotunitdef", 0 );
     aicallback.SendTextMsg( "type id 34 is " + unitdef.name, 0 );
     aicallback.SendTextMsg( "human name: " + unitdef.humanName, 0 );
     aicallback.SendTextMsg( "id: " + unitdef.id, 0 );
     
     IMoveData movedata = unitdef.movedata;
     //IAICallback_SendTextMsg( aicallback, "movedata is null? " + ( movedata == 0 );
     //IAICallback_SendTextMsg( aicallback, buffer, 0 );    
     
     //IAICallback_SendTextMsg( aicallback, "movetype: %i" + MoveData_get_movetype( movedata ) );        
     //IAICallback_SendTextMsg( aicallback, buffer, 0 );    
     
     aicallback.SendTextMsg( "maxslope: " + movedata.maxSlope, 0 );
 }
Exemplo n.º 10
0
        BuildTable() // protected constructor to force Singleton instantiation
        {
            CSAI       = CSAI.GetInstance();
            aicallback = CSAI.aicallback;
            logfile    = LogFile.GetInstance();

            modname = aicallback.GetModName();

            int numunitdefs = aicallback.GetNumUnitDefs();

            logfile.WriteLine("calling GetUnitDefList, for " + numunitdefs + " units ... ");
            //availableunittypes = aicallback.GetUnitDefList();
            availableunittypes = new IUnitDef[numunitdefs + 1];
            for (int i = 1; i <= numunitdefs; i++)
            {
                availableunittypes[i] = aicallback.GetUnitDefByTypeId(i);
                logfile.WriteLine(i + " " + availableunittypes[i].name + " " + availableunittypes[i].humanName);
            }
            logfile.WriteLine("... done");

            if (!LoadCache(modname))
            {
                aicallback.SendTextMsg("Creating new cachefile for mod " + modname, 0);
                GenerateBuildTable(modname);
                SaveCache(modname);
            }
        }
Exemplo n.º 11
0
        public TankController(Dictionary <int, IUnitDef> UnitDefsById, IUnitDef typicalunitdef)
        {
            csai       = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile    = LogFile.GetInstance();

            this.DefsById       = UnitDefsById;
            this.typicalunitdef = typicalunitdef;

            unitcontroller  = UnitController.GetInstance();
            enemycontroller = EnemyController.GetInstance();
            buildtable      = BuildTable.GetInstance();

            enemyselector = new EnemySelector2(typicalunitdef.speed * 2, typicalunitdef);
            // speed here is experimental

            attackpackcoordinator       = new AttackPackCoordinator(DefsById);
            spreadsearchpackcoordinator = new SpreadSearchPackCoordinator(DefsById);
            movetopackcoordinator       = new MoveToPackCoordinator(DefsById);
            guardpackcoordinator        = new GuardPackCoordinator(DefsById);

            packcoordinatorselector = new PackCoordinatorSelector();
            packcoordinatorselector.LoadCoordinator(attackpackcoordinator);
            packcoordinatorselector.LoadCoordinator(spreadsearchpackcoordinator);
            packcoordinatorselector.LoadCoordinator(movetopackcoordinator);
            packcoordinatorselector.LoadCoordinator(guardpackcoordinator);

            logfile.WriteLine("*TankController Initialized*");
        }
Exemplo n.º 12
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));
            }
        }
Exemplo n.º 13
0
        // returns figure group
        public static int DrawMap(bool[,] map)
        {
            int         thismapwidth  = map.GetUpperBound(0) + 1;
            int         thismapheight = map.GetUpperBound(1) + 1;
            IAICallback aicallback    = CSAI.GetInstance().aicallback;
            int         multiplier    = (aicallback.GetMapWidth() / thismapwidth) * 8;

            int figuregroup = 0;

            for (int y = 0; y < thismapheight; y++)
            {
                for (int x = 0; x < thismapwidth; x++)
                {
                    double elevation = aicallback.GetElevation(x * multiplier, y * multiplier) + 10;
                    if (x < (thismapwidth - 1) &&
                        map[x, y] != map[x + 1, y])
                    {
                        figuregroup = aicallback.CreateLineFigure(new Float3((x + 1) * multiplier, elevation, y * multiplier),
                                                                  new Float3((x + 1) * multiplier, elevation, (y + 1) * multiplier), 10, false, 200, figuregroup);
                    }
                    if (y < (thismapheight - 1) &&
                        map[x, y] != map[x, y + 1])
                    {
                        figuregroup = aicallback.CreateLineFigure(new Float3(x * multiplier, elevation, (y + 1) * multiplier),
                                                                  new Float3((x + 1) * multiplier, elevation, (y + 1) * multiplier), 10, false, 200, figuregroup);
                    }
                }
            }
            return(figuregroup);
        }
Exemplo n.º 14
0
        BuildTable() // protected constructor to force Singleton instantiation
        {
            CSAI       = CSAI.GetInstance();
            aicallback = CSAI.aicallback;
            logfile    = LogFile.GetInstance();

            modname = aicallback.GetModName();

            logfile.WriteLine("calling GetUnitDefList... ");
            List <IUnitDef> unittypeslist = new List <IUnitDef>();
            int             numunittypes  = aicallback.GetNumUnitDefs();

            for (int i = 1; i <= numunittypes; i++)
            {
                unittypeslist.Add(aicallback.GetUnitDefByTypeId(i));
            }
            availableunittypes = unittypeslist.ToArray();
            logfile.WriteLine("... done");

            if (!LoadCache(modname))
            {
                aicallback.SendTextMsg("Creating new cachefile for mod " + modname, 0);
                GenerateBuildTable(modname);
                SaveCache(modname);
            }
        }
Exemplo n.º 15
0
        public void InitAI(IAICallback aicallback, int team)
        {
            this.aicallback = aicallback;
            this.team       = team;
            aicallback.SendTextMsg("Hello from Mono AbicWrappers", 0);
            aicallback.SendTextMsg("The map name is: " + aicallback.GetMapName(), 0);
            aicallback.SendTextMsg("Our ally team is: " + aicallback.GetMyTeam(), 0);

            //int features[10000 + 1];
            //int numfeatures = IAICallback_GetFeatures( aicallback, features, 10000 );
            //sprintf( buffer, "Num features is: %i", numfeatures );
            //IAICallback_SendTextMsg( aicallback, buffer, 0 );

            //const FeatureDef *featuredef = IAICallback_GetFeatureDef( aicallback, features[0] );
            //sprintf( buffer, "First feature: %s", FeatureDef_get_myName( featuredef ) );
            //IAICallback_SendTextMsg( aicallback, buffer, 0 );

            IUnitDef unitdef = aicallback.GetUnitDefByTypeId(34);

            aicallback.SendTextMsg("gotunitdef", 0);
            aicallback.SendTextMsg("type id 34 is " + unitdef.name, 0);
            aicallback.SendTextMsg("human name: " + unitdef.humanName, 0);
            aicallback.SendTextMsg("id: " + unitdef.id, 0);

            IMoveData movedata = unitdef.movedata;

            //IAICallback_SendTextMsg( aicallback, "movedata is null? " + ( movedata == 0 );
            //IAICallback_SendTextMsg( aicallback, buffer, 0 );

            //IAICallback_SendTextMsg( aicallback, "movetype: %i" + MoveData_get_movetype( movedata ) );
            //IAICallback_SendTextMsg( aicallback, buffer, 0 );

            aicallback.SendTextMsg("maxslope: " + movedata.maxSlope, 0);
        }
Exemplo n.º 16
0
        public MovementMaps()
        {
            csai = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile = LogFile.GetInstance();

            GenerateMaps();
        }
Exemplo n.º 17
0
        Ownership()
        {
            csai = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile = logfile.GetInstance();

            csai.UnitCreatedEvent += new CSAI.UnitCreatedHandler(csai_UnitCreatedEvent);
        }
Exemplo n.º 18
0
 public static string GetGameTimeString()
 {
     IAICallback aicallback = CSAI.GetInstance().aicallback;
     int frames = aicallback.GetCurrentFrame();
     TimeSpan gametime = TimeSpan.FromSeconds((double)frames / 30);
     string secondfractionstring = ( gametime.Milliseconds / 10 ).ToString().PadLeft( 2, '0' );
     return gametime.Hours + ":" + gametime.Minutes + ":" + gametime.Seconds + "." + secondfractionstring;
 }
Exemplo n.º 19
0
        public PlayStyle()
        {
            csai       = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile    = LogFile.GetInstance();

            PlayStyleManager.GetInstance().RegisterPlayStyle(this);
        }
Exemplo n.º 20
0
        Ownership()
        {
            csai       = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile    = logfile.GetInstance();

            csai.UnitCreatedEvent += new CSAI.UnitCreatedHandler(csai_UnitCreatedEvent);
        }
Exemplo n.º 21
0
        public MovementMaps()
        {
            csai       = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile    = LogFile.GetInstance();

            GenerateMaps();
        }
Exemplo n.º 22
0
        public PlayStyle()
        {
            csai = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile = LogFile.GetInstance();

            PlayStyleManager.GetInstance().RegisterPlayStyle( this );
        }
Exemplo n.º 23
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 ) );
        }
        // 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));
        }
        public MobileFusionController()
        {
            csai = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile = LogFile.GetInstance();

            UnitController.GetInstance().UnitAddedEvent += new UnitController.UnitAddedHandler(MobileFusionController_UnitAddedEvent);
            UnitController.GetInstance().AllUnitsLoaded += new UnitController.AllUnitsLoadedHandler(MobileFusionController_AllUnitsLoaded);
        }
Exemplo n.º 26
0
        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 ) );
        }
Exemplo n.º 27
0
        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));
        }
        public MobileFusionController()
        {
            csai       = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile    = LogFile.GetInstance();

            UnitController.GetInstance().UnitAddedEvent += new UnitController.UnitAddedHandler(MobileFusionController_UnitAddedEvent);
            UnitController.GetInstance().AllUnitsLoaded += new UnitController.AllUnitsLoadedHandler(MobileFusionController_AllUnitsLoaded);
        }
Exemplo n.º 29
0
        public Workflow()
        {
            csai = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile = LogFile.GetInstance();

            if (csai.DebugOn)
            {
                csai.RegisterVoiceCommand("dumpworkflow", new CSAI.VoiceCommandHandler(DumpWorkFlow));
            }
        }
Exemplo n.º 30
0
        public RadarController(IPlayStyle playstyle)
        {
            this.playstyle = playstyle;

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

            unitcontroller = UnitController.GetInstance();
            buildtable     = BuildTable.GetInstance();
        }
Exemplo n.º 31
0
        BuildPlanner()
        {
            csai = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile = LogFile.GetInstance();

            unitdefhelp = new UnitDefHelp( aicallback );

            mapwidth = aicallback.GetMapWidth();
            mapheight = aicallback.GetMapHeight();
        }
Exemplo n.º 32
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));
            }
        }
Exemplo n.º 33
0
        public RadarController( IPlayStyle playstyle )
        {
            this.playstyle = playstyle;

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

            unitcontroller = UnitController.GetInstance();
            buildtable = BuildTable.GetInstance();
        }
Exemplo n.º 34
0
        BuildPlanner()
        {
            csai       = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile    = LogFile.GetInstance();

            unitdefhelp = new UnitDefHelp(aicallback);

            mapwidth  = aicallback.GetMapWidth();
            mapheight = aicallback.GetMapHeight();
        }
Exemplo n.º 35
0
        //public delegate void AttackPackDeadHandler();
        //public event AttackPackDeadHandler AttackPackDeadEvent;
        // can pass in pointer to a hashtable in another class if we want
        // ie other class can directly modify our hashtable
        public AttackPackCoordinatorUseGroup( Hashtable UnitDefListByDeployedId )
        {
            this.UnitDefListByDeployedId = UnitDefListByDeployedId;

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

            debugon = csai.DebugOn;

            csai.TickEvent += new CSAI.TickHandler( this.Tick );
        }
Exemplo n.º 36
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));
            }
        }
        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));
            }
        }
        //public delegate void AttackPackDeadHandler();
        //public event AttackPackDeadHandler AttackPackDeadEvent;
        // can pass in pointer to a hashtable in another class if we want
        // ie other class can directly modify our hashtable
        public AttackPackCoordinator(Dictionary<int, IUnitDef> UnitDefListByDeployedId)
        {
            this.UnitDefListByDeployedId = UnitDefListByDeployedId;

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

            debugon = csai.DebugOn;

            csai.TickEvent += new CSAI.TickHandler( this.Tick );
        }
        //public delegate void AttackPackDeadHandler();

        //public event AttackPackDeadHandler AttackPackDeadEvent;

        // can pass in pointer to a hashtable in another class if we want
        // ie other class can directly modify our hashtable
        public AttackPackCoordinator(Hashtable UnitDefListByDeployedId)
        {
            this.UnitDefListByDeployedId = UnitDefListByDeployedId;

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

            debugon = csai.DebugOn;

            csai.TickEvent += new CSAI.TickHandler(this.Tick);
        }
        // can pass in pointer to a hashtable in another class if we want
        // ie other class can directly modify our hashtable
        public MoveToPackCoordinator(Dictionary <int, IUnitDef> UnitDefListByDeployedId)
        {
            this.UnitDefListByDeployedId = UnitDefListByDeployedId;

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

            debugon = csai.DebugOn;

            csai.TickEvent     += new CSAI.TickHandler(this.Tick);
            csai.UnitIdleEvent += new CSAI.UnitIdleHandler(UnitIdle);
        }
        // can pass in pointer to a hashtable in another class if we want
        // ie other class can directly modify our hashtable
        public SpreadSearchPackCoordinator( Hashtable UnitDefListByDeployedId )
        {
            this.UnitDefListByDeployedId = UnitDefListByDeployedId;

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

            debugon = csai.DebugOn;

            csai.TickEvent += new CSAI.TickHandler( this.Tick );
            csai.UnitIdleEvent += new CSAI.UnitIdleHandler( UnitIdle );
        }
Exemplo n.º 42
0
        void UnitCreatedEvent(int deployedunitid, IUnitDef unitdef)
        {
            IAICallback aicallback = CSAI.GetInstance().aicallback;

            if (aicallback.GetCurrentFrame() <= 1)
            {
                if (unitdef.isCommander)
                {
                    startposition = aicallback.GetUnitPos(deployedunitid);
                    //aicallback.get
                }
            }
        }
Exemplo n.º 43
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 ) );
        }
Exemplo n.º 44
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));
        }
Exemplo n.º 45
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*");
        }
Exemplo n.º 46
0
        public EnemySelector(double maxenemyspeed, bool WaterOk, bool BadTerrainOk)
        {
            csai       = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile    = LogFile.GetInstance();

            // csai.EnemyEntersLOSEvent += new CSAI.EnemyEntersLOSHandler( EnemyEntersLOS );

            enemycontroller = EnemyController.GetInstance();
            unitdefhelp     = new UnitDefHelp(aicallback);

            this.maxenemyspeed = maxenemyspeed;
            this.WaterOk       = WaterOk;
            this.BadTerrainOk  = BadTerrainOk;
        }
Exemplo n.º 47
0
        public EnemySelector( double maxenemyspeed, bool WaterOk, bool BadTerrainOk )
        {
            csai = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile = LogFile.GetInstance();

               // csai.EnemyEntersLOSEvent += new CSAI.EnemyEntersLOSHandler( EnemyEntersLOS );

            enemycontroller = EnemyController.GetInstance();
            unitdefhelp = new UnitDefHelp( aicallback );

            this.maxenemyspeed = maxenemyspeed;
            this.WaterOk = WaterOk;
            this.BadTerrainOk = BadTerrainOk;
        }
Exemplo n.º 48
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*");
        }
Exemplo n.º 49
0
        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));
            }
        }
Exemplo n.º 50
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));
            }
        }
Exemplo n.º 51
0
        public static int DrawRectangle(Float3 pos, int width, int height, int groupnumber)
        {
            IAICallback aicallback = CSAI.GetInstance().aicallback;
            double      elevation  = aicallback.GetElevation(pos.x, pos.z) + 10;

            groupnumber = aicallback.CreateLineFigure(pos + new Float3(0, elevation, 0),
                                                      pos + new Float3(width, elevation, 0), 10, false, 200, groupnumber);
            groupnumber = aicallback.CreateLineFigure(pos + new Float3(width, elevation, 0),
                                                      pos + new Float3(width, elevation, height), 10, false, 200, groupnumber);
            groupnumber = aicallback.CreateLineFigure(pos + new Float3(width, elevation, height),
                                                      pos + new Float3(0, elevation, height), 10, false, 200, groupnumber);
            groupnumber = aicallback.CreateLineFigure(pos + new Float3(0, elevation, height),
                                                      pos + new Float3(0, elevation, 0), 10, false, 200, groupnumber);

            return(groupnumber);
        }
Exemplo n.º 52
0
        // can pass in pointer to a hashtable in another class if we want
        // ie other class can directly modify our hashtable
        public SpreadSearchPackCoordinatorWithSearchGrid(Hashtable UnitDefListByDeployedId)
        {
            this.UnitDefListByDeployedId = UnitDefListByDeployedId;

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

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

            debugon = csai.DebugOn;

            csai.TickEvent     += new CSAI.TickHandler(this.Tick);
            csai.UnitIdleEvent += new CSAI.UnitIdleHandler(UnitIdle);
        }
Exemplo n.º 53
0
        // int terrainwidth;
        // int terrainheight;

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

            random = new Random();

            unitcontroller = UnitController.GetInstance();
            // buildtable = BuildTable.GetInstance();
            enemycontroller = EnemyController.GetInstance();

            searchcoordinator = new SpreadSearchPackCoordinatorWithSearchGrid(ScoutUnitDefsById);

            logfile.WriteLine("*ScoutControllerRaider initialized*");
        }
       // int terrainwidth;
       // int terrainheight;
        
        public ScoutControllerRaider()
        {
            csai = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile = LogFile.GetInstance();
            
            random = new Random();

            unitcontroller = UnitController.GetInstance();
           // buildtable = BuildTable.GetInstance();
            enemycontroller = EnemyController.GetInstance();
            
            searchcoordinator = new SpreadSearchPackCoordinatorWithSearchGrid( ScoutUnitDefsById );
            
            logfile.WriteLine( "*ScoutControllerRaider initialized*" );
        }
Exemplo n.º 55
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 );

            Init();
        }
Exemplo n.º 56
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);

            Init();
        }
        // can pass in pointer to a hashtable in another class if we want
        // ie other class can directly modify our hashtable
        public SpreadSearchPackCoordinatorWithSearchGrid(Dictionary<int, IUnitDef> UnitDefListByDeployedId)
        {
            this.UnitDefListByDeployedId = UnitDefListByDeployedId;

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

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

            debugon = csai.DebugOn;

            csai.TickEvent += new CSAI.TickHandler( this.Tick );
            csai.UnitIdleEvent += new CSAI.UnitIdleHandler( UnitIdle );
        }
Exemplo n.º 58
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 ) );
        }
        FriendlyUnitPositionObserver()
        {
            csai = CSAI.GetInstance();
            aicallback = csai.aicallback;
            logfile = LogFile.GetInstance();

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

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

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

            unitdefhelp = new UnitDefHelp( aicallback );
        }
Exemplo n.º 60
0
        public ScoutControllerRandomSearch( IPlayStyle playstyle )
        {
            random = new Random();

            this.playstyle = playstyle;

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

            unitcontroller = UnitController.GetInstance();
            buildtable = BuildTable.GetInstance();

            searchcoordinator = new SpreadSearchPackCoordinatorWithSearchGrid( ScoutUnitDefsById );

            logfile.WriteLine( "*ScoutController initialized*" );
        }