public BadFactionPlayer() { // Initialise the bad faction's characters foragerAI = null; forager = null; builderAI = null; builder = null; hiveAI = null; hive = null; barrackAI = null; barrack = null; depotAI = null; depot = null; // Set the computer's faction if (RTSFactionManager.Instance != null && RTSFactionManager.Instance.Factions.Count != 1) badFaction = RTSFactionManager.Instance.Factions[1].FactionType; // Initialise the opening strategy openingStrategy = OpeningStrategy().GetEnumerator(); strategyIterator = 0; foragerStrategy = ForagerStrategy().GetEnumerator(); foragerIterator = 0; // Initalise the first action currentAction = Action.Null; }
// Identify the bad faction's entities private void IdentifyCharacters(LinkedList<Entity> mapChildren) { builderAI = null; builder = null; hiveAI = null; hive = null; barrackAI = null; barrack = null; depotAI = null; depot = null; // For each map entity foreach (Entity entity in mapChildren) { // Is this a GenericAntCharacter entity //GenericAntCharacter unit = entity as GenericAntCharacter; //RTSUnit rtsunit = entity as RTSUnit; if (entity.Type.Name == "ForagerAnt") { ForagerAnt unit = entity as ForagerAnt; if (unit != null) { if (unit.Intellect != null) { if (unit.Intellect.Faction == badFaction) { if (foragerAI == null) { AntUnitAI intellect = unit.Intellect as AntUnitAI; if (intellect != null) { foragerAI = intellect; forager = unit; } } } } } } else if (entity.Type.Name == "BuilderAnt") { GenericAntCharacter unit = entity as GenericAntCharacter; if (unit != null) { if (unit.Intellect != null) { if (unit.Intellect.Faction == badFaction) { // Identify the builder ant if it has not already been found if (builderAI == null) { AntUnitAI intellect = unit.Intellect as AntUnitAI; if (intellect != null) { // Builder ant found builderAI = intellect; builder = unit; } } } } } } /*else if (entity.Type.Name == "RTSDepot") { RTSMine mine = entity as RTSMine; if (mine != null) { if (mine.Intellect != null) { if (mine.Intellect.Faction == badFaction) { if (depotAI == null) { RTSBuildingAI intellect = mine.Intellect as RTSBuildingAI; if (intellect != null) { // barrack found depotAI = intellect; depot = mine; Log.Warning("depot = (RTSMine)building"); } } } } } }*/ else { // Is this a RTSBuilding entity RTSBuilding building = entity as RTSBuilding; if (building != null) { if (building.Intellect != null) { if (building.Intellect.Faction == badFaction) { // Identify the hive if it has not already been found if (hiveAI == null && building.Type.Name == "AntColmena") { RTSBuildingAI intellect = building.Intellect as RTSBuildingAI; if (intellect != null) { // Hive found hiveAI = intellect; hive = building; } } // Identify the barracks if it has not already been found else if (barrackAI == null && building.Type.Name == "AntBarrack") { RTSBuildingAI intellect = building.Intellect as RTSBuildingAI; if (intellect != null) { // barrack found barrackAI = intellect; barrack = building; } } } } } } } }