Ejemplo n.º 1
0
        public static Dialog Fetch(string filename, string objectname)
        {
            var dialog = new Dialog();
            dialog.Nodes = new Dictionary<int, DialogNode>();

            string settingString = String.Join("\r\n", File.ReadAllLines("Content/Dialog/" + filename + ".js"));

            var nodeList = Newtonsoft.Json.Linq.JObject.Parse(settingString);

            foreach(var node in nodeList[objectname]["nodes"])
            {
                var dialogNode = new DialogNode
                    {
                        Identifier = (int) (node["identifier"]),
                        Text = node["text"].ToString(),
                        Options = new Dictionary<string, int>()
                    };

                if (node.SelectToken("options") != null && node["options"].Any())
                {
                    foreach(var option in node["options"])
                    {
                        dialogNode.Options.Add(option["text"].ToString(), (int)option["node"]);
                    }
                }

                dialog.Nodes.Add(dialogNode.Identifier, dialogNode);
            }

            dialog.Continue();

            return dialog;
        }
Ejemplo n.º 2
0
        public EventHandler<InteractEventArgs> SimpleChest(string name, List<Item> contents)
        {
            return (sender, args) =>
                {
                    if (_clearedChests.Contains(name)) return;

                    var scene = ((OverworldScene) sender);
                    var dialog = new Dialog();
                    dialog.Nodes.Add(1, new DialogNode { Identifier = 1, Text = "Found items:" });

                    foreach(var item in contents)
                    {
                        dialog.Nodes[1].Text += "\n" + item.Name;
                    }

                    dialog.OnExit = (o, eventArgs) => ((SRPGGame) scene.Game).Inventory.AddRange(contents);
                    dialog.Continue();
                    scene.StartDialog(dialog);
                    _clearedChests.Add(name);
                };
        }
Ejemplo n.º 3
0
        public void StartDialog(Dialog dialog)
        {
            StopCharacter();

            Game.IsMouseVisible = true;

            dialog.OnExit += EndDialogEvent;
            _dialog = new DialogLayer(this, dialog);
            Gui.Screen.Desktop.Children.Add(_dialog);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Pre-battle initialization sequence to load characters, the battleboard and the image layers.
        /// </summary>
        protected override void OnEntered()
        {
            base.OnEntered();

            QueuedCommands = new List<Command>();

            _characterStats = new CharacterStatsDialog();
            Gui.Screen.Desktop.Children.Add(_characterStats);

            _hud = new HUDDialog();
            _hud.EndTurnPressed += EndPlayerTurn;
            Gui.Screen.Desktop.Children.Add(_hud);

            _queuedCommands = new QueuedCommandsDialog(QueuedCommands);
            _queuedCommands.ExecuteClicked += ExecuteQueuedCommands;

            _abilityStatLayer = new AbilityStatDialog();

            Game.IsMouseVisible = true;

            Gui.Visualizer = FlatGuiVisualizer.FromFile(Game.Services, "Content/Gui/main_gui.xml");

            ((FlatGuiVisualizer)Gui.Visualizer).RendererRepository.AddAssembly(typeof(FlatImageButtonControlRenderer).Assembly);
            ((FlatGuiVisualizer)Gui.Visualizer).RendererRepository.AddAssembly(typeof(FlatTiledIconControlRenderer).Assembly);
            ((FlatGuiVisualizer)Gui.Visualizer).RendererRepository.AddAssembly(typeof(FlatRadialButtonControlRenderer).Assembly);
            ((FlatGuiVisualizer)Gui.Visualizer).RendererRepository.AddAssembly(typeof(FlatQueuedCommandControlRenderer).Assembly);

            var keyboard = new KeyboardInputLayer(this, null);
            keyboard.AddKeyDownBinding(Keys.Escape, Cancel);
            Components.Add(keyboard);

            if (_startingDialog != null)
            {
                StartDialog(_startingDialog);
                _startingDialog = null;
            }
        }
Ejemplo n.º 5
0
        public void StartDialog(Dialog dialog)
        {
            dialog.OnExit += EndDialogEvent;
            _dialog = new DialogLayer(this, dialog);
            Gui.Screen.Desktop.Children.Add(_dialog);

            _state = BattleState.Dialog;
            _battleBoardLayer.FreeAim = false;
            _battleBoardLayer.AbilityAim = false;
            HideGui(_characterStats);
            HideGui(_hud);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Initialize a battle sequence by name. This call happens at the start of a battle and is required
        /// for this scene to not die a horrible death.
        /// </summary>
        /// <param name="battleName">Name of the battle to be initialized</param>
        public void SetBattle(string battleName)
        {
            // set up defaults

            BattleBoard = new BattleBoard();

            RoundNumber = 0;
            FactionTurn = 0;
            _state = BattleState.PlayerTurn;
            var partyGrid = new List<Point>();

            _battleBoardLayer = new BattleBoardLayer(this, null);
            _battleBoardLayer.CharacterSelected += SelectCharacter;

            Components.Add(_battleBoardLayer);

            switch(battleName)
            {
                case "coliseum/halls":
                    _battleBoardLayer.SetBackground("Zones/Coliseum/Halls/north");
                    _battleBoardLayer.SetGrid("Zones/Coliseum/Halls/battle");
                    BattleBoard.Sandbag = Grid.FromBitmap(Game.Services, "Zones/Coliseum/Halls/battle");
                    _battleBoardLayer.AddImage(new ImageObject(Game, _battleBoardLayer, "Zones/Coliseum/Halls/north"));
                    _battleBoardLayer.AddImage(new ImageObject(Game, _battleBoardLayer, "Zones/Coliseum/pillar") { X = 393, Y = 190, DrawOrder = 248 });
                    _battleBoardLayer.AddImage(new ImageObject(Game, _battleBoardLayer, "Zones/Coliseum/pillar") { X = 393, Y = 390, DrawOrder = 448 });
                    _battleBoardLayer.AddImage(new ImageObject(Game, _battleBoardLayer, "Zones/Coliseum/pillar") { X = 393, Y = 590, DrawOrder = 648 });
                    _battleBoardLayer.AddImage(new ImageObject(Game, _battleBoardLayer, "Zones/Coliseum/pillar") { X = 593, Y = 190, DrawOrder = 248 });
                    _battleBoardLayer.AddImage(new ImageObject(Game, _battleBoardLayer, "Zones/Coliseum/pillar") { X = 593, Y = 390, DrawOrder = 448 });
                    _battleBoardLayer.AddImage(new ImageObject(Game, _battleBoardLayer, "Zones/Coliseum/pillar") { X = 593, Y = 590, DrawOrder = 648 });

                    partyGrid.Add(new Point(10,13));
                    partyGrid.Add(new Point(11,13));
                    partyGrid.Add(new Point(9,13));
                    partyGrid.Add(new Point(10,12));
                    partyGrid.Add(new Point(11,12));
                    partyGrid.Add(new Point(9,12));

                    BattleBoard.Characters.Add(GenerateCombatant("Guard 1", "coliseum/guard", new Vector2(9, 3)));
                    BattleBoard.Characters.Add(GenerateCombatant("Guard 2", "coliseum/guard", new Vector2(11, 3)));
                    BattleBoard.Characters.Add(GenerateCombatant("Guard Captain", "coliseum/guard", new Vector2(10, 3)));

                    BattleBoard.Characters.Add(GenerateCombatant("Guard 3", "coliseum/guard", new Vector2(9, 10)));
                    BattleBoard.Characters.Add(GenerateCombatant("Guard 4", "coliseum/guard", new Vector2(11, 10)));
                    BattleBoard.Characters.Add(GenerateCombatant("Guard 5", "coliseum/guard", new Vector2(10, 10)));

                    _startingDialog = Dialog.Fetch("coliseum", "guards");

                    break;
                default:
                    throw new Exception("unknown battle " + battleName);
            }

            // add party to the party grid for this battle, in order
            for(var i = 0; i < ((SRPGGame)Game).Party.Count; i++)
            {
                var character = ((SRPGGame) Game).Party[i];
                character.Avatar.Location.X = partyGrid[i].X;
                character.Avatar.Location.Y = partyGrid[i].Y;
                BattleBoard.Characters.Add(character);
            }

            _battleBoardLayer.SetBoard(BattleBoard);
            _commander.BattleBoard = BattleBoard;

            // center camera on partyGrid[0]
            UpdateCamera(
                0 - partyGrid[0].X*50 + Game.GraphicsDevice.Viewport.Width/2,
                0 - partyGrid[0].Y*50 + Game.GraphicsDevice.Viewport.Height/2
            );

            ChangeFaction(0);
        }