public override void Initialize(AICommander commander) { base.Initialize(commander); IGameService service = Services.GetService <IGameService>(); this.gameEntityRepositoryService = service.Game.Services.GetService <IGameEntityRepositoryService>(); }
protected override void RefreshObjectives(StaticString context, StaticString pass) { base.RefreshObjectives(context, pass); for (int i = 0; i < this.MajorEmpire.TamedKaijus.Count; i++) { Kaiju kaiju = this.MajorEmpire.TamedKaijus[i]; if (kaiju.OnArmyMode()) { AICommander aicommander = this.aiCommanders.Find((AICommander match) => match.ForceArmyGUID == kaiju.KaijuArmy.GUID); if (aicommander == null) { this.AddCommander(new AICommander_KaijuSupport { ForceArmyGUID = kaiju.KaijuArmy.GUID, Empire = base.AIEntity.Empire, AIPlayer = base.AIEntity.AIPlayer }); } else { aicommander.Initialize(); aicommander.Load(); aicommander.CreateMission(); } } } }
private void Order_KaijuRisen(object sender, TicketRaisedEventArgs e) { if (e.Result == PostOrderResponse.Processed) { OrderKaijuChangeMode orderKaijuChangeMode = e.Order as OrderKaijuChangeMode; Kaiju kaiju = null; if (!this.gameEntityRepositoryService.TryGetValue <Kaiju>(orderKaijuChangeMode.KaijuGUID, out kaiju) || !this.MajorEmpire.TamedKaijus.Contains(kaiju)) { return; } AICommander aicommander = this.aiCommanders.Find((AICommander match) => match.ForceArmyGUID == kaiju.KaijuArmy.GUID); if (aicommander == null) { this.AddCommander(new AICommander_KaijuSupport { ForceArmyGUID = kaiju.KaijuArmy.GUID, Empire = base.AIEntity.Empire, AIPlayer = base.AIEntity.AIPlayer }); return; } aicommander.Initialize(); aicommander.Load(); aicommander.CreateMission(); } }
public override void Initialize(AICommander aiCommander) { base.Initialize(aiCommander); IGameService service = Services.GetService <IGameService>(); this.game = (service.Game as global::Game); }
public override void Initialize(AICommander commander) { base.Initialize(commander); if (commander.Empire is MajorEmpire) { this.departmentOfForeignAffairs = commander.Empire.GetAgency <DepartmentOfForeignAffairs>(); } }
public override void Initialize(AICommander commander) { base.Initialize(commander); IGameService service = Services.GetService <IGameService>(); this.gameEntityRepositoryService = service.Game.Services.GetService <IGameEntityRepositoryService>(); base.AIDataArmyGUID = commander.ForceArmyGUID; }
public override void Initialize(AICommander commander) { base.Initialize(commander); IGameService service = Services.GetService <IGameService>(); this.pathfindingService = service.Game.Services.GetService <IPathfindingService>(); this.gameEntityRepositoryService = service.Game.Services.GetService <IGameEntityRepositoryService>(); this.worldPositionningService = service.Game.Services.GetService <IWorldPositionningService>(); }
public override void Initialize(AICommander commander) { base.Initialize(commander); IGameService service = Services.GetService <IGameService>(); Diagnostics.Assert(service != null); this.worldPositionningService = service.Game.Services.GetService <IWorldPositionningService>(); Diagnostics.Assert(this.worldPositionningService != null); }
protected virtual void AddCommander(AICommander commander) { if (this.IsActive()) { commander.Initialize(); commander.Load(); commander.CreateMission(); this.aiCommanders.Add(commander); } }
public BattleAISystem(IBattleManager mgr) : base(mgr) { _AICommander = new AICommander(); _AIBuilder = new AIBuilder(); _AICommander.sender = facade.SendNotification; _AIBuilder.sender = facade.SendNotification; _AIBuilder.mapProxy = facade.RetrieveProxy(MapVOProxy.NAME) as MapVOProxy; _AIBuilder.buildingProxy = facade.RetrieveProxy(BuildingVOProxy.NAME) as BuildingVOProxy; }
void Awake() { units = 0; turn = true; if (ai) { aiComponent = gameObject.GetComponent(typeof(AICommander)) as AICommander; } }
public override void Initialize(AICommander commander) { base.Initialize(commander); this.departmentOfTheInterior = commander.Empire.GetAgency <DepartmentOfTheInterior>(); this.intelligenceAIHelper = AIScheduler.Services.GetService <IIntelligenceAIHelper>(); this.personalityMPTenacity = 0.8f; IGameService service = Services.GetService <IGameService>(); this.gameEntityRepositoryService = service.Game.Services.GetService <IGameEntityRepositoryService>(); }
public override void Initialize(AICommander commander) { base.Initialize(commander); IGameService service = Services.GetService <IGameService>(); this.worldPositionningService = service.Game.Services.GetService <IWorldPositionningService>(); this.pathfindingService = service.Game.Services.GetService <IPathfindingService>(); this.departmentOfScience = base.Commander.Empire.GetAgency <DepartmentOfScience>(); this.departmentOfForeignAffairs = base.Commander.Empire.GetAgency <DepartmentOfForeignAffairs>(); }
protected virtual void RefreshCommanders(StaticString context, StaticString pass) { for (int i = 0; i < this.aiCommanders.Count; i++) { AICommander aicommander = this.aiCommanders[i]; aicommander.RefreshObjective(); aicommander.RefreshMission(); this.GenerateRetrofitUnitMessage(aicommander); } this.GenerateNewCommander(); }
public int ComputeCommanderMissionNumber(AICommanderMissionDefinition.AICommanderCategory category) { int num = 0; for (int i = 0; i < this.aiCommanders.Count; i++) { AICommander aicommander = this.aiCommanders[i]; num += aicommander.ComputeCommanderMissionNumber(category); } return(num); }
public void Initialize(World w) { instance = this; activeWorld = w; playerStatus = new PlayerStatus[2]; playerStatus[0] = new PlayerStatus(0); playerStatus[1] = new PlayerStatus(1); player1 = new AICommander(playerStatus[0].id, lightArmy); player2 = new AICommander(playerStatus[1].id, darkArmy); }
void Start () { if (whichSide == WhichSide.Ally) { myCommander = GameObject.FindGameObjectWithTag("AIManager").transform.FindChild("PMC Commander").GetComponent<AICommander> (); enemyCommander = GameObject.FindGameObjectWithTag("AIManager").transform.FindChild("Enemy Commander").GetComponent<AICommander> (); } else if (whichSide == WhichSide.Enemy) { myCommander = GameObject.FindGameObjectWithTag("AIManager").transform.FindChild("Enemy Commander").GetComponent<AICommander> (); enemyCommander = GameObject.FindGameObjectWithTag("AIManager").transform.FindChild("PMC Commander").GetComponent<AICommander> (); } }
public void Initialize(World w) { instance = this; activeWorld = w; playerStatus = new PlayerStatus[2]; playerStatus[0] = new PlayerStatus(0); playerStatus[1] = new PlayerStatus(1); player1 = new AICommander(playerStatus[0].id, lightArmy); player2 = new AICommander(playerStatus[1].id, darkArmy); }
void Awake () { if(instance == null) { instance = this; } else { Destroy(gameObject); } pmcCommander = GameObject.FindGameObjectWithTag("AIManager").transform.FindChild("PMC Commander").GetComponent<AICommander> (); }
protected virtual void CheckCommanders(StaticString context, StaticString pass) { for (int i = this.aiCommanders.Count - 1; i >= 0; i--) { AICommander aicommander = this.aiCommanders[i]; bool forceStop = false; aicommander.CheckObjectiveInProgress(forceStop); if (aicommander.IsMissionFinished(forceStop)) { this.RemoveCommander(aicommander); } } }
public void AssignArmyMission(AICommander aiCommander, AIArmyMissionDefinition armyMissionDefinition, params object[] parameters) { if (this.ArmyMission != null) { this.UnassignArmyMission(); } this.ArmyMission = new AIArmyMission { AIArmyMissionDefinition = armyMissionDefinition, Army = this.Army, AICommander = aiCommander }; this.ArmyMission.Initialize(parameters); }
public override void Initialize(AICommander commander) { base.Initialize(commander); Services.GetService <IGameService>(); base.AIDataArmyGUID = commander.ForceArmyGUID; this.ruinCommander = (base.Commander as AICommander_RuinHunter); IGameService service = Services.GetService <IGameService>(); this.game = (service.Game as global::Game); if (this.ruinCommander == null) { base.Completion = AICommanderMission.AICommanderMissionCompletion.Fail; } }
public override void Initialize(AICommander commander) { base.Initialize(commander); Diagnostics.Assert(AIScheduler.Services != null); this.intelligenceAiHelper = AIScheduler.Services.GetService <IIntelligenceAIHelper>(); IGameService service = Services.GetService <IGameService>(); Diagnostics.Assert(service != null); this.worldPositionningService = service.Game.Services.GetService <IWorldPositionningService>(); Diagnostics.Assert(this.worldPositionningService != null); this.pathfindingService = service.Game.Services.GetService <IPathfindingService>(); this.personalityAIHelper = AIScheduler.Services.GetService <IPersonalityAIHelper>(); this.unitInGarrisonPercent = this.personalityAIHelper.GetRegistryValue <float>(base.Commander.Empire, string.Format("{0}/{1}", AILayer_Military.RegistryPath, "UnitInGarrisonPercent"), this.unitInGarrisonPercent); this.unitInGarrisonPriorityMultiplierPerSlot = this.personalityAIHelper.GetRegistryValue <float>(base.Commander.Empire, string.Format("{0}/{1}", AILayer_Military.RegistryPath, "UnitInGarrisonPriorityMultiplierPerSlot"), this.unitInGarrisonPriorityMultiplierPerSlot); this.unitRatioBoost = this.personalityAIHelper.GetRegistryValue <float>(base.Commander.Empire, string.Format("{0}/{1}", AILayer_Military.RegistryPath, "UnitRatioBoost"), this.unitRatioBoost); }
public override void Initialize(AICommander commander) { base.Initialize(commander); IGameService service = Services.GetService <IGameService>(); Diagnostics.Assert(service != null); this.game = (service.Game as global::Game); this.worldPositioningService = service.Game.Services.GetService <IWorldPositionningService>(); this.pathfindingService = service.Game.Services.GetService <IPathfindingService>(); this.departmentOfDefense = base.Commander.Empire.GetAgency <DepartmentOfDefense>(); this.departmentOfTheInterior = base.Commander.Empire.GetAgency <DepartmentOfTheInterior>(); this.aiDataRepositoryHelper = AIScheduler.Services.GetService <IAIDataRepositoryAIHelper>(); base.AIDataArmyGUID = commander.ForceArmyGUID; AIData_Army aidata_Army; if (this.aiDataRepositoryHelper.TryGetAIData <AIData_Army>(base.AIDataArmyGUID, out aidata_Army) && aidata_Army.Army is KaijuArmy) { this.Kaiju = (aidata_Army.Army as KaijuArmy).Kaiju; } if (base.Commander.Empire != null && base.Commander.Empire is MajorEmpire) { GameServer gameServer = (Services.GetService <ISessionService>().Session as global::Session).GameServer as GameServer; AIPlayer_MajorEmpire aiplayer_MajorEmpire; if (gameServer.AIScheduler != null && gameServer.AIScheduler.TryGetMajorEmpireAIPlayer(base.Commander.Empire as MajorEmpire, out aiplayer_MajorEmpire)) { AIEntity entity = aiplayer_MajorEmpire.GetEntity <AIEntity_Empire>(); if (entity != null) { this.aILayer_KaijuManagement = entity.GetLayer <AILayer_KaijuManagement>(); this.aILayer_War = entity.GetLayer <AILayer_War>(); } } } IDatabase <GarrisonAction> database = Databases.GetDatabase <GarrisonAction>(false); GarrisonAction garrisonAction = null; if (database == null || !database.TryGetValue("GarrisonActionMigrateKaiju", out garrisonAction)) { Diagnostics.LogError("AICommanderMission_KaijuSupport didnt find GarrisonActionMigrateKaiju"); return; } this.garrisonAction_MigrateKaiju = (garrisonAction as GarrisonAction_MigrateKaiju); }
public virtual void Initialize(AICommander aiCommander) { this.Commander = aiCommander; IGameService service = Services.GetService <IGameService>(); Diagnostics.Assert(service != null); this.encounterRepositoryService = service.Game.Services.GetService <IEncounterRepositoryService>(); Diagnostics.Assert(this.encounterRepositoryService != null); this.encounterRepositoryService.OneEncounterStateChange += this.EncounterRepositoryService_OneEncounterStateChange; this.departmentOfDefense = this.Commander.Empire.GetAgency <DepartmentOfDefense>(); Diagnostics.Assert(this.departmentOfDefense != null); this.departmentOfDefense.ArmiesCollectionChange += this.AICommanderMission_ArmyCollectionChange; this.aiDataRepository = AIScheduler.Services.GetService <IAIDataRepositoryAIHelper>(); this.tickableRepository = AIScheduler.Services.GetService <ITickableRepositoryAIHelper>(); if (this.InternalGUID == GameEntityGUID.Zero) { this.InternalGUID = AIScheduler.Services.GetService <IAIEntityGUIDAIHelper>().GenerateAIEntityGUID(); } }
void Start() { //check which side we're on and get a squad name from it if (whichSide == WhichSide.Ally) { myCommander = GameObject.FindGameObjectWithTag("AIManager").transform.FindChild("PMC Commander").GetComponent<AICommander> (); } else if (whichSide == WhichSide.Enemy) { myCommander = GameObject.FindGameObjectWithTag("AIManager").transform.FindChild("Enemy Commander").GetComponent<AICommander> (); } squadName = myCommander.RequestSquadronName (); //spawn the required number of craft for(int i = 0; i < numberToSpawn; i++) { GameObject obj = Instantiate(objectPrefab, (Vector2)transform.position + Random.insideUnitCircle, Quaternion.identity) as GameObject; obj.name = squadName + " " + (i+1); craft.Add(obj); } //create SquadLeader object and put it on the leader squadLeaderPrefab = Instantiate (squadLeaderPrefab, transform.position, Quaternion.identity) as GameObject; squadLeaderPrefab.transform.SetParent (craft [0].transform.FindChild ("Abilities")); squadLeaderPrefab.transform.localPosition = Vector3.zero; squadLeaderPrefab.GetComponent<SquadronLeader> ().whichSide = (whichSide == WhichSide.Ally) ? SquadronLeader.WhichSide.Ally : SquadronLeader.WhichSide.Enemy; //set up the wingmen to know who their leader is and cover him for(int i = 1; i < craft.Count; i++) { squadLeaderPrefab.GetComponent<SquadronLeader>().activeWingmen.Add(craft[i]); craft[i].GetComponent<AIFighter>().flightLeader = craft[0]; craft[i].GetComponent<AIFighter>().flightLeadSquadronScript = craft[0].GetComponentInChildren<SquadronLeader>(); craft[i].GetComponent<AIFighter>().currentState = AIFighter.StateMachine.Covering; } Destroy (gameObject); }
public override void Initialize(AICommander commander) { base.Initialize(commander); this.departmentOfDefense = base.Commander.Empire.GetAgency <DepartmentOfDefense>(); this.aiDataRepositoryHelper = AIScheduler.Services.GetService <IAIDataRepositoryAIHelper>(); this.colossusCommander = (commander as AICommander_Colossus); base.AIDataArmyGUID = commander.ForceArmyGUID; if (base.Commander.Empire != null && base.Commander.Empire is MajorEmpire) { GameServer gameServer = (Services.GetService <ISessionService>().Session as global::Session).GameServer as GameServer; AIPlayer_MajorEmpire aiplayer_MajorEmpire; if (gameServer.AIScheduler != null && gameServer.AIScheduler.TryGetMajorEmpireAIPlayer(base.Commander.Empire as MajorEmpire, out aiplayer_MajorEmpire)) { AIEntity entity = aiplayer_MajorEmpire.GetEntity <AIEntity_Empire>(); if (entity != null) { this.ailayer_War = entity.GetLayer <AILayer_War>(); } } } }
public override void ReadXml(XmlReader reader) { base.ReadXml(reader); if (!reader.IsStartElement("Commanders")) { return; } if (reader.IsStartElement("Commanders") && reader.IsEmptyElement()) { reader.Skip(); return; } reader.ReadStartElement("Commanders"); while (reader.IsStartElement()) { Type type = Type.GetType(reader.GetAttribute("AssemblyQualifiedName")); if (type == null) { reader.Skip(); } else { AICommander aicommander = Activator.CreateInstance(type, true) as AICommander; if (aicommander == null) { reader.Skip(); } else { aicommander.Empire = base.AIEntity.Empire; aicommander.AIPlayer = base.AIEntity.AIPlayer; aicommander.Initialize(); reader.ReadElementSerializable <AICommander>(ref aicommander); this.aiCommanders.Add(aicommander); } } } reader.ReadEndElement("Commanders"); }
private void AILayer_KaijuManagement_TamedKaijusCollectionChanged(object sender, CollectionChangeEventArgs e) { if (e.Action == CollectionChangeAction.Add && this.IsActive()) { Kaiju kaiju = e.Element as Kaiju; if (kaiju != null && this.MajorEmpire.TamedKaijus.Contains(kaiju) && kaiju.OnArmyMode()) { AICommander aicommander = this.aiCommanders.Find((AICommander match) => match.ForceArmyGUID == kaiju.KaijuArmy.GUID); if (aicommander == null) { this.AddCommander(new AICommander_KaijuSupport { ForceArmyGUID = kaiju.KaijuArmy.GUID, Empire = base.AIEntity.Empire, AIPlayer = base.AIEntity.AIPlayer }); return; } aicommander.Initialize(); aicommander.Load(); aicommander.CreateMission(); } } }
public override void Initialize(AICommander commander) { base.Initialize(commander); }
void Awake() { player = GameObject.FindGameObjectWithTag ("PlayerFighter"); player.GetComponentInChildren<WeaponsPrimaryFighter> ().allowedToFire = false; playerHealth = player.GetComponent<HealthFighter> (); enemyCommander = GameObject.Find ("Enemy Commander").GetComponent<AICommander> (); startKeyboardText = keyboardControlsText.text; ChangeControlsImage (PlayerPrefs.GetString("Control Scheme")); /*feedbackButton.gameObject.SetActive (true); Navigation navUp = resumeButton.navigation; navUp.selectOnUp = feedbackButton; resumeButton.navigation = navUp; Navigation navUp2 = quitButton.navigation; navUp2.selectOnUp = feedbackButton; quitButton.navigation = navUp2; Navigation navDown = controlsButton.navigation; navDown.selectOnDown = feedbackButton; controlsButton.navigation = navDown;*/ objectiveText.enabled = false; startPos = (GameObject.FindGameObjectWithTag ("AIManager").transform.FindChild ("PMC Commander").position - Vector3.zero).normalized * 500; spawnerScript = GetComponent<Spawner> (); }
private void GenerateRetrofitUnitMessage(AICommander commander) { for (int i = 0; i < commander.Missions.Count; i++) { IGameService service = Services.GetService <IGameService>(); Diagnostics.Assert(service != null); IWorldPositionningService service2 = service.Game.Services.GetService <IWorldPositionningService>(); Diagnostics.Assert(service2 != null); AICommanderMissionWithRequestArmy aicommanderMissionWithRequestArmy = commander.Missions[i] as AICommanderMissionWithRequestArmy; AIData_Army aidata_Army; if (aicommanderMissionWithRequestArmy != null && (aicommanderMissionWithRequestArmy.Completion == AICommanderMission.AICommanderMissionCompletion.Initializing || aicommanderMissionWithRequestArmy.Completion == AICommanderMission.AICommanderMissionCompletion.Pending || aicommanderMissionWithRequestArmy.Completion == AICommanderMission.AICommanderMissionCompletion.Running) && aicommanderMissionWithRequestArmy.AIDataArmyGUID.IsValid && aicommanderMissionWithRequestArmy.AllowRetrofit && this.aiDataRepository.TryGetAIData <AIData_Army>(aicommanderMissionWithRequestArmy.AIDataArmyGUID, out aidata_Army)) { bool flag = true; Region region = service2.GetRegion(aidata_Army.Army.WorldPosition); if (region == null || region.Owner != aidata_Army.Army.Empire) { flag = false; } float num = 0f; bool flag2 = false; AIData_Unit unitData; for (int j = 0; j < aidata_Army.Army.StandardUnits.Count; j++) { if (this.aiDataRepository.TryGetAIData <AIData_Unit>(aidata_Army.Army.StandardUnits[j].GUID, out unitData) && unitData.RetrofitData.MayRetrofit && unitData.RetrofitData.MilitaryPowerDifference > 0f) { flag2 = true; num += unitData.RetrofitData.MilitaryPowerDifference; } } if (flag2) { float propertyValue = aidata_Army.Army.GetPropertyValue(SimulationProperties.MilitaryPower); float num2; bool flag3; bool flag4; aicommanderMissionWithRequestArmy.ComputeNeededArmyPower(out num2, out flag3, out flag4); float num3 = commander.GetPriority(aicommanderMissionWithRequestArmy); if (num <= 0f) { num3 = AILayer.Boost(num3, -0.9f); } else if (!flag3 && propertyValue < num2) { num3 = AILayer.Boost(num3, 0.2f); } DepartmentOfForeignAffairs agency = base.AIEntity.Empire.GetAgency <DepartmentOfForeignAffairs>(); Predicate <EvaluableMessage_RetrofitUnit> < > 9__0; for (int k = 0; k < aidata_Army.Army.StandardUnits.Count; k++) { if (this.aiDataRepository.TryGetAIData <AIData_Unit>(aidata_Army.Army.StandardUnits[k].GUID, out unitData) && unitData.RetrofitData.MayRetrofit && unitData.RetrofitData.MilitaryPowerDifference > 0f) { Blackboard <BlackboardLayerID, BlackboardMessage> blackboard = commander.AIPlayer.Blackboard; BlackboardLayerID blackboardLayerID = BlackboardLayerID.Empire; BlackboardLayerID layerID = blackboardLayerID; Predicate <EvaluableMessage_RetrofitUnit> filter; if ((filter = < > 9__0) == null) { filter = (< > 9__0 = ((EvaluableMessage_RetrofitUnit match) => match.ElementGuid == unitData.Unit.GUID)); } EvaluableMessage_RetrofitUnit evaluableMessage_RetrofitUnit = blackboard.FindFirst <EvaluableMessage_RetrofitUnit>(layerID, filter); if (evaluableMessage_RetrofitUnit == null || evaluableMessage_RetrofitUnit.State != BlackboardMessage.StateValue.Message_InProgress) { evaluableMessage_RetrofitUnit = new EvaluableMessage_RetrofitUnit(unitData.Unit.GUID); commander.AIPlayer.Blackboard.AddMessage(evaluableMessage_RetrofitUnit); } float num4 = 0f; for (int l = 0; l < unitData.RetrofitData.RetrofitCosts.Length; l++) { if (unitData.RetrofitData.RetrofitCosts[l].ResourceName == DepartmentOfTheTreasury.Resources.EmpireMoney) { num4 += unitData.RetrofitData.RetrofitCosts[l].Value; } } if (agency.IsInWarWithSomeone() && unitData.RetrofitData.MilitaryPowerDifference > unitData.Unit.UnitDesign.Context.GetPropertyValue(SimulationProperties.MilitaryPower) && flag && this.diplomacyLayer != null && this.diplomacyLayer.GetMilitaryPowerDif(false) < 0.5f * propertyValue) { evaluableMessage_RetrofitUnit.SetInterest(1f, 1f); } else { evaluableMessage_RetrofitUnit.SetInterest(this.retrofitGlobalPriority, num3); } evaluableMessage_RetrofitUnit.UpdateBuyEvaluation("Retrofit", 0UL, num4, (int)BuyEvaluation.MaxTurnGain, 0f, 0UL); evaluableMessage_RetrofitUnit.TimeOut = 1; } } } } } }
protected Vector2 ChooseEvadePos(Rigidbody2D myRigidbody, LayerMask mask, AICommander myCommanderScript) { /*GameObject closestEnemy = myCommanderScript.ClosestTarget (myCommanderScript.knownEnemyFighters, transform.position); Vector2 dir = ((Vector2)transform.position + myRigidbody.velocity) - ((Vector2)closestEnemy.transform.position + closestEnemy.GetComponent<Rigidbody2D>().velocity); */ Vector3 forward = myRigidbody.velocity.magnitude == 0? transform.up : (Vector3)myRigidbody.velocity.normalized; Vector3 targetDir = Quaternion.AngleAxis(90*(Mathf.Pow(-1, Random.Range(1,3))) , Vector3.forward)*forward; return (Vector2)(transform.position + (targetDir * 2000)); }
void SetUpShipLists(AICommander whichCommander) { currentlyViewedCommanderShips = whichCommander; if (whichCommander == pmcCommander) switchListText.text = "View Enemy Ships"; else if (whichCommander == enemyCommander) switchListText.text = "View PMC Ships"; for(int i=0; i< craftListItems.Count; i++) { craftListItems[i].SetActive(false); } craftToShow.Clear (); craftToShow.AddRange (whichCommander.myFighters); craftToShow.AddRange (whichCommander.myBombers); craftToShow.AddRange (whichCommander.myTransports); craftToShow.AddRange (whichCommander.myCapShips); if (craftToShow.Count <= 0) return; //if there aren't enough buttons created for the list length, make more if(craftListItems.Count < craftToShow.Count) { int howManyMore = craftToShow.Count - craftListItems.Count; for(int i=0; i < howManyMore; i++) { GameObject newListPanel = Instantiate(singleCraftListPrefab) as GameObject; newListPanel.transform.SetParent(allCraftListParent, false); craftListItems.Add(newListPanel); newListPanel.SetActive(false); } } //set up the buttons to reference a craft each for(int i=0; i< craftToShow.Count; i++) { craftListItems[i].GetComponent<TacticalObject>().whoDoIRepresent = craftToShow[i]; craftListItems[i].SetActive(true); craftListItems[i].GetComponentInChildren<Text>().text = craftToShow[i].name; } //set up explicit button navigation and select first item Navigation[] navs = new Navigation[craftListItems.Count]; if(craftListItems.Count >1) { for(int i=0; i< craftToShow.Count; i++) { craftListItems[i].GetComponentInChildren<Animator>().SetTrigger("Normal"); navs[i] = craftListItems[i].GetComponentInChildren<Button> ().navigation; if(i == 0) { navs[i].selectOnUp = craftListItems[craftToShow.Count-1].GetComponentInChildren<Button>(); navs[i].selectOnDown = craftListItems[i+1].GetComponentInChildren<Button>(); } else if(i == craftToShow.Count-1) { navs[i].selectOnDown = craftListItems[0].GetComponentInChildren<Button>(); navs[i].selectOnUp = craftListItems[i-1].GetComponentInChildren<Button>(); } else { navs[i].selectOnUp = craftListItems[i-1].GetComponentInChildren<Button>(); navs[i].selectOnDown = craftListItems[i+1].GetComponentInChildren<Button>(); } craftListItems[i].GetComponentInChildren<Button>().navigation = navs[i]; } } if(craftListItems.Count != 0) { craftListItems [0].GetComponentInChildren<Button> ().Select (); craftListItems [0].GetComponentInChildren<Animator> ().SetTrigger("Highlighted"); } }//end of SetUpShipLists
protected Vector2 ChooseRetreatPosition(Rigidbody2D myRigidbody, LayerMask mask, AICommander enemyCommanderScript) { Collider2D[] enemies = Physics2D.OverlapCircleAll (transform.position, 10f, mask); Vector2 averagePos = Vector2.zero; if(enemies.Length == 0) { Vector2 dir = ((Vector2)transform.position - enemyCommanderScript.AverageForcesPosition()).normalized*20; return ((Vector2)transform.position + myRigidbody.velocity) + dir; } else { foreach(Collider2D col in enemies) { Vector2 enemyVel = col.tag == "Turret"? col.transform.parent.parent.GetComponent<Rigidbody2D>().velocity : col.GetComponent<Rigidbody2D>().velocity; averagePos += ((Vector2)col.transform.position + enemyVel); } averagePos /= enemies.Length; Vector2 dir = ((Vector2)transform.position + myRigidbody.velocity - averagePos).normalized*20; return ((Vector2)transform.position + myRigidbody.velocity) + dir; } }
protected virtual void RemoveCommander(AICommander commander) { commander.Release(); this.aiCommanders.Remove(commander); }
protected void CheckAndAddTargetToCommanderList(AICommander myCommander, GameObject target) { if (whichSide == WhichSide.Ally && myCommander.knownEnemyFighters.Count == 0) _battleEventManager.instance.firstClashCalled = false; if((target.tag == "Fighter" || target.tag == "PlayerFighter") && !myCommander.knownEnemyFighters.Contains(target)) { if(!target.activeInHierarchy || target.GetComponent<HealthFighter>().dead) { Debug.Log(gameObject.name + " BIG F*****G ERROR!!!!!!"); return; } myCommander.knownEnemyFighters.Add(target); if(whichSide == WhichSide.Ally) _battleEventManager.instance.CallFirstWingmanClash(); } else if(target.tag == "Turret" && !myCommander.knownEnemyTurrets.Contains(target)) { if(!target.activeInHierarchy || target.GetComponent<HealthTurret>().dead) { Debug.Log(gameObject.name + " BIG F*****G ERROR!!!!!!"); return; } myCommander.knownEnemyTurrets.Add(target); } else { if(!target.activeInHierarchy || ((target.tag == "Fighter" || target.tag == "PlayerFighter") && target.GetComponent<HealthFighter>().dead) || target.tag == "Turret" && target.GetComponent<HealthTurret>().dead) { myCommander.knownEnemyFighters.Remove(target); Debug.Log("Removed "+target+"(INVALID) from "+ myCommander.name+" KnownFighters List"); } } }
protected override State Execute(AIBehaviorTree aiBehaviorTree, params object[] parameters) { global::Empire empire = aiBehaviorTree.AICommander.Empire; if (empire == null || !(empire is MajorEmpire)) { aiBehaviorTree.ErrorCode = 10; return(State.Failure); } Army army; if (base.GetArmyUnlessLocked(aiBehaviorTree, "$Army", out army) > AIArmyMission.AIArmyMissionErrorCode.None) { return(State.Failure); } GameServer gameServer = (Services.GetService <ISessionService>().Session as global::Session).GameServer as GameServer; AILayer_ArmyManagement ailayer_ArmyManagement = null; AIPlayer_MajorEmpire aiplayer_MajorEmpire; if (gameServer.AIScheduler != null && gameServer.AIScheduler.TryGetMajorEmpireAIPlayer(empire as MajorEmpire, out aiplayer_MajorEmpire)) { AIEntity entity = aiplayer_MajorEmpire.GetEntity <AIEntity_Empire>(); if (entity != null) { ailayer_ArmyManagement = entity.GetLayer <AILayer_ArmyManagement>(); } } if (ailayer_ArmyManagement == null) { return(State.Failure); } int num = int.MaxValue; Army value = null; AICommander aicommander = null; foreach (AICommander aicommander2 in ailayer_ArmyManagement.AICommanders) { if (aicommander2 is AICommander_WarWithObjective || aicommander2 is AICommander_Victory) { foreach (AICommanderMission aicommanderMission in aicommander2.Missions) { IGameEntity gameEntity = null; if (aicommanderMission.AIDataArmyGUID.IsValid && this.gameEntityRepositoryService.TryGetValue(aicommanderMission.AIDataArmyGUID, out gameEntity) && gameEntity is Army) { Army army2 = gameEntity as Army; int distance = this.worldPositionningService.GetDistance(army.WorldPosition, army2.WorldPosition); if (distance < num) { num = distance; value = army2; aicommander = aicommander2; } } } } } if ((float)num > Mathf.Max(army.GetPropertyValue(SimulationProperties.MaximumMovement) * 1.5f, 6f)) { return(State.Failure); } if (aicommander != null && aicommander is AICommanderWithObjective) { AICommanderWithObjective aicommanderWithObjective = aicommander as AICommanderWithObjective; IWorldPositionable worldPositionable = null; if (aicommanderWithObjective.SubObjectiveGuid.IsValid) { IGameEntity gameEntity2 = null; if (this.gameEntityRepositoryService.TryGetValue(aicommanderWithObjective.SubObjectiveGuid, out gameEntity2) && gameEntity2 is IWorldPositionable) { worldPositionable = (gameEntity2 as IWorldPositionable); } } Region region = this.worldPositionningService.GetRegion(aicommanderWithObjective.RegionIndex); if (region.City != null) { worldPositionable = region.City; } if (worldPositionable == null) { if (aiBehaviorTree.Variables.ContainsKey(this.Output_MainTargetVarName)) { aiBehaviorTree.Variables.Remove(this.Output_MainTargetVarName); } return(State.Failure); } if (aiBehaviorTree.Variables.ContainsKey(this.Output_MainTargetVarName)) { aiBehaviorTree.Variables[this.Output_MainTargetVarName] = worldPositionable; } else { aiBehaviorTree.Variables.Add(this.Output_MainTargetVarName, worldPositionable); } } if (aiBehaviorTree.Variables.ContainsKey(this.Output_TargetVarName)) { aiBehaviorTree.Variables[this.Output_TargetVarName] = value; } else { aiBehaviorTree.Variables.Add(this.Output_TargetVarName, value); } return(State.Success); }
protected override void RefreshObjectives(StaticString context, StaticString pass) { base.RefreshObjectives(context, pass); AILayer_Military layer = base.AIEntity.GetLayer <AILayer_Military>(); base.GlobalPriority.Reset(); AILayer_Strategy layer2 = base.AIEntity.GetLayer <AILayer_Strategy>(); base.GlobalPriority.Add(layer2.StrategicNetwork.GetAgentValue("InternalMilitary"), "Strategic network 'InternalMilitary'", new object[0]); base.GlobalPriority.Boost(-0.5f, "Avoid patrol to be high", new object[0]); base.GatherObjectives(AICommanderMissionDefinition.AICommanderCategory.Patrol.ToString(), ref this.patrolObjectives); base.ValidateMessages(ref this.patrolObjectives); if (base.AIEntity.Empire is MajorEmpire) { MajorEmpire majorEmpire = base.AIEntity.Empire as MajorEmpire; for (int i = 0; i < majorEmpire.ConvertedVillages.Count; i++) { Village village = majorEmpire.ConvertedVillages[i]; if (this.worldAtlasHelper.IsRegionExplored(base.AIEntity.Empire, village.Region, 0.95f)) { GlobalObjectiveMessage globalObjectiveMessage = this.patrolObjectives.Find((GlobalObjectiveMessage match) => match.RegionIndex == village.Region.Index); if (globalObjectiveMessage == null) { globalObjectiveMessage = base.GenerateObjective(village.Region.Index); this.patrolObjectives.Add(globalObjectiveMessage); } globalObjectiveMessage.TimeOut = 1; globalObjectiveMessage.GlobalPriority = base.GlobalPriority; HeuristicValue heuristicValue = new HeuristicValue(0f); heuristicValue.Add(layer.GetVillageUnitPriority(village, village.StandardUnits.Count), "Village unit priority", new object[0]); globalObjectiveMessage.LocalPriority = heuristicValue; } } for (int j = 0; j < majorEmpire.TamedKaijus.Count; j++) { Kaiju kaiju = majorEmpire.TamedKaijus[j]; if (kaiju.OnGarrisonMode()) { GlobalObjectiveMessage globalObjectiveMessage2 = this.patrolObjectives.Find((GlobalObjectiveMessage match) => match.RegionIndex == kaiju.Region.Index); if (globalObjectiveMessage2 == null) { globalObjectiveMessage2 = base.GenerateObjective(kaiju.Region.Index); this.patrolObjectives.Add(globalObjectiveMessage2); } globalObjectiveMessage2.TimeOut = 1; globalObjectiveMessage2.GlobalPriority = base.GlobalPriority; HeuristicValue heuristicValue2 = new HeuristicValue(0.6f); AIRegionData regionData = this.worldAtlasHelper.GetRegionData(base.AIEntity.Empire.Index, kaiju.Region.Index); if (regionData != null) { float operand = Mathf.Min(1f, 0.1f * (float)regionData.BorderWithNeutral + 0.2f * (float)regionData.BorderWithEnnemy); heuristicValue2.Boost(operand, "Border with enemy!", new object[0]); } globalObjectiveMessage2.LocalPriority = heuristicValue2; } } } for (int k = 0; k < this.departmentOfTheInterior.Cities.Count; k++) { City city = this.departmentOfTheInterior.Cities[k]; if (this.worldAtlasHelper.IsRegionExplored(base.AIEntity.Empire, city.Region, 0.8f)) { GlobalObjectiveMessage globalObjectiveMessage3 = this.patrolObjectives.Find((GlobalObjectiveMessage match) => match.RegionIndex == city.Region.Index); if (globalObjectiveMessage3 == null) { globalObjectiveMessage3 = base.GenerateObjective(city.Region.Index); this.patrolObjectives.Add(globalObjectiveMessage3); } globalObjectiveMessage3.TimeOut = 1; globalObjectiveMessage3.GlobalPriority = base.GlobalPriority; HeuristicValue heuristicValue3 = new HeuristicValue(0f); heuristicValue3.Add(AILayer_Military.GetCityDefenseLocalPriority(city, this.unitRatioBoost, 0), "City defense local priority", new object[0]); globalObjectiveMessage3.LocalPriority = heuristicValue3; } } if (base.AIEntity.Empire is MajorEmpire) { using (List <int> .Enumerator enumerator = this.questSolverLayer.QuestRegions.GetEnumerator()) { while (enumerator.MoveNext()) { int regionIndex = enumerator.Current; GlobalObjectiveMessage globalObjectiveMessage4 = this.patrolObjectives.Find((GlobalObjectiveMessage match) => match.RegionIndex == regionIndex); if (globalObjectiveMessage4 == null) { globalObjectiveMessage4 = base.GenerateObjective(regionIndex); this.patrolObjectives.Add(globalObjectiveMessage4); } if (globalObjectiveMessage4 != null) { globalObjectiveMessage4.GlobalPriority.Value = 0.85f; globalObjectiveMessage4.LocalPriority.Value = 0.85f; } } } } if (this.departmentOfForeignAffairs.IsInWarWithSomeone()) { base.GatherObjectives(AICommanderMissionDefinition.AICommanderCategory.WarPatrol.ToString(), ref this.warPatrolObjectives); base.ValidateMessages(ref this.warPatrolObjectives); if (base.AIEntity.Empire is MajorEmpire) { MajorEmpire majorEmpire2 = base.AIEntity.Empire as MajorEmpire; for (int l = 0; l < majorEmpire2.ConvertedVillages.Count; l++) { Village village = majorEmpire2.ConvertedVillages[l]; GlobalObjectiveMessage globalObjectiveMessage5 = this.warPatrolObjectives.Find((GlobalObjectiveMessage match) => match.RegionIndex == village.Region.Index); if (globalObjectiveMessage5 == null) { globalObjectiveMessage5 = base.GenerateObjective(village.Region.Index); globalObjectiveMessage5.ObjectiveType = AICommanderMissionDefinition.AICommanderCategory.WarPatrol.ToString(); this.warPatrolObjectives.Add(globalObjectiveMessage5); } globalObjectiveMessage5.TimeOut = 1; globalObjectiveMessage5.GlobalPriority = base.GlobalPriority; HeuristicValue heuristicValue4 = new HeuristicValue(0f); heuristicValue4.Add(layer.GetVillageUnitPriority(village, village.StandardUnits.Count), "Village unit priority", new object[0]); globalObjectiveMessage5.LocalPriority = heuristicValue4; } for (int m = 0; m < majorEmpire2.TamedKaijus.Count; m++) { Kaiju kaiju = majorEmpire2.TamedKaijus[m]; if (kaiju.OnGarrisonMode()) { GlobalObjectiveMessage globalObjectiveMessage6 = this.warPatrolObjectives.Find((GlobalObjectiveMessage match) => match.RegionIndex == kaiju.Region.Index); if (globalObjectiveMessage6 == null) { globalObjectiveMessage6 = base.GenerateObjective(kaiju.Region.Index); this.warPatrolObjectives.Add(globalObjectiveMessage6); } globalObjectiveMessage6.TimeOut = 1; globalObjectiveMessage6.GlobalPriority = base.GlobalPriority; HeuristicValue heuristicValue5 = new HeuristicValue(0.8f); AIRegionData regionData2 = this.worldAtlasHelper.GetRegionData(base.AIEntity.Empire.Index, kaiju.Region.Index); if (regionData2 != null) { float operand2 = Mathf.Min(1f, 0.2f * (float)regionData2.BorderWithNeutral + 0.3f * (float)regionData2.BorderWithEnnemy); heuristicValue5.Boost(operand2, "Border with enemy!", new object[0]); } globalObjectiveMessage6.LocalPriority = heuristicValue5; } } } for (int n = 0; n < this.departmentOfTheInterior.Cities.Count; n++) { City city = this.departmentOfTheInterior.Cities[n]; GlobalObjectiveMessage globalObjectiveMessage7 = this.warPatrolObjectives.Find((GlobalObjectiveMessage match) => match.RegionIndex == city.Region.Index); if (globalObjectiveMessage7 == null) { globalObjectiveMessage7 = base.GenerateObjective(city.Region.Index); globalObjectiveMessage7.ObjectiveType = AICommanderMissionDefinition.AICommanderCategory.WarPatrol.ToString(); this.warPatrolObjectives.Add(globalObjectiveMessage7); } globalObjectiveMessage7.TimeOut = 1; globalObjectiveMessage7.GlobalPriority = base.GlobalPriority; HeuristicValue heuristicValue6 = new HeuristicValue(0f); heuristicValue6.Add(AILayer_Military.GetCityDefenseLocalPriority(city, this.unitRatioBoost, 0), "City defense local priority", new object[0]); if (this.worldAtlasHelper.GetRegionData(city.Empire.Index, city.Region.Index).BorderWithEnnemy > 0) { heuristicValue6.Boost(0.2f, "Border with enemy!", new object[0]); } globalObjectiveMessage7.LocalPriority = heuristicValue6; } bool flag = false; for (int num = 0; num < this.warPatrolObjectives.Count; num++) { GlobalObjectiveMessage warPatrolObjective = this.warPatrolObjectives[num]; if (base.AIEntity.GetCommanderProcessingTheNeededGlobalObjective(warPatrolObjective.ID) == null) { GlobalObjectiveMessage globalObjectiveMessage8 = this.patrolObjectives.Find((GlobalObjectiveMessage match) => match.RegionIndex == warPatrolObjective.RegionIndex); if (globalObjectiveMessage8 != null) { AICommander commanderProcessingTheNeededGlobalObjective = base.AIEntity.GetCommanderProcessingTheNeededGlobalObjective(globalObjectiveMessage8.ID); if (commanderProcessingTheNeededGlobalObjective != null) { commanderProcessingTheNeededGlobalObjective.Release(); flag = true; } } } } if (flag) { base.AIEntity.KillAllCommanders("AICommander_Exploration"); } } }