Пример #1
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);
            }
        }
Пример #2
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);
            }
        }
Пример #3
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 );
            }
        }
Пример #4
0
        public void UnitCreated(int unit)
        {
            aicallback.SendTextMsg("Unit created: " + unit, 0);

            IUnitDef unitdef = aicallback.GetUnitDef(unit);

            aicallback.SendTextMsg("Unit created: " + unitdef.name, 0);

            IMoveData movedata = unitdef.movedata;

            if (movedata != null)
            {
                aicallback.SendTextMsg("Max Slope: " + movedata.maxSlope, 0);
            }

            if (unitdef.isCommander)
            {
                int    numbuildoptions    = unitdef.GetNumBuildOptions();
                string buildoptionsstring = "Build options: ";
                for (int i = 0; i < numbuildoptions; i++)
                {
                    buildoptionsstring += unitdef.GetBuildOption(i);
                }
                aicallback.SendTextMsg(buildoptionsstring, 0);

                Float3 commanderpos = aicallback.GetUnitPos(unit);
                aicallback.SendTextMsg("Commanderpos: " + commanderpos.ToString(), 0);

                int numunitdefs = aicallback.GetNumUnitDefs();
                aicallback.SendTextMsg("Num unit defs: " + numunitdefs, 0);

                for (int i = 1; i <= numunitdefs; i++)
                {
                    IUnitDef thisunitdef = aicallback.GetUnitDefByTypeId(i);
                    if (thisunitdef.name == "ARMSOLAR")
                    {
                        aicallback.SendTextMsg("Found solar collector def: " + thisunitdef.id, 0);

                        Float3 nearestbuildpos = aicallback.ClosestBuildSite(thisunitdef, commanderpos, 1400, 2);
                        aicallback.SendTextMsg("Closest build site: " + nearestbuildpos.ToString(), 0);

                        aicallback.DrawUnit("ARMSOLAR", nearestbuildpos, 0,
                                            200, aicallback.GetMyAllyTeam(), true, true);

                        aicallback.GiveOrder(unit, new Command(-thisunitdef.id, nearestbuildpos.ToDoubleArray()));
                    }
                }
            }
        }
Пример #5
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 );
            }
        }