protected void setButtonsState() { giveControlToPlayer.interactable = SelectedCountry.isAI(); giveControlToAi.interactable = !SelectedCountry.isAI(); declareWar.interactable = !Diplomacy.IsInWar(Game.Player, this.SelectedCountry); }
public static void DeclareWar(DialogueContext Context) { Context.Envoy.OwnerFaction.Race.Speech.Language.SayBoo(); if (!Context.Politics.HasEvent("you declared war on us")) { Context.Politics.RecentEvents.Add(new Diplomacy.PoliticalEvent() { Change = -2.0f, Description = "you declared war on us", Duration = new TimeSpan(4, 0, 0, 0), Time = Context.World.Time.CurrentDate }); Context.Politics.WasAtWar = true; } Context.Say(Datastructures.SelectRandom(Context.Envoy.OwnerFaction.Race.Speech.WarDeclarations)); Context.ClearOptions(); Context.AddOption("Goodbye.", (context) => { Diplomacy.RecallEnvoy(context.Envoy); GameState.Game.StateManager.PopState(); }); Context.World.GoalManager.OnGameEvent(new Goals.Events.DeclareWar { PlayerFaction = Context.PlayerFaction, OtherFaction = Context.Envoy.OwnerFaction }); }
public void OnDeclareWar() { if (Game.Player != this.SelectedCountry && !Diplomacy.IsInWar(Game.Player, this.SelectedCountry)) { Diplomacy.DeclareWar(Game.Player, this.SelectedCountry); Refresh(); } }
private static void _recall_envoy(YarnEngine State, List <Ancora.AstNode> Arguments, Yarn.MemoryVariableStore Memory) { var envoy = Memory.GetValue("$envoy").AsObject as TradeEnvoy; if (envoy == null) { State.PlayerInterface.Output("Command 'recall_envoy' can only be called from a TradeEnvoy initiated conversation."); return; } Diplomacy.RecallEnvoy(envoy); }
/// <summary> /// Serializes the data elements into the internal buffer. /// </summary> /// <remarks></remarks> private void WriteData() { // Initialize buffer if (_buffer == null) { _buffer = new RAMBuffer(); } else if (_buffer.Length != 0) { _buffer.Clear(); } // Write header _buffer.WriteString("1.21", 4); _buffer.WriteUInteger(4 + 4 + 4 + (uint)ScenarioInstructions.Length + 4 + 4); _buffer.WriteInteger(2); _buffer.WriteUInteger(LastSaveTimestamp); _buffer.WriteInteger(ScenarioInstructions.Length); _buffer.WriteString(ScenarioInstructions); _buffer.WriteUInteger(0); _buffer.WriteUInteger(PlayerCount); // Create buffer for compressed data elements RAMBuffer comprBuffer = new RAMBuffer(); Header.WriteData(comprBuffer); MessagesCinematics.WriteData(comprBuffer); PlayerAiResources.WriteData(comprBuffer); GlobalVictory.WriteData(comprBuffer); Diplomacy.WriteData(comprBuffer); Disables.WriteData(comprBuffer); Map.WriteData(comprBuffer); Units.WriteData(comprBuffer); PlayerDiplomacyVarious.WriteData(comprBuffer); Triggers.WriteData(comprBuffer); IncludedFiles.WriteData(comprBuffer); // Compress data and copy to main buffer using (MemoryStream output = new MemoryStream()) using (MemoryStream input = comprBuffer.ToMemoryStream()) { // Create compressor stream using (DeflateStream compressor = new DeflateStream(output, CompressionMode.Compress)) { // Compress input.CopyTo(compressor); input.Close(); } // Save compressed data into main buffer _buffer.Write(output.ToArray()); } }
public short GetRelation(Clan clan) { if (clan == this && clan.Id != 0) { return((short)objects.Diplomacy.ALLIED); } if (Diplomacy.ContainsKey(clan.Id)) { return((short)Diplomacy[clan.Id]); } return((short)objects.Diplomacy.NONE); }
public static Action <DialogueContext> GoodbyeWithPrompt(String Prompt) { return((context) => { context.Say(Prompt); context.ClearOptions(); context.AddOption("Goodbye.", (_) => { Diplomacy.RecallEnvoy(context.Envoy); GameState.Game.StateManager.PopState(); }); }); }
public void Yes() { switch (dipstate) { case 0: Diplomacy.DeclareWar(player, select, true); War(); return; case 1: GlobalTrade.MakeDeal(deal); /*if (player.haveDeal(select)) * player.BreakTradeDeal(select); * else * player.SendOfferTradeDeal(select, new TradeDeal(player.state, sellT, sellR, select.state, buyT, buyR)); */ UpdateTradePanel(); return; break; case 2: if (player.haveAccess(select)) { player.ForceAccess(select, false); } else { player.SendOfferForceAccess(select); } break; case 3: player.FabricateCasusBelli(select, !player.fabricatingCasus(select), actionSlider.value); break; case 4: player.Insult(select); break; case 5: player.BeginPatronage(select, !player.havePatronage(select)); break; case 6: player.Uniate(select); break; } that.RecalculArmyPath(); other.RecalculArmyPath(); SchowDiplomacy(); }
public void SchowDiplomacy(State pl, State sel) { if (pl == null) { return; } player = pl.diplomacy; that = pl; if (sel.diplomacy == select) { return; } select = sel.diplomacy; other = sel; SchowDiplomacy(); }
public void Initialize() { Diplomacy.FastClear(); for (int i = 0; i < TeamManager.Teams.Count; i++) { Team team = TeamManager.Teams[i]; if (team != this) { Diplomacy.AddAt(AllegianceType.Neutral, team.ID); } } TeamManager.UpdateDiplomacy(this); this.SetAllegiance(this, AllegianceType.Friendly); MainController = new AgentController(); MainController.JoinTeam(this); }
static void CreateDiplomacy() { Diplomacy.InitDiplomacy(states.Count); for (int i = 0; i < states.Count; i++) { states[i].ID = i; states[i].diplomacy = new Diplomacy(states[i]); } for (int i = 0; i < states.Count; i++) { var target = states[i].GetWarTarget(); if (target != null) { states[i].diplomacy.uniqueCB.Add((target.diplomacy, 1)); } } }
public static void ConversationRoot(DialogueContext Context) { Context.Say(String.Format("{0} I am {1} of {2}.", Datastructures.SelectRandom(Context.Envoy.OwnerFaction.Race.Speech.Greetings), Context.EnvoyName, Context.Envoy.OwnerFaction.Name)); Context.ClearOptions(); Context.AddOption("Trade", Trade); Context.AddOption("Leave", (context) => { Diplomacy.RecallEnvoy(context.Envoy); Context.Say(Datastructures.SelectRandom(context.Envoy.OwnerFaction.Race.Speech.Farewells)); Context.ClearOptions(); Context.AddOption("Goodbye.", (_) => { GameState.Game.StateManager.PopState(); }); }); }
private static void LoadClanDiplomacy(Clan clan) { using (var mySqlClient = SqlDatabaseManager.GetClient()) { var data = (DataTable)mySqlClient.ExecuteQueryTable($"SELECT * FROM server_clan_diplomacy WHERE senderClan = {clan.Id}"); foreach (DataRow row in data.Rows) { int id = Convert.ToInt32(row["toClan"]); Diplomacy relation = (Diplomacy)Convert.ToInt32(row["diplomacyType"]); clan.Diplomacy.Add(id, relation); } var data2 = (DataTable)mySqlClient.ExecuteQueryTable($"SELECT * FROM server_clan_diplomacy WHERE toClan = {clan.Id}"); foreach (DataRow row in data2.Rows) { int id = Convert.ToInt32(row["senderClan"]); Diplomacy relation = (Diplomacy)Convert.ToInt32(row["diplomacyType"]); clan.Diplomacy.Add(id, relation); } } }
public override JSONObject Serialize() { JSONObject obj = new JSONObject(); obj.Add(cAppraise, Appraise.Serialize()); obj.Add(cBalance, Balance.Serialize()); obj.Add(cBluff, Bluff.Serialize()); obj.Add(cClimb, Climb.Serialize()); obj.Add(cConcentration, Concentration.Serialize()); obj.Add(cDecipherScript, DecipherScript.Serialize()); obj.Add(cDiplomacy, Diplomacy.Serialize()); obj.Add(cDisableDevice, DisableDevice.Serialize()); obj.Add(cDisguise, Disguise.Serialize()); obj.Add(cEscapeArtist, EscapeArtist.Serialize()); obj.Add(cForgery, Forgery.Serialize()); obj.Add(cGatherInformation, GatherInformation.Serialize()); obj.Add(cHandleAnimal, HandleAnimal.Serialize()); obj.Add(cHeal, Heal.Serialize()); obj.Add(cHide, Hide.Serialize()); obj.Add(cIntimidate, Intimidate.Serialize()); obj.Add(cJump, Jump.Serialize()); obj.Add(cListen, Listen.Serialize()); obj.Add(cMoveSilently, MoveSilently.Serialize()); obj.Add(cOpenLock, OpenLock.Serialize()); obj.Add(cRide, Ride.Serialize()); obj.Add(cSearch, Search.Serialize()); obj.Add(cSenseMotive, SenseMotive.Serialize()); obj.Add(cSleightOfHand, SleightOfHand.Serialize()); obj.Add(cSpellCraft, SpellCraft.Serialize()); obj.Add(cSpot, Spot.Serialize()); obj.Add(cSurvival, Survival.Serialize()); obj.Add(cSwim, Swim.Serialize()); obj.Add(cTumble, Tumble.Serialize()); obj.Add(cUseMagicDevice, UseMagicDevice.Serialize()); obj.Add(cUseRope, UseRope.Serialize()); return(obj); }
public int Add(Diplomacy o) { return(new DiplomacyDAO().Add(o)); }
public DiplomacyProxi(Diplomacy we, Diplomacy they) => (state, relation, delta, war, forceAccess, fabrCB, patronage, uniqueCB, deal) =
public void AnnexationButton() { player.state.Annexation(select.state); Diplomacy.DeclareWar(player, select, false); ProvinceMenu.instance.UpdateMenu(); }
public void WhitePeaceButton() { Player.instance.WhitePeace(player.state, select.state); Diplomacy.DeclareWar(player, select, false); SchowDiplomacy(); }
public bool CanCastOnRegion(Region region) { Diplomacy Owner = Person.owner.diplomacy; return(region != null && region.curOwner != null && region.curOwner.diplomacy != null && Owner.haveWar(region.curOwner.diplomacy)); }
public void DiplomacyStatusUpdate(int mapId, IList <Field> fields) { IList <Kingdom> kingdoms = new KingdomDAO().GetByMapId(mapId); Dictionary <int, Rectangle> kingdomsArea = new Dictionary <int, Rectangle>(); foreach (Field field in fields) { if (!kingdomsArea.ContainsKey(field.KingdomId)) { kingdomsArea[field.KingdomId] = new Rectangle(); } if (field.FieldX > kingdomsArea[field.KingdomId].maxX) { kingdomsArea[field.KingdomId].maxX = field.FieldX; } if (field.FieldY > kingdomsArea[field.KingdomId].maxY) { kingdomsArea[field.KingdomId].maxY = field.FieldY; } if (field.FieldX < kingdomsArea[field.KingdomId].minX) { kingdomsArea[field.KingdomId].minX = field.FieldX; } if (field.FieldY < kingdomsArea[field.KingdomId].minY) { kingdomsArea[field.KingdomId].minY = field.FieldY; } } foreach (Kingdom kingdom in kingdoms) { IList <Diplomacy> diplomacy = new DiplomacyDAO().GetByUserId(kingdom.UserId); foreach (Kingdom kingdomA in kingdoms) { if (kingdomsArea[kingdom.KingdomId].CollidesWith(kingdomsArea[kingdomA.KingdomId], 2)) { bool mustAdd = true; foreach (Diplomacy dip in diplomacy) { if (dip.SecondaryUserId == kingdomA.UserId) { mustAdd = false; } } if (mustAdd) { Diplomacy dip = new Diplomacy(); dip.MainUserId = kingdom.UserId; dip.SecondaryUserId = kingdomA.UserId; dip.DiplomacyStatusId = 1;// hardcode, nie che mi sie znowu do bazy dodawac pierdolowatej metody, w bazie najlepiej by pod tym id byla wojna new DiplomacyDAO().Add(dip); } } } } }
/// <summary> /// Creates the user interface + player controls. /// </summary> /// <param name="createMaster">True if the Game Master needs to be created as well.</param> public void CreateGUI(bool createMaster) { LoadingMessage = "Creating GUI"; IndicatorManager.SetupStandards(); GUI = new DwarfGUI(Game, Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Default), Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Title), Game.Content.Load<SpriteFont>(ContentPaths.Fonts.Small), Input); if(!createMaster) { return; } Master = new GameMaster(ComponentManager.Factions.Factions["Player"], Game, ComponentManager, ChunkManager, Camera, GraphicsDevice, GUI); Diplomacy = new Diplomacy(ComponentManager.Factions); Diplomacy.Initialize(Time.CurrentDate); CreateGUIComponents(); GUI.MouseMode = GUISkin.MousePointer.Wait; }
public void Show(Diplomacy diplomacy) { this.diplomacy = diplomacy; UpdateInfo(); }
public static Action <DialogueContext> RootWithPrompt(String Prompt) { return((Context) => { if (Context.Politics.WasAtWar) { Context.Say("We are at war."); Context.AddOption("Make peace", MakePeace); Context.AddOption("Continue the war", DeclareWar); } else { Context.Say(Prompt); Context.ClearOptions(); Context.AddOption("Trade", Trade); Context.AddOption("What is your opinion of us?", (context) => { var prompt = ""; if (context.Politics.RecentEvents.Count > 0) { prompt = String.Format("So far, our relationship has been {0}", context.Politics.GetCurrentRelationship()); if (context.Politics.RecentEvents.Count > 0) { prompt += ", because "; prompt += TextGenerator.GetListString( context.Politics.RecentEvents.Select(e => e.Description).ToList()); } prompt += "."; } else { prompt = "We know nothing about you."; } Context.Transition(RootWithPrompt(prompt)); }); Context.AddOption("What is something you have many of?", (context) => { Context.Transition(RootWithPrompt(String.Format("We have many {0}.", GetPluralForm(Datastructures.SelectRandom(context.Envoy.OwnerFaction.Race.CommonResources))))); }); Context.AddOption("What is something you have few of?", (context) => { if (context.Envoy.OwnerFaction.Race.RareResources.Count > 0) { Context.Transition(RootWithPrompt(String.Format("We have few {0}.", GetPluralForm(Datastructures.SelectRandom(context.Envoy.OwnerFaction.Race.RareResources))))); } else { Context.Transition(RootWithPrompt("Nothing in particular.")); } }); Context.AddOption("What is something you hate?", (context) => { if (context.Envoy.OwnerFaction.Race.HatedResources.Count > 0) { Context.Transition(RootWithPrompt(String.Format("We hate {0}.", GetPluralForm(Datastructures.SelectRandom(context.Envoy.OwnerFaction.Race.HatedResources))))); } else { Context.Transition(RootWithPrompt("We don't hate anything in particular.")); } }); Context.AddOption("What is something you like?", (context) => { if (context.Envoy.OwnerFaction.Race.LikedResources.Count > 0) { Context.Transition(RootWithPrompt(String.Format("We like {0}.", GetPluralForm(Datastructures.SelectRandom(context.Envoy.OwnerFaction.Race.LikedResources))))); } else { Context.Transition(RootWithPrompt("We don't like anything in particular.")); } }); Context.AddOption("Declare war", ConfirmDeclareWar); Context.AddOption("Leave", (context) => { Context.Say(Datastructures.SelectRandom(context.Envoy.OwnerFaction.Race.Speech.Farewells)); Context.ClearOptions(); Context.AddOption("Goodbye.", (_) => { Diplomacy.RecallEnvoy(context.Envoy); GameState.Game.StateManager.PopState(); }); }); } }); }