/// <summary> /// Launches an attack on the NPC faction's current target faction. /// </summary> /// <returns>True if the attack has been successfully launched, otherwise false.</returns> public bool LaunchAttack() { //making sure there's a valid target faction or we're in the peace time if (targetFaction == null || gameMgr.InPeaceTime()) { return(false); } //mark as attacking: IsAttacking = true; RefreshCurrentAttackUnits(); //we'll be searching for the next building to attack starting from the last attack pos, initially set it as the capital building lastAttackPos = gameMgr.GetFaction(factionMgr.FactionID).CapitalPosition; currentTarget = null; //pick a target building: SetTargetEntity(targetFaction.GetBuildings().Cast <FactionEntity>(), true); //start the attack order timer: attackOrderTimer = attackOrderReloadRange.getRandomValue(); return(true); }
//method to launch the attack: void LaunchAttack() { //making sure there's a valid target faction: if (targetFaction == null) { return; } //mark as attacking: isAttacking = true; //clear the current attack units list: currentAttackUnits.Clear(); currentAttackUnits.AddRange(factionMgr.GetAttackUnits(1 - npcMgr.defenseManager_NPC.defenseRatioRange.getRandomValue())); //get the required units for this attack. //we'll be searching for the next building to attack starting from the last attack pos, initially set it as the capital building lastAttackPos = gameMgr.GetFaction(factionMgr.FactionID).CapitalPosition; currentTarget = null; //pick a target building: SetTargetEntity(targetFaction.GetBuildings().Cast <FactionEntity>()); //start the attack order timer: attackOrderTimer = attackOrderReloadRange.getRandomValue(); }