Beispiel #1
0
        public PreGame(string path)
        {
            InitializeComponent();

            _path = path;

            // load the scenario from json file
            using (StreamReader r = new StreamReader(Path.Combine(_path, "scenario.json")))
            {
                string         json     = r.ReadToEnd();
                ScenarioSchema scenario = JsonConvert.DeserializeObject <ScenarioSchema>(json);
                // set the title of the scenario
                TitleLabel.Content = new TextBlock {
                    Text = scenario.Title, TextWrapping = TextWrapping.Wrap
                };
                // set description text
                DescriptionLabel.Content = new TextBlock {
                    Text = scenario.Description, TextWrapping = TextWrapping.Wrap, TextAlignment = TextAlignment.Left
                };
                // load the image
                BitmapImage bitmapImage = new BitmapImage(new Uri(Path.Combine(_path, scenario.Image)));
                BgImage.Source = bitmapImage;
                // prepare the scenario's settings to be loaded
                _settings   = scenario.Settings;
                _introVideo = scenario.IntroVideo;
            }
        }
Beispiel #2
0
        public ScenarioBlock(string path, Action <string> loadPreGame)
        {
            InitializeComponent();

            _path        = path;
            _loadPreGame = loadPreGame;

            BitmapImage bitmapImage = new BitmapImage(new Uri(Path.Combine(path, "bg.png")));

            BgImage.Source = bitmapImage;

            // load the scenario from json file
            using (StreamReader r = new StreamReader(Path.Combine(path, "scenario.json")))
            {
                string         json     = r.ReadToEnd();
                ScenarioSchema scenario = JsonConvert.DeserializeObject <ScenarioSchema>(json);
                TitleLabel.Content = new TextBlock {
                    Text = scenario.Title, TextWrapping = TextWrapping.Wrap
                };
                SubTitleLabel.Content = new TextBlock {
                    Text = scenario.Subtitle, TextWrapping = TextWrapping.Wrap
                };
            }
        }