コード例 #1
0
        public void OnDungeonSelected(object sender, GestureEventArgs e)
        {
            var selectedGrid = sender as Grid;
            var dungeonId = (int)selectedGrid.Tag;
            _selectedDungeon = GetDungeon(dungeonId);

            var heroRepository = new HeroRepository();
            _heroesOwnedByPlayer = heroRepository.GetHeroesOwnedByPlayer().Count;

            var playerRepository = new PlayerRepository();
            _player = playerRepository.GetPlayer();

            if (PlayerCanEnterDungeon())
            {
                _player.Stam.Current = _player.Stam.Current - _selectedDungeon.StaminaCost;
                playerRepository.SavePlayer(_player);
                MessageBus.Default.Notify("EnterDungeon", new Object(), new NotificationEventArgs(dungeonId.ToString()));
            }
            else
            {
                var errorModalControl = GetErrorMessage();
                var errorModal = new ModalContainer(errorModalControl);
                errorModal.Show();
            }
        }
コード例 #2
0
        private void StatBars(object sender, RoutedEventArgs e)
        {
            _playerRepository = new PlayerRepository();
            _player = _playerRepository.GetPlayer();

            UpdateStamina(_player);
            ColorStatBars(_player);
        }
コード例 #3
0
 private void UpdateStamina(Player player)
 {
     if (ShouldUpdateStamina())
     {
         var additionalStamina = AmountToUpdateStaminaBy();
         player.Stam.Current += additionalStamina;
         _playerRepository.SavePlayer(player);
     }
 }
コード例 #4
0
        private void ColorStatBars(Player player)
        {
            var expFillColor = new SolidColorBrush(Color.FromArgb(250, 254, 226, 116));
            ExpBar.SetColor(expFillColor);
            ExpBar.SetFillPercentage(player.Exp.Current, player.Exp.Max);

            var stamfillColor = new SolidColorBrush(Color.FromArgb(250, 77, 212, 255));
            StamBar.SetColor(stamfillColor);
            StamBar.SetFillPercentage(player.Stam.Current, player.Stam.Max);
        }
コード例 #5
0
        protected override void CreateKey(string key)
        {
            var stam = new Stamina(max: 10);

            var exp = new Experience();
            exp.Max = 100;
            exp.Current = 0;

            var player = new Player();
            player.Exp = exp;
            player.Stam = stam;

            IsolatedStorageSettings.ApplicationSettings.Add(PLAYER_KEY, player);
        }
コード例 #6
0
 public void SavePlayer(Player updatedPlayer)
 {
     IsolatedStorageSettings.ApplicationSettings[PLAYER_KEY] = updatedPlayer;
     IsolatedStorageSettings.ApplicationSettings.Save();
 }