public static WarType Get(int id) { WarType warType = new WarType(); using (var dbContext = new HouseOfClansEntities()) { warType = dbContext.WarTypes.Where(p => p.id == id).FirstOrDefault(); } return(warType); }
public override int GetHashCode() { //https://stackoverflow.com/a/892640/3131828 unchecked { int h = 23; h *= 31 + (WarType?.GetHashCode() ?? 0); h *= 31 + (Status?.GetHashCode() ?? 0); h *= 31 + (Faction1?.GetHashCode() ?? 0); h *= 31 + (Faction2?.GetHashCode() ?? 0); return(h); } }
private void PcJetEnemy_MouseClick(object sender, MouseEventArgs e) { if (_yourTurn) { pcJetEnemy.Enabled = false; labelJetEnemy.Enabled = false; pcSoldierEnemy.Enabled = false; labelSoldierEnemy.Enabled = false; pcTankEnemy.Enabled = false; labelTankEnemy.Enabled = false; _yourTurn = false; _defender = WarType.Jet; _commands.Append("/y"); DefineAtackCommand(); } }
public void GetWarDeclaredOnUs(Empire WarDeclarant, WarType wt) { this.empire.GetRelations()[WarDeclarant].AtWar = true; this.empire.GetRelations()[WarDeclarant].FedQuest = null; this.empire.GetRelations()[WarDeclarant].Posture = Posture.Hostile; this.empire.GetRelations()[WarDeclarant].ActiveWar = new War(this.empire, WarDeclarant, this.empire.GetUS().StarDate) { WarType = wt }; if (EmpireManager.GetEmpireByName(this.empire.GetUS().PlayerLoyalty) != this.empire) { string name = this.empire.data.DiplomaticPersonality.Name; if (name != null && name == "Pacifist") { if (this.empire.GetRelations()[WarDeclarant].ActiveWar.StartingNumContestedSystems <= 0) { this.empire.GetRelations()[WarDeclarant].ActiveWar.WarType = WarType.DefensiveWar; } else { this.empire.GetRelations()[WarDeclarant].ActiveWar.WarType = WarType.BorderConflict; } } } if (this.empire.GetRelations()[WarDeclarant].Trust > 0f) { this.empire.GetRelations()[WarDeclarant].Trust = 0f; } this.empire.GetRelations()[WarDeclarant].Treaty_Alliance = false; this.empire.GetRelations()[WarDeclarant].Treaty_NAPact = false; this.empire.GetRelations()[WarDeclarant].Treaty_OpenBorders = false; this.empire.GetRelations()[WarDeclarant].Treaty_Trade = false; this.empire.GetRelations()[WarDeclarant].Treaty_Peace = false; }
public void DeclareWarOnViaCall(Empire them, WarType wt) { this.empire.GetRelations()[them].PreparingForWar = false; if (this.empire.isFaction || this.empire.data.Defeated || them.data.Defeated || them.isFaction) { return; } this.empire.GetRelations()[them].FedQuest = null; if (this.empire == EmpireManager.GetEmpireByName(this.empire.GetUS().PlayerLoyalty) && this.empire.GetRelations()[them].Treaty_NAPact) { this.empire.GetRelations()[them].Treaty_NAPact = false; Relationship item = them.GetRelations()[this.empire]; item.Trust = item.Trust - 50f; Relationship angerDiplomaticConflict = them.GetRelations()[this.empire]; angerDiplomaticConflict.Anger_DiplomaticConflict = angerDiplomaticConflict.Anger_DiplomaticConflict + 50f; them.GetRelations()[this.empire].UpdateRelationship(them, this.empire); } if (them == EmpireManager.GetEmpireByName(this.empire.GetUS().PlayerLoyalty) && !this.empire.GetRelations()[them].AtWar) { switch (wt) { case WarType.BorderConflict: { if (this.empire.GetRelations()[them].contestedSystemGuid == Guid.Empty) { this.empire.GetUS().ScreenManager.AddScreen(new DiplomacyScreen(this.empire, them, "Declare War BC")); break; } else { this.empire.GetUS().ScreenManager.AddScreen(new DiplomacyScreen(this.empire, them, "Declare War BC Tarsys", this.empire.GetRelations()[them].GetContestedSystem())); break; } } case WarType.ImperialistWar: { if (!this.empire.GetRelations()[them].Treaty_NAPact) { this.empire.GetUS().ScreenManager.AddScreen(new DiplomacyScreen(this.empire, them, "Declare War Imperialism")); break; } else { this.empire.GetUS().ScreenManager.AddScreen(new DiplomacyScreen(this.empire, them, "Declare War Imperialism Break NA")); break; } } case WarType.DefensiveWar: { if (this.empire.GetRelations()[them].Treaty_NAPact) { if (!this.empire.GetRelations()[them].Treaty_NAPact) { break; } this.empire.GetUS().ScreenManager.AddScreen(new DiplomacyScreen(this.empire, them, "Declare War Defense BrokenNA")); this.empire.GetRelations()[them].Treaty_NAPact = false; Relationship trust = this.empire.GetRelations()[them]; trust.Trust = trust.Trust - 50f; Relationship relationship = this.empire.GetRelations()[them]; relationship.Anger_DiplomaticConflict = relationship.Anger_DiplomaticConflict + 50f; break; } else { this.empire.GetUS().ScreenManager.AddScreen(new DiplomacyScreen(this.empire, them, "Declare War Defense")); Relationship item1 = this.empire.GetRelations()[them]; item1.Anger_DiplomaticConflict = item1.Anger_DiplomaticConflict + 25f; Relationship trust1 = this.empire.GetRelations()[them]; trust1.Trust = trust1.Trust - 25f; break; } } } } if (them == EmpireManager.GetEmpireByName(this.empire.GetUS().PlayerLoyalty) || this.empire == EmpireManager.GetEmpireByName(this.empire.GetUS().PlayerLoyalty)) { Ship.universeScreen.NotificationManager.AddWarDeclaredNotification(this.empire, them); } else if (EmpireManager.GetEmpireByName(this.empire.GetUS().PlayerLoyalty).GetRelations()[them].Known && EmpireManager.GetEmpireByName(this.empire.GetUS().PlayerLoyalty).GetRelations()[this.empire].Known) { Ship.universeScreen.NotificationManager.AddWarDeclaredNotification(this.empire, them); } this.empire.GetRelations()[them].AtWar = true; this.empire.GetRelations()[them].Posture = Posture.Hostile; this.empire.GetRelations()[them].ActiveWar = new War(this.empire, them, this.empire.GetUS().StarDate) { WarType = wt }; if (this.empire.GetRelations()[them].Trust > 0f) { this.empire.GetRelations()[them].Trust = 0f; } this.empire.GetRelations()[them].Treaty_OpenBorders = false; this.empire.GetRelations()[them].Treaty_NAPact = false; this.empire.GetRelations()[them].Treaty_Trade = false; this.empire.GetRelations()[them].Treaty_Alliance = false; this.empire.GetRelations()[them].Treaty_Peace = false; them.GetGSAI().GetWarDeclaredOnUs(this.empire, wt); }
public void DeclareWarOn(Empire them, WarType wt) { this.empire.GetRelations()[them].PreparingForWar = false; if (this.empire.isFaction || this.empire.data.Defeated || (them.data.Defeated || them.isFaction)) return; this.empire.GetRelations()[them].FedQuest = (FederationQuest)null; if (this.empire == EmpireManager.GetEmpireByName(this.empire.GetUS().PlayerLoyalty) && this.empire.GetRelations()[them].Treaty_NAPact) { this.empire.GetRelations()[them].Treaty_NAPact = false; foreach (KeyValuePair<Empire, Relationship> keyValuePair in this.empire.GetRelations()) { if (keyValuePair.Key != them) { keyValuePair.Key.GetRelations()[this.empire].Trust -= 50f; keyValuePair.Key.GetRelations()[this.empire].Anger_DiplomaticConflict += 20f; keyValuePair.Key.GetRelations()[this.empire].UpdateRelationship(keyValuePair.Key, this.empire); } } them.GetRelations()[this.empire].Trust -= 50f; them.GetRelations()[this.empire].Anger_DiplomaticConflict += 50f; them.GetRelations()[this.empire].UpdateRelationship(them, this.empire); } if (them == EmpireManager.GetEmpireByName(this.empire.GetUS().PlayerLoyalty) && !this.empire.GetRelations()[them].AtWar) { switch (wt) { case WarType.BorderConflict: if (this.empire.GetRelations()[them].contestedSystemGuid != Guid.Empty) { this.empire.GetUS().ScreenManager.AddScreen((GameScreen)new DiplomacyScreen(this.empire, them, "Declare War BC TarSys", this.empire.GetRelations()[them].GetContestedSystem())); break; } else { this.empire.GetUS().ScreenManager.AddScreen((GameScreen)new DiplomacyScreen(this.empire, them, "Declare War BC")); break; } case WarType.ImperialistWar: if (this.empire.GetRelations()[them].Treaty_NAPact) { this.empire.GetUS().ScreenManager.AddScreen((GameScreen)new DiplomacyScreen(this.empire, them, "Declare War Imperialism Break NA")); using (Dictionary<Empire, Relationship>.Enumerator enumerator = this.empire.GetRelations().GetEnumerator()) { while (enumerator.MoveNext()) { KeyValuePair<Empire, Relationship> current = enumerator.Current; if (current.Key != them) { current.Value.Trust -= 50f; current.Value.Anger_DiplomaticConflict += 20f; } } break; } } else { this.empire.GetUS().ScreenManager.AddScreen((GameScreen)new DiplomacyScreen(this.empire, them, "Declare War Imperialism")); break; } case WarType.DefensiveWar: if (!this.empire.GetRelations()[them].Treaty_NAPact) { this.empire.GetUS().ScreenManager.AddScreen((GameScreen)new DiplomacyScreen(this.empire, them, "Declare War Defense")); this.empire.GetRelations()[them].Anger_DiplomaticConflict += 25f; this.empire.GetRelations()[them].Trust -= 25f; break; } else if (this.empire.GetRelations()[them].Treaty_NAPact) { this.empire.GetUS().ScreenManager.AddScreen((GameScreen)new DiplomacyScreen(this.empire, them, "Declare War Defense BrokenNA")); this.empire.GetRelations()[them].Treaty_NAPact = false; foreach (KeyValuePair<Empire, Relationship> keyValuePair in this.empire.GetRelations()) { if (keyValuePair.Key != them) { keyValuePair.Value.Trust -= 50f; keyValuePair.Value.Anger_DiplomaticConflict += 20f; } } this.empire.GetRelations()[them].Trust -= 50f; this.empire.GetRelations()[them].Anger_DiplomaticConflict += 50f; break; } else break; } } if (them == EmpireManager.GetEmpireByName(this.empire.GetUS().PlayerLoyalty) || this.empire == EmpireManager.GetEmpireByName(this.empire.GetUS().PlayerLoyalty)) Ship.universeScreen.NotificationManager.AddWarDeclaredNotification(this.empire, them); else if (EmpireManager.GetEmpireByName(this.empire.GetUS().PlayerLoyalty).GetRelations()[them].Known && EmpireManager.GetEmpireByName(this.empire.GetUS().PlayerLoyalty).GetRelations()[this.empire].Known) Ship.universeScreen.NotificationManager.AddWarDeclaredNotification(this.empire, them); this.empire.GetRelations()[them].AtWar = true; this.empire.GetRelations()[them].Posture = Posture.Hostile; this.empire.GetRelations()[them].ActiveWar = new War(this.empire, them, this.empire.GetUS().StarDate); this.empire.GetRelations()[them].ActiveWar.WarType = wt; if ((double)this.empire.GetRelations()[them].Trust > 0.0) this.empire.GetRelations()[them].Trust = 0.0f; this.empire.GetRelations()[them].Treaty_OpenBorders = false; this.empire.GetRelations()[them].Treaty_NAPact = false; this.empire.GetRelations()[them].Treaty_Trade = false; this.empire.GetRelations()[them].Treaty_Alliance = false; this.empire.GetRelations()[them].Treaty_Peace = false; them.GetGSAI().GetWarDeclaredOnUs(this.empire, wt); }
public void DeclareWarFromEvent(Empire them, WarType wt) { this.empire.GetRelations()[them].AtWar = true; this.empire.GetRelations()[them].Posture = Posture.Hostile; this.empire.GetRelations()[them].ActiveWar = new War(this.empire, them, this.empire.GetUS().StarDate) { WarType = wt }; if (this.empire.GetRelations()[them].Trust > 0f) { this.empire.GetRelations()[them].Trust = 0f; } this.empire.GetRelations()[them].Treaty_OpenBorders = false; this.empire.GetRelations()[them].Treaty_NAPact = false; this.empire.GetRelations()[them].Treaty_Trade = false; this.empire.GetRelations()[them].Treaty_Alliance = false; this.empire.GetRelations()[them].Treaty_Peace = false; them.GetGSAI().GetWarDeclaredOnUs(this.empire, wt); }
public bool StartWar(Gang enemyGang, TurfZone warZone, WarType theWarType, AttackStrength attackStrength) { if (!isOccurring || enemyGang == GangManager.instance.PlayerGang) { this.enemyGang = enemyGang; this.warZone = warZone; this.curWarType = theWarType; curWarAtkStrength = attackStrength; playerNearWarzone = false; spawnPointsSet = false; warBlip = World.CreateBlip(warZone.zoneBlipPosition); warBlip.IsFlashing = true; warBlip.Sprite = BlipSprite.Deathmatch; warBlip.Color = BlipColor.Red; warAreaBlip = World.CreateBlip(warZone.zoneBlipPosition, ModOptions.instance.maxDistToWarBlipBeforePlayerLeavesWar); warAreaBlip.Sprite = BlipSprite.BigCircle; warAreaBlip.Color = BlipColor.Red; warAreaBlip.Alpha = 175; Function.Call(Hash.BEGIN_TEXT_COMMAND_SET_BLIP_NAME, "STRING"); Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, "Gang War (versus " + enemyGang.name + ")"); Function.Call(Hash.END_TEXT_COMMAND_SET_BLIP_NAME, warBlip); curTicksAwayFromBattle = 0; enemiesInsideCars = SpawnManager.instance.GetSpawnedMembersOfGang(enemyGang, true); if (theWarType == WarType.attackingEnemy) { alliedReinforcements = GangCalculations.CalculateAttackerReinforcements(GangManager.instance.PlayerGang, attackStrength); enemyReinforcements = GangCalculations.CalculateDefenderReinforcements(enemyGang, warZone); } else { alliedReinforcements = GangCalculations.CalculateDefenderReinforcements(GangManager.instance.PlayerGang, warZone); enemyReinforcements = GangCalculations.CalculateAttackerReinforcements(enemyGang, attackStrength); } float screenRatio = (float)Game.ScreenResolution.Width / Game.ScreenResolution.Height; int proportionalScreenWidth = (int)(1080 * screenRatio); //nativeUI UIResText works with 1080p height alliedNumText.Position = new Point((proportionalScreenWidth / 2) - 120, 10); enemyNumText.Position = new Point((proportionalScreenWidth / 2) + 120, 10); alliedNumText.Caption = alliedReinforcements.ToString(); enemyNumText.Caption = enemyReinforcements.ToString(); initialEnemyReinforcements = enemyReinforcements; reinforcementsAdvantage = alliedReinforcements / (float)enemyReinforcements; spawnedAllies = SpawnManager.instance.GetSpawnedMembersOfGang(GangManager.instance.PlayerGang).Count; spawnedEnemies = SpawnManager.instance.GetSpawnedMembersOfGang(enemyGang).Count; maxSpawnedAllies = (int)(RandoMath.Max((ModOptions.instance.spawnedMemberLimit / 2) * reinforcementsAdvantage, 5)); maxSpawnedEnemies = RandoMath.Max(ModOptions.instance.spawnedMemberLimit - maxSpawnedAllies, 5); isOccurring = true; //BANG-like sound Function.Call(Hash.PLAY_SOUND_FRONTEND, -1, "PROPERTY_PURCHASE", "HUD_AWARDS"); if (theWarType == WarType.attackingEnemy) { UI.ShowSubtitle("The " + enemyGang.name + " are coming!"); //if we are attacking, set spawns around the player! SetSpawnPoints(MindControl.CurrentPlayerCharacter.Position); } else { UI.Notify(string.Concat("The ", enemyGang.name, " are attacking ", warZone.zoneName, "! They are ", GangCalculations.CalculateAttackerReinforcements(enemyGang, attackStrength).ToString(), " against our ", GangCalculations.CalculateDefenderReinforcements(GangManager.instance.PlayerGang, warZone).ToString())); //spawns are set around the zone blip if we are defending if (World.GetDistance(MindControl.CurrentPlayerCharacter.Position, warZone.zoneBlipPosition) < 100) { SetSpawnPoints(warZone.zoneBlipPosition); } } SetHateRelationsBetweenGangs(); return(true); } else { return(false); } }
private void PcJetYou_MouseClick(object sender, MouseEventArgs e) { if (_playerEnemy.IsReady && _playerYou.IsReady) { if (_playerEnemy.Jets <= 0) { pcJetEnemy.Enabled = false; labelJetEnemy.Enabled = false; } else { pcJetEnemy.Enabled = true; labelJetEnemy.Enabled = true; } if (_playerEnemy.Soldiers <= 0) { pcSoldierEnemy.Enabled = false; labelSoldierEnemy.Enabled = false; } else { pcSoldierEnemy.Enabled = true; labelSoldierEnemy.Enabled = true; } if (_playerEnemy.Tanks <= 0) { pcTankEnemy.Enabled = false; labelTankEnemy.Enabled = false; } else { pcTankEnemy.Enabled = true; labelTankEnemy.Enabled = true; } _attacker = WarType.Jet; } else if (!_playerYou.IsReady) { if (e.Button == MouseButtons.Left) { if (_buyPoints - Constants.JetPoints <= 0) { return; } _playerYou.Jets++; _buyPoints -= Constants.JetPoints; } else if (e.Button == MouseButtons.Right) { if (_playerYou.Jets == 0) { return; } _playerYou.Jets--; _buyPoints += Constants.JetPoints; } pcJetYou.Text = string.Format("Flugzeug ({0:00})", Math.Ceiling(_playerYou.Jets)); buttonReady.Text = $"Fertig ({_buyPoints})"; } }