Exemplo n.º 1
0
        private static void SyncPlayerHistoryState(
            App game,
            string panelName,
            PlayerInfo playerInfo,
            bool updateButtonIds)
        {
            int turnCount = game.GameDatabase.GetTurnCount();

            game.UI.ClearItems(DiplomacyUI.UINewsList);
            List <DiplomacyReactionHistoryEntryInfo> list = game.GameDatabase.GetDiplomacyReactionHistory(playerInfo.ID, game.Game.LocalPlayer.ID, turnCount, 10).ToList <DiplomacyReactionHistoryEntryInfo>();
            Vector3 vector3_1 = new Vector3(0.2f, 0.8f, 0.2f);
            Vector3 vector3_2 = new Vector3(0.8f, 0.2f, 0.2f);

            foreach (DiplomacyReactionHistoryEntryInfo historyEntryInfo in list)
            {
                Vector3 vector3_3 = historyEntryInfo.Difference > 0 ? vector3_1 : vector3_2;
                game.UI.AddItem(game.UI.Path(panelName, DiplomacyUI.UINewsList), string.Empty, historyEntryInfo.ID, string.Empty);
                string itemGlobalId = game.UI.GetItemGlobalID(game.UI.Path(panelName, DiplomacyUI.UINewsList), string.Empty, historyEntryInfo.ID, string.Empty);
                game.UI.SetEnabled(itemGlobalId, false);
                game.UI.SetPropertyString(game.UI.Path(itemGlobalId, "txtTurn"), "text", historyEntryInfo.TurnCount.ToString());
                game.UI.SetPropertyString(game.UI.Path(itemGlobalId, "txtType"), "text", App.Localize("@" + historyEntryInfo.Reaction.ToString()));
                game.UI.SetPropertyString(game.UI.Path(itemGlobalId, "txtChange"), "text", historyEntryInfo.Difference > 0 ? string.Format("+{0}", (object)historyEntryInfo.Difference) : historyEntryInfo.Difference.ToString());
                game.UI.SetPropertyColorNormalized(game.UI.Path(itemGlobalId, "txtChange"), "color", vector3_3);
            }
            game.UI.ClearItems(DiplomacyUI.UIInteractionsList);
            foreach (DiplomacyActionHistoryEntryInfo actionInfo in game.GameDatabase.GetDiplomacyActionHistory(playerInfo.ID, game.Game.LocalPlayer.ID, turnCount - 1, 10).ToList <DiplomacyActionHistoryEntryInfo>())
            {
                game.UI.AddItem(game.UI.Path(panelName, DiplomacyUI.UIInteractionsList), string.Empty, actionInfo.ID, string.Empty);
                string itemGlobalId = game.UI.GetItemGlobalID(game.UI.Path(panelName, DiplomacyUI.UIInteractionsList), string.Empty, actionInfo.ID, string.Empty);
                game.UI.SetEnabled(itemGlobalId, false);
                game.UI.SetPropertyString(game.UI.Path(itemGlobalId, "txtTurn"), "text", actionInfo.TurnCount.ToString());
                game.UI.SetPropertyString(game.UI.Path(itemGlobalId, "txtInteraction"), "text", DiplomacyUI.GetDiplomacyActionString(game, actionInfo));
            }
        }
Exemplo n.º 2
0
        private static void SyncDiplomacyActionsState(
            App game,
            string panelName,
            PlayerInfo playerInfo,
            bool updateButtonIds)
        {
            int         turnCount     = game.GameDatabase.GetTurnCount();
            FactionInfo factionInfo   = game.GameDatabase.GetFactionInfo(playerInfo.FactionID);
            string      propertyValue = game.GameDatabase.GetPlayerInfo(game.Game.LocalPlayer.ID).FactionDiplomacyPoints[factionInfo.ID].ToString();
            List <DiplomacyActionHistoryEntryInfo> list = game.GameDatabase.GetDiplomacyActionHistory(game.Game.LocalPlayer.ID, playerInfo.ID, turnCount, 1).ToList <DiplomacyActionHistoryEntryInfo>();

            game.UI.ClearItems(game.UI.Path(panelName, DiplomacyUI.UIPendingActions));
            foreach (DiplomacyActionHistoryEntryInfo actionInfo in list)
            {
                game.UI.AddItem(game.UI.Path(panelName, DiplomacyUI.UIPendingActions), string.Empty, actionInfo.ID, string.Empty);
                string itemGlobalId = game.UI.GetItemGlobalID(game.UI.Path(panelName, DiplomacyUI.UIPendingActions), string.Empty, actionInfo.ID, string.Empty);
                game.UI.SetEnabled(itemGlobalId, false);
                game.UI.SetPropertyString(game.UI.Path(itemGlobalId, "txtTurn"), "text", actionInfo.TurnCount.ToString());
                game.UI.SetPropertyString(game.UI.Path(itemGlobalId, "txtInteraction"), "text", DiplomacyUI.GetDiplomacyActionString(game, actionInfo));
            }
            string        str = ((IEnumerable <string>)panelName.Split('.')).First <string>();
            bool          isStandardPlayer = playerInfo.isStandardPlayer;
            UICommChannel ui1 = game.UI;
            string        panelId1;

            if (!isStandardPlayer)
            {
                panelId1 = game.UI.Path(panelName, DiplomacyUI.UIDeclareButton);
            }
            else
            {
                panelId1 = string.Format("{0}|{1}", (object)str, (object)DiplomacyUI.UIDeclareButton);
            }
            string text = string.Format(App.Localize("@UI_DIPLOMACY_DECLARE"), (object)game.Game.GetDiplomacyActionCost(DiplomacyAction.DECLARATION, new RequestType?(), new DemandType?()));

            ui1.SetButtonText(panelId1, text);
            UICommChannel ui2 = game.UI;
            string        panelId2;

            if (!isStandardPlayer)
            {
                panelId2 = game.UI.Path(panelName, DiplomacyUI.UISurpriseAttackButton);
            }
            else
            {
                panelId2 = string.Format("{0}|{1}", (object)str, (object)DiplomacyUI.UISurpriseAttackButton);
            }
            int num1 = DiplomacyUI.EnableSupriseButton(game.Game, playerInfo) ? 1 : 0;

            ui2.SetEnabled(panelId2, num1 != 0);
            UICommChannel ui3 = game.UI;
            string        panelId3;

            if (!isStandardPlayer)
            {
                panelId3 = game.UI.Path(panelName, DiplomacyUI.UIDeclareButton);
            }
            else
            {
                panelId3 = string.Format("{0}|{1}", (object)str, (object)DiplomacyUI.UIDeclareButton);
            }
            int num2 = DiplomacyUI.EnableDeclareButton(game.Game, playerInfo) ? 1 : 0;

            ui3.SetEnabled(panelId3, num2 != 0);
            UICommChannel ui4 = game.UI;
            string        panelId4;

            if (!isStandardPlayer)
            {
                panelId4 = game.UI.Path(panelName, DiplomacyUI.UIRequestButton);
            }
            else
            {
                panelId4 = string.Format("{0}|{1}", (object)str, (object)DiplomacyUI.UIRequestButton);
            }
            int num3 = DiplomacyUI.EnableRequestButton(game.Game, playerInfo) ? 1 : 0;

            ui4.SetEnabled(panelId4, num3 != 0);
            UICommChannel ui5 = game.UI;
            string        panelId5;

            if (!isStandardPlayer)
            {
                panelId5 = game.UI.Path(panelName, DiplomacyUI.UIDemandButton);
            }
            else
            {
                panelId5 = string.Format("{0}|{1}", (object)str, (object)DiplomacyUI.UIDemandButton);
            }
            int num4 = DiplomacyUI.EnableDemandButton(game.Game, playerInfo) ? 1 : 0;

            ui5.SetEnabled(panelId5, num4 != 0);
            UICommChannel ui6 = game.UI;
            string        panelId6;

            if (!isStandardPlayer)
            {
                panelId6 = game.UI.Path(panelName, DiplomacyUI.UITreatyButton);
            }
            else
            {
                panelId6 = string.Format("{0}|{1}", (object)str, (object)DiplomacyUI.UITreatyButton);
            }
            int num5 = DiplomacyUI.EnableTreatyButton(game.Game, playerInfo) ? 1 : 0;

            ui6.SetEnabled(panelId6, num5 != 0);
            game.UI.SetPropertyString(game.UI.Path(panelName, DiplomacyUI.UIActionRdpValue), "text", propertyValue);
        }