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*"); }
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)); } }
TankList() { LogFile.GetInstance().WriteLine("TankList() >>>"); UnitController.GetInstance().UnitAddedEvent += new UnitController.UnitAddedHandler(UnitAddedEvent); UnitController.GetInstance().UnitRemovedEvent += new UnitController.UnitRemovedHandler(UnitRemovedEvent); LogFile.GetInstance().WriteLine("TankList() <<<"); }
// 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 void Activate() { UnitController.GetInstance(); EnemyController.GetInstance(); FriendlyUnitPositionObserver.GetInstance(); MovementMaps.GetInstance(); BuildMap.GetInstance(); Metal.GetInstance().Init(); LosMap.GetInstance(); BuildPlanner.GetInstance(); BuildTable.GetInstance(); CommanderList.GetInstance(); Level1ConstructorList.GetInstance(); Level1FactoryList.GetInstance(); tankcontroller = new TankController(TankList.GetInstance().defbyid, BuildTable.GetInstance().UnitDefByName["armstump"]); tankcontroller.Activate(); helicoptercontroller = new TankController(HelicopterList.GetInstance().defbyid, BuildTable.GetInstance().UnitDefByName["armbrawl"]); helicoptercontroller.Activate(); new ScoutControllerRaider().Activate(); UnitController.GetInstance().LoadExistingUnits(); EnemyController.GetInstance().LoadExistingUnits(); CheckIdleUnits(); //BuildSolarCell(CommanderList.GetInstance().defbyid.Keys.GetEnumerator().Current); csai.UnitIdleEvent += new CSAI.UnitIdleHandler(csai_UnitIdleEvent); csai.TickEvent += new CSAI.TickHandler(csai_TickEvent); }
void CheckIdleUnits() { logfile.WriteLine("CheckIdleUnits()"); foreach (KeyValuePair <int, IUnitDef> kvp in UnitController.GetInstance().UnitDefByDeployedId) { // logfile.WriteLine("Checking " + kvp.Key); if (kvp.Value.canBuild) { if (!aicallback.UnitIsBusy(kvp.Key)) { logfile.WriteLine("Unit " + kvp.Value.humanName + " not busy, calling idle"); if (AssistingConstructors.ContainsKey(kvp.Key)) { logfile.WriteLine("removing from assistingconstructors"); AssistingConstructors.Remove(kvp.Key); } csai_UnitIdleEvent(kvp.Key); } if (!ActiveConstructors.Contains(kvp.Key)) { logfile.WriteLine("Unit " + kvp.Value.humanName + " not in active commanders, calling idle"); csai_UnitIdleEvent(kvp.Key); } } } }
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*"); }
TankRush() { strategycontroller = StrategyController.GetInstance(); strategycontroller.RegisterStrategy( this.GetType().ToString(), this ); unitcontroller = UnitController.GetInstance(); unitcontroller.ExistingUnitEvent += new UnitController.ExistingUnitHandler(unitcontroller_ExistingUnitEvent); }
public void Init() { //IntPtr springwindowhandle = GetSpringWindowHandle(); controlpanel = new ControlPanel(); controlpanel.Show(); UnitController.GetInstance().UnitAddedEvent += new UnitController.UnitAddedHandler(CSAIUserInteraction_UnitAddedEvent); UnitController.GetInstance().UnitRemovedEvent += new UnitController.UnitRemovedHandler(CSAIUserInteraction_UnitRemovedEvent); //if( ControlPanel. }
void MobileFusionController_AllUnitsLoaded() { foreach (int mob in mobileunits) { Float3 targetpos = aicallback.GetUnitPos(UnitController.GetInstance().UnitDefsByName["armmex"][0].id); //aicallback.GiveOrder(mob, new Command(Command.CMD_PATROL, targetpos.ToDoubleArray())); GiveOrderWrapper.GetInstance().MoveTo(mob, targetpos); } }
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); }
public RadarController(IPlayStyle playstyle) { this.playstyle = playstyle; csai = CSAI.GetInstance(); aicallback = csai.aicallback; logfile = LogFile.GetInstance(); unitcontroller = UnitController.GetInstance(); buildtable = BuildTable.GetInstance(); }
public override string ToString() { int underconstruction = unitsunderconstruction.Count; int currentunits = 0; if (UnitController.GetInstance().UnitDefsByName.ContainsKey(unitname)) { currentunits += UnitController.GetInstance().UnitDefsByName[unitname].Count; } return("Order priority: " + priority + " unitname: " + unitname + " quantity: " + currentunits + "(" + underconstruction + ") / " + quantity); }
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)); }
} // 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)); }
// 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*"); }
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(); }
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*"); }
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); }
public ConstructorController(IPlayStyle playstyle) { this.playstyle = playstyle; csai = CSAI.GetInstance(); aicallback = csai.aicallback; logfile = LogFile.GetInstance(); ShowNextBuildSite = csai.DebugOn; unitcontroller = UnitController.GetInstance(); // factorycontroller = FactoryController.GetInstance(); buildtable = BuildTable.GetInstance(); metal = Metal.GetInstance(); ShowNextBuildSite = csai.DebugOn; logfile.WriteLine("ConstructorController::ConstructorController() finished"); }
bool BuildMex(int constructorid) { if (!BuildTree.GetInstance().CanBuild(UnitController.GetInstance().UnitDefByDeployedId[constructorid].name.ToLower(), "armmex")) { return(false); } IUnitDef unitdef = BuildTable.GetInstance().UnitDefByName["armmex"]; Float3 buildsite = Metal.GetInstance().GetNearestMetalSpot(aicallback.GetUnitPos(constructorid)); buildsite = aicallback.ClosestBuildSite(unitdef, buildsite, 100, 0); if (!ActiveConstructors.Contains(constructorid)) { ActiveConstructors.Add(constructorid); } //aicallback.GiveOrder(constructorid, new Command(-unitdef.id, buildsite.ToDoubleArray())); GiveOrderWrapper.GetInstance().BuildUnit(constructorid, unitdef.name, buildsite); return(true); }
public void Activate() { if (!started) { started = true; restartedfrompause = true; groupid = aicallback.CreateGroup("", 0); logfile.WriteLine("ATCUG created group id " + groupid); unitcontroller = UnitController.GetInstance(); 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)); Recoordinate(); } }
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(); }
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); }
Float3 BuildUnit(int constructorid, string targetunitname) { csai.DebugSay("workflow, building " + targetunitname); IUnitDef targetunitdef = BuildTable.GetInstance().UnitDefByName[targetunitname]; IUnitDef constructordef = UnitController.GetInstance().UnitDefByDeployedId[constructorid]; if (new UnitDefHelp(aicallback).IsMobile(constructordef)) { logfile.WriteLine("constructor is mobile"); Float3 constructorpos = aicallback.GetUnitPos(constructorid); Float3 buildsite = BuildPlanner.GetInstance().ClosestBuildSite(targetunitdef, constructorpos, 3000, 2); buildsite = aicallback.ClosestBuildSite(targetunitdef, buildsite, 1400, 0); logfile.WriteLine("constructor location: " + constructorpos.ToString() + " Buildsite: " + buildsite.ToString() + " target item: " + targetunitdef.humanName); if (!ActiveConstructors.Contains(constructorid)) { ActiveConstructors.Add(constructorid); } aicallback.DrawUnit(targetunitname.ToUpper(), buildsite, 0.0, 200, aicallback.GetMyAllyTeam(), true, true); GiveOrderWrapper.GetInstance().BuildUnit(constructorid, targetunitname, buildsite); return(buildsite); } else { Float3 factorypos = aicallback.GetUnitPos(constructorid); logfile.WriteLine("factory location: " + factorypos.ToString() + " target item: " + targetunitdef.humanName); if (!ActiveConstructors.Contains(constructorid)) { ActiveConstructors.Add(constructorid); } aicallback.DrawUnit(targetunitdef.name.ToUpper(), factorypos, 0.0, 200, aicallback.GetMyAllyTeam(), true, true); GiveOrderWrapper.GetInstance().BuildUnit(constructorid, targetunitname); return(factorypos); } }
// int terrainwidth; // int terrainheight; public ScoutControllerRaider(IPlayStyle playstyle) { this.playstyle = playstyle; csai = CSAI.GetInstance(); aicallback = csai.aicallback; logfile = LogFile.GetInstance(); random = new Random(); //terrainwidth = aicallback.GetMapWidth() * MovementMaps.SQUARE_SIZE; // terrainheight = aicallback.GetMapHeight() * MovementMaps.SQUARE_SIZE; //int[,] sectorlastcheckedtickcount = new int[ terrainwidth, terrainheight ]; // bool[,] sectorispriority = new bool[ terrainwidth, terrainheight ];; unitcontroller = UnitController.GetInstance(); buildtable = BuildTable.GetInstance(); enemycontroller = EnemyController.GetInstance(); searchcoordinator = new SpreadSearchPackCoordinatorWithSearchGrid(ScoutUnitDefsById); logfile.WriteLine("*ScoutControllerRaider initialized*"); }
void csai_UnitIdleEvent(int deployedunitid) { IUnitDef unitdef = UnitController.GetInstance().UnitDefByDeployedId[deployedunitid]; if (!unitdef.canBuild) { //logfile.WriteLine("cantbuild"); return; } logfile.WriteLine("unitidleevent " + deployedunitid + " " + unitdef.name + " " + unitdef.humanName); if (ActiveConstructors.Contains(deployedunitid)) { ActiveConstructors.Remove(deployedunitid); } Ownership.GetInstance().SignalConstructorIsIdle(deployedunitid); double highestpriority = 0; List <Order> bestorders = new List <Order>(); foreach (Order order in orders) { double thispriority = order.priority; if (thispriority >= highestpriority) { int currentunits = order.unitsunderconstruction.Count; if (UnitController.GetInstance().UnitDefsByName.ContainsKey(order.unitname)) { currentunits += UnitController.GetInstance().UnitDefsByName[order.unitname].Count; } if (currentunits < order.quantity) { if (BuildTree.GetInstance().CanBuild(unitdef.name.ToLower(), order.unitname)) { //if( CanBuild(deployedunitid, if (thispriority > highestpriority) { highestpriority = thispriority; bestorders = new List <Order>(); bestorders.Add(order); csai.DebugSay("Possible order: " + order.ToString()); } else if (thispriority == highestpriority) { bestorders.Add(order); csai.DebugSay("Possible order: " + order.ToString()); } } } } } //if (bestorders.Count == 0) // { // csai.DebugSay("No orders found"); // return; // } List <Order> possibleorders = new List <Order>(); // get orders this unit can build bool metalneeded = false; bool energyneeded = false; IUnitDef deftobuild = null; foreach (Order order in bestorders) { csai.DebugSay("bestorder " + order.unitname); //if( BuildTree.GetInstance().CanBuild( unitdef.name.ToLower(), order.unitname ) ) //{ deftobuild = BuildTable.GetInstance().UnitDefByName[order.unitname]; if (MetalController.GetInstance().CanBuild(deftobuild)) { if (EnergyController.GetInstance().CanBuild(deftobuild)) { possibleorders.Add(order); csai.DebugSay("possible: " + order.unitname); } else { csai.DebugSay("needs energy"); energyneeded = true; } } else { csai.DebugSay("needs metal"); metalneeded = true; } //} } if (possibleorders.Count == 0) { if (Level1ConstructorList.GetInstance().defbyid.Count < 1 && !UnitController.GetInstance().UnitDefsByName.ContainsKey("armcom")) { if (BuildConstructionVehicle(deployedunitid, unitdef)) { return; } } if (energyneeded || aicallback.GetEnergy() < aicallback.GetEnergyStorage() / 5) { if (BuildSolarCell(deployedunitid)) { logfile.WriteLine("building solarcell"); if (AssistingConstructors.ContainsKey(deployedunitid)) { AssistingConstructors.Remove(deployedunitid); } return; } } if (metalneeded || aicallback.GetMetal() < aicallback.GetMetalStorage() / 5) { Float3 reclaimpos = ReclaimHelper.GetNearestReclaim(aicallback.GetUnitPos(deployedunitid), deployedunitid); if (reclaimpos != null) { GiveOrderWrapper.GetInstance().Reclaim(deployedunitid, reclaimpos, 100); return; } if (BuildMex(deployedunitid)) { logfile.WriteLine("building mex"); if (AssistingConstructors.ContainsKey(deployedunitid)) { AssistingConstructors.Remove(deployedunitid); } return; } } logfile.WriteLine("offering assistance"); OfferAssistance(deployedunitid); return; } Order ordertodo = possibleorders[random.Next(0, possibleorders.Count)]; if (ordertodo.unitname == "armmex") { BuildMex(deployedunitid); if (AssistingConstructors.ContainsKey(deployedunitid)) { AssistingConstructors.Remove(deployedunitid); } } else { //ordertodo.unitsunderconstruction += 1; deftobuild = BuildTable.GetInstance().UnitDefByName[ordertodo.unitname]; Float3 pos = BuildUnit(deployedunitid, ordertodo.unitname); Ownership.IOrder ownershiporder = Ownership.GetInstance().RegisterBuildingOrder(this, deployedunitid, deftobuild, pos); logfile.WriteLine("building: " + ordertodo.unitname); ordertodo.unitsunderconstruction.Add(ownershiporder); if (AssistingConstructors.ContainsKey(deployedunitid)) { AssistingConstructors.Remove(deployedunitid); } } }
Level1FactoryList() { UnitController.GetInstance().UnitAddedEvent += new UnitController.UnitAddedHandler(Level1FactoryList_UnitAddedEvent); UnitController.GetInstance().UnitRemovedEvent += new UnitController.UnitRemovedHandler(Level1FactoryList_UnitRemovedEvent); }
//int numOfUnits = 0; //IUnitDef[] unitList; //IUnitDef solarcollectordef; public void InitAI(IAICallback aicallback, int team) { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB"); this.aicallback = aicallback; try{ this.Team = team; logfile = LogFile.GetInstance().Init(team); logfile.WriteLine("C# AI started v" + AIVersion + ", team " + team + " ref " + reference + " map " + aicallback.GetMapName() + " mod " + aicallback.GetModName()); if (File.Exists("AI/CSAI/debug.flg")) // if this file exists, activate debug mode; saves manually changing this for releases { logfile.WriteLine("Toggling debug on"); DebugOn = true; } if (DebugOn) { new Testing.RunTests().Go(); } InitCache(); PlayStyleManager.GetInstance(); LoadPlayStyles.Go(); metal = Metal.GetInstance(); CommanderController.GetInstance(); BuildTable.GetInstance(); UnitController.GetInstance(); EnemyController.GetInstance(); EnergyController.GetInstance(); MovementMaps.GetInstance(); BuildMap.GetInstance(); //FactoryController.GetInstance(); //RadarController.GetInstance(); //TankController.GetInstance(); //ScoutController.GetInstance(); //ConstructorController.GetInstance(); metal.Init(); BuildPlanner.GetInstance(); UnitController.GetInstance().LoadExistingUnits(); // need this if we're being reloaded in middle of a game, to get already existing units EnemyController.GetInstance().LoadExistingUnits(); StrategyController.GetInstance(); LoadStrategies.Go(); PlayStyleManager.GetInstance().ChoosePlayStyle("tankrush"); if (aicallback.GetModName().ToLower().IndexOf("aass") == 0 || aicallback.GetModName().ToLower().IndexOf("xtape") == 0) { aicallback.SendTextMsg("C# AI initialized v" + AIVersion + ", team " + team, 0); aicallback.SendTextMsg("Please say '.csai help' for available commands", 0); PlayStyleManager.GetInstance().ListPlayStyles(); //CommanderController.GetInstance().CommanderBuildPower(); } else { aicallback.SendTextMsg("Warning: CSAI needs AA2.23 or XTA7 to run correctly at this time", 0); logfile.WriteLine("*********************************************************"); logfile.WriteLine("*********************************************************"); logfile.WriteLine("**** ****"); logfile.WriteLine("**** Warning: CSAI needs AA2.23 or XTA7 to run correctly at this time ****"); logfile.WriteLine("**** ****"); logfile.WriteLine("*********************************************************"); logfile.WriteLine("*********************************************************"); } } catch (Exception e) { logfile.WriteLine("Exception: " + e.ToString()); aicallback.SendTextMsg("Exception: " + e.ToString(), 0); } }
CommanderList() { UnitController.GetInstance().UnitAddedEvent += new UnitController.UnitAddedHandler(UnitAddedEvent); UnitController.GetInstance().UnitRemovedEvent += new UnitController.UnitRemovedHandler(UnitRemovedEvent); }