Exemple #1
0
        public HaroldsEndeavour()
        {
            InitializeComponent();

            if (File.Exists(PLAYER_DATA_FILR_NAME))
            {
                _player = Player.CreatePlayerFromXmlString(File.ReadAllText(PLAYER_DATA_FILR_NAME));
            }
            else
            {
                _player = Player.CreateDefaultPlayer();
                MainMenuScreen mainMenuScreen = new MainMenuScreen(_player);
                mainMenuScreen.StartPosition = FormStartPosition.CenterParent;
                mainMenuScreen.ShowDialog(this);
            }

            cboWeapons.DataSource    = _player.Weapons;
            cboWeapons.DisplayMember = "Name";
            cboWeapons.ValueMember   = "Id";

            if (_player.CurrentWeapon != null)
            {
                cboWeapons.SelectedItem = _player.CurrentWeapon;
            }

            EventHandler cboWeapons_SelectedIndexChanged = null;

            cboWeapons.SelectedIndexChanged += cboWeapons_SelectedIndexChanged;

            cboPotions.DataSource    = _player.Potions;
            cboPotions.DisplayMember = "Name";
            cboPotions.ValueMember   = "Id";

            _player.PropertyChanged += PlayerOnPropertyChanged;

            MoveTo(_player.CurrentLocation);

            UpdatePlayerStats();
        }