Exemplo n.º 1
0
        protected void setButtonsState()
        {
            giveControlToPlayer.interactable = SelectedCountry.isAI();
            giveControlToAi.interactable     = !SelectedCountry.isAI();

            declareWar.interactable = !Diplomacy.IsInWar(Game.Player, this.SelectedCountry);
        }
Exemplo n.º 2
0
        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
            });
        }
Exemplo n.º 3
0
 public void OnDeclareWar()
 {
     if (Game.Player != this.SelectedCountry && !Diplomacy.IsInWar(Game.Player, this.SelectedCountry))
     {
         Diplomacy.DeclareWar(Game.Player, this.SelectedCountry);
         Refresh();
     }
 }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        /// <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());
                }
        }
Exemplo n.º 6
0
 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);
 }
Exemplo n.º 7
0
 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();
         });
     });
 }
Exemplo n.º 8
0
    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();
    }
Exemplo n.º 9
0
 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();
 }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
 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));
         }
     }
 }
Exemplo n.º 12
0
 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();
         });
     });
 }
Exemplo n.º 13
0
        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);
                }
            }
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
 public int Add(Diplomacy o)
 {
     return(new DiplomacyDAO().Add(o));
 }
Exemplo n.º 16
0
 public DiplomacyProxi(Diplomacy we, Diplomacy they) =>
 (state, relation, delta, war, forceAccess, fabrCB, patronage, uniqueCB, deal) =
Exemplo n.º 17
0
 public void AnnexationButton()
 {
     player.state.Annexation(select.state);
     Diplomacy.DeclareWar(player, select, false);
     ProvinceMenu.instance.UpdateMenu();
 }
Exemplo n.º 18
0
 public void WhitePeaceButton()
 {
     Player.instance.WhitePeace(player.state, select.state);
     Diplomacy.DeclareWar(player, select, false);
     SchowDiplomacy();
 }
Exemplo n.º 19
0
    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));
    }
Exemplo n.º 20
0
        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);
                        }
                    }
                }
            }
        }
Exemplo n.º 21
0
        /// <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;
        }
Exemplo n.º 22
0
 public void Show(Diplomacy diplomacy)
 {
     this.diplomacy = diplomacy;
     UpdateInfo();
 }
Exemplo n.º 23
0
 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();
                 });
             });
         }
     });
 }