private void CheckFrontLineBonus() { flResourceModifier = 1f; flgrowthModifier = 1f; flOffDefModifier = 1f; int noSystems = 0; for (int i = 0; i < MasterScript.systemListConstructor.systemList[thisSystem].permanentConnections.Count; ++i) { int neighbour = MasterScript.RefreshCurrentSystem(MasterScript.systemListConstructor.systemList[thisSystem].permanentConnections[i]); if (MasterScript.systemListConstructor.systemList[neighbour].systemOwnedBy != null && MasterScript.systemListConstructor.systemList[neighbour].systemOwnedBy != thisPlayer.playerRace) { DiplomaticPosition temp = MasterScript.diplomacyScript.ReturnDiplomaticRelation(MasterScript.systemListConstructor.systemList[thisSystem].systemOwnedBy, MasterScript.systemListConstructor.systemList[neighbour].systemOwnedBy); flResourceModifier += temp.resourceModifier; flgrowthModifier += temp.growthModifier; flOffDefModifier += temp.offDefModifier; ++noSystems; } } if (noSystems != 0) { flResourceModifier = flResourceModifier / noSystems; flgrowthModifier = flgrowthModifier / noSystems; flOffDefModifier = flOffDefModifier / noSystems; } }
public string[] GetRelationships(DiplomaticPosition value, string faction) { List <string> relations = new List <string>(); if (attitudes.ContainsKey(faction)) { foreach (KeyValuePair <object, List <string> > valFac in attitudes[faction]) { if (typeof(T) == typeof(int)) { if (GetDiplomaticPosition((int)valFac.Key) == value) { foreach (string fo in valFac.Value) { relations.Add(fo); } } } else if (typeof(T) == typeof(float)) { if (GetDiplomaticPosition((float)valFac.Key) == value) { foreach (string fo in valFac.Value) { relations.Add(fo); } } } } } return(relations.ToArray()); }
public void SetUpRelationsList() //Use to generate list of all diplomatic relationships between players { for (int i = 0; i < MasterScript.turnInfoScript.allPlayers.Count; ++i) { DiplomaticPosition relation = new DiplomaticPosition(); //Create new relation for AI and connect to players relation.playerOne = MasterScript.turnInfoScript.allPlayers[i]; relation.playerTwo = MasterScript.playerTurnScript; relation.stateCounter = 49; relation.firstContact = false; relationsList.Add(relation); for (int j = 0; j < MasterScript.turnInfoScript.allPlayers.Count; ++j) //This ensures that all players are connected, and that no multiple connections exist { if (MasterScript.turnInfoScript.allPlayers[i].playerRace == MasterScript.turnInfoScript.allPlayers[j].playerRace) { continue; } bool skip = false; for (int k = 0; k < relationsList.Count; ++k) { if (relationsList[k].playerOne.playerRace == MasterScript.turnInfoScript.allPlayers[i].playerRace && relationsList[k].playerTwo.playerRace == MasterScript.turnInfoScript.allPlayers[j].playerRace) { skip = true; break; } if (relationsList[k].playerTwo.playerRace == MasterScript.turnInfoScript.allPlayers[i].playerRace && relationsList[k].playerOne.playerRace == MasterScript.turnInfoScript.allPlayers[j].playerRace) { skip = true; break; } } if (skip == false) { DiplomaticPosition relationTwo = new DiplomaticPosition(); //Connect AI players relationTwo.playerOne = MasterScript.turnInfoScript.allPlayers[i]; relationTwo.playerTwo = MasterScript.turnInfoScript.allPlayers[j]; relationTwo.stateCounter = 49; relationTwo.firstContact = false; relationsList.Add(relationTwo); } } } }
private float PromoteBonus() //Calculates resource bonus from promotions on enemy systems { float totalAdjacencyBonus = 1f; if (promotedBy == null) { for (int i = 0; i < MasterScript.systemListConstructor.systemList[thisSystem].permanentConnections.Count; ++i) { int j = MasterScript.RefreshCurrentSystem(MasterScript.systemListConstructor.systemList[thisSystem].permanentConnections[i]); systemSIMData = MasterScript.systemListConstructor.systemList[j].systemObject.GetComponent <SystemSIMData>(); if (systemSIMData.promotedBy != null) { if (MasterScript.systemListConstructor.systemList[j].systemOwnedBy == thisPlayer.playerRace) { totalAdjacencyBonus += 0.05f; } else { totalAdjacencyBonus += 0.1f; } } } } else if (promotedBy != null) { if (promotionTimer + 30.0f < Time.time) { promotedBy = null; } DiplomaticPosition temp = MasterScript.diplomacyScript.ReturnDiplomaticRelation(thisPlayer.playerRace, promotedBy); ++temp.stateCounter; totalAdjacencyBonus = 1.5f; } return(totalAdjacencyBonus); }
private float EmbargoPenalty() //Calculates penalties from Embargoes { if (embargoedBy != null) { DiplomaticPosition temp = MasterScript.diplomacyScript.ReturnDiplomaticRelation(thisPlayer.playerRace, embargoedBy); --temp.stateCounter; if (embargoTimer + 20.0f < Time.time) { embargoedBy = null; } float embargoPenalty = 1 - temp.resourceModifier; return(embargoPenalty); } return(1); }
public void PopulateRelationTree(ref TreeView tree) { foreach (var priFac in attitudes) { foreach (var relValue in priFac.Value) { foreach (string secFac in relValue.Value) { DiplomaticPosition dp = GetDiplomaticPosition((int)relValue.Key); switch (dp) { case DiplomaticPosition.Allied: tree.Nodes[priFac.Key].Nodes["Relationships"].Nodes["Allied"].Nodes.Add(secFac); tree.Nodes[secFac].Nodes["Relationships"].Nodes["Allied"].Nodes.Add(priFac.Key); break; case DiplomaticPosition.Hostile: tree.Nodes[priFac.Key].Nodes["Relationships"].Nodes["Hostile"].Nodes.Add(secFac); tree.Nodes[secFac].Nodes["Relationships"].Nodes["Hostile"].Nodes.Add(priFac.Key); break; case DiplomaticPosition.Neutral: tree.Nodes[priFac.Key].Nodes["Relationships"].Nodes["Neutral"].Nodes.Add(secFac); tree.Nodes[secFac].Nodes["Relationships"].Nodes["Neutral"].Nodes.Add(priFac.Key); break; case DiplomaticPosition.Suspicous: tree.Nodes[priFac.Key].Nodes["Relationships"].Nodes["Suspicous"].Nodes.Add(secFac); tree.Nodes[secFac].Nodes["Relationships"].Nodes["Suspicous"].Nodes.Add(priFac.Key); break; case DiplomaticPosition.War: tree.Nodes[priFac.Key].Nodes["Relationships"].Nodes["At War"].Nodes.Add(secFac); tree.Nodes[secFac].Nodes["Relationships"].Nodes["At War"].Nodes.Add(priFac.Key); break; } } } } }
public MagickImage CreateDiplomacyMap(Descr_Strat ds, Descr_Region dr, SMFactions smf, string factionName, string savepath) { MagickImage regionMap = new MagickImage(dr.FilePathRegions); //use region map to map out regions var rpixels = regionMap.GetPixels(); //colours MagickColor fac1 = new MagickColor(Color.Gold); //get the faction colour primary MagickColor facCol2 = new MagickColor(Color.White); // secondary colour MagickColor allied = new MagickColor(Color.Green); MagickColor suspicous = new MagickColor(Color.Blue); MagickColor neutral = new MagickColor(Color.Aqua); MagickColor hostile = new MagickColor(Color.MediumVioletRed); MagickColor war = new MagickColor(Color.DarkRed); MagickColor currentColour1 = fac1; MagickColor currentColour2 = facCol2; MagickImage factionMap = new MagickImage(radarMapLocation); foreach (Faction f in ds.factions) // loop through faction { int relationval = (int)ds.factionRelationships.DoesFactionHaveRelations(factionName, f.name); if (f.name == factionName) { currentColour1 = fac1; currentColour2 = facCol2; } else if (relationval > -1) { DiplomaticPosition dp = ds.factionRelationships.GetDiplomaticPosition(relationval); if (dp == DiplomaticPosition.Allied) { currentColour1 = allied; } else if (dp == DiplomaticPosition.Hostile) { currentColour1 = hostile; } else if (dp == DiplomaticPosition.Neutral) { currentColour1 = neutral; } else if (dp == DiplomaticPosition.Suspicous) { currentColour1 = suspicous; } else if (dp == DiplomaticPosition.War) { currentColour1 = war; } } else { continue; } using (IPixelCollection fmPixels = factionMap.GetPixels()) { foreach (Settlement s in f.settlements) //loop through settlements to get the regions { int[] regColour = dr.GetRGBValue(s.region); //get the colour of a region MagickColor regCol = MagickColor.FromRgb((byte)regColour[0], (byte)regColour[1], (byte)regColour[2]); int channelsCount = fmPixels.Channels; for (int y = 0; y < factionMap.Height; y++) { List <ushort[]> regVert = new List <ushort[]>(); //create lists to store each pixel along the width of the image List <ushort[]> facVert = new List <ushort[]>(); if (y - 1 >= 0) { regVert.Add(rpixels.GetArea(0, y - 1, regionMap.Width, 1)); // get string of pixels across the image at current y value facVert.Add(fmPixels.GetArea(0, y - 1, factionMap.Width, 1)); } regVert.Add(rpixels.GetArea(0, y, regionMap.Width, 1)); facVert.Add(fmPixels.GetArea(0, y, factionMap.Width, 1)); if (y + 1 < regionMap.Height) { facVert.Add(fmPixels.GetArea(0, y + 1, factionMap.Width, 1)); regVert.Add(rpixels.GetArea(0, y + 1, regionMap.Width, 1)); } int i = 0; if (regVert.Count == 2) { i = 0; } else { i = 1; } for (int x = 0; x < regVert[i].Length; x += channelsCount) // traverse each pixel across the image at the current y value { MagickColor pixCol = new MagickColor(regVert[i][x], regVert[i][x + 1], regVert[i][x + 2]); //create magickcolour using MagickColor fCol = new MagickColor(facVert[i][x], facVert[i][x + 1], facVert[i][x + 2]); if (pixCol == regCol) //compare region colour { int bc = BorderCheck(x, i, regVert, regCol); //check if region is a border if (bc > 1 && bc < 4) { fmPixels.SetPixel(x == 0 ? x : x / 3, y, Blend(currentColour2, fCol, 0.6)); } else { fmPixels.SetPixel(x == 0 ? x : x / 3, y, Blend(currentColour1, fCol, 0.6)); } } } } } } } return(factionMap); }