public void RemoveHeroFromPlayerCollection(Hero heroToRemove)
 {
     var heroes = GetHeroesOwnedByPlayer();
     heroes = heroes.Where(h => h.Id != heroToRemove.Id).ToList();
     IsolatedStorageSettings.ApplicationSettings[HEROES_KEY] = heroes;
     IsolatedStorageSettings.ApplicationSettings.Save();
 }
 public void AddHeroToPlayerCollection(Hero heroToAdd)
 {
     var heroes = GetHeroesOwnedByPlayer();
     heroes.Add(heroToAdd);
     IsolatedStorageSettings.ApplicationSettings[HEROES_KEY] = heroes;
     IsolatedStorageSettings.ApplicationSettings.Save();
 }
 private Grid PopulateTopRow(int row, Grid grid, Hero heroCastingSpell)
 {
     var heroImage = ImageUtils.GetImageFromPath(heroCastingSpell.FullImagePath);
        grid.Children.Add(heroImage);
        heroImage.SetValue(Grid.RowProperty, row);
        heroImage.Stretch = Stretch.Fill;
        return grid;
 }
        public ExperienceToNextHeroLevel(Hero hero, double expGained)
        {
            _levelCalculator = new HeroLevelCalculator();
            InitializeComponent();

            DrawConditionalElements(hero, expGained);
            DrawHeroProfile(hero);
        }
        public DeleteHeroConfirmation(Hero heroToDelete)
        {
            InitializeComponent();
            _heroToDelete = heroToDelete;

            HeroImage.Source = ImageUtils.GetImageSourceFromPath("/" + _heroToDelete.FullImagePath);
            HeroName.Text = _heroToDelete.Name;
            HeroLevel.Text = "Current Level " + heroToDelete.Level;
        }
 private Grid CreateContent(double width, double height, Hero heroCastingSpell)
 {
     var grid = InitGrid(2);
     grid = StyleGrid(grid);
     grid = PopulateTopRow(0, grid, heroCastingSpell);
     grid = PopulateBottomRow(1, grid);
     grid = SizeGrid(width, height, grid); //must come last
     return grid;
 }
        public CastSpellModal(Hero heroCastingSpell)
        {
            _modal = new Popup();

            var popupWidth = Application.Current.Host.Content.ActualWidth * .8;
            var popupHeight = Application.Current.Host.Content.ActualHeight * .75;
            _modalContent = CreateContent(popupWidth, popupHeight, heroCastingSpell);
            _modal.Child = _modalContent;
        }
 private void DrawHeroProfile(Hero hero)
 {
     //TODO: we always use 5 so it can be internal to this method.
     var profileSize = ViewCalculations.GetHeroProfileSizeGiveNColumns(5);
     var heroViewModel = HeroToViewModelMapper.GetHeroViewModel(hero);
     Profile.Draw(heroViewModel);
     Profile.Height = profileSize.Height;
     Profile.Width = profileSize.Width;
 }
        private static HeroViewModel PopulateValuesOnHeroVM(Hero hero)
        {
            var heroVM = new HeroViewModel();
            heroVM.ProfileImageSource = "/" + hero.ProfileImagePath;
            heroVM.OrbImageSource = "/" + ImageUtils.GetOrbImagePathFromType(hero.Type);
            heroVM.BorderImageSource = "/" + ImageUtils.GetProfileBorderImagePathFromType(hero.Type);
            heroVM.Id = hero.Id.ToString();

            return heroVM;
        }
示例#10
0
 private static Hero CopyHero(Hero heroToCopy)
 {
     return new Hero(heroToCopy.Name,
                     heroToCopy.HitPoints,
                     heroToCopy.HealsFor,
                     heroToCopy.AttackDamage,
                     heroToCopy.Type,
                     heroToCopy.BaseExpPerLevel,
                     heroToCopy.MaxLevel);
 }
        public static HeroViewModel[] GetHeroViewModels(Hero[] heroes)
        {
            var heroViewModels = new HeroViewModel[heroes.Length];

            for (int i = 0; i < heroViewModels.Length; i++)
            {
                heroViewModels[i] = GetHeroViewModel(heroes[i]);
            }

            return heroViewModels;
        }
        private static List<HeroViewModel> FillEmptySlots(int extraSlotsToAdd)
        {
            var emptyHeroVMs = new List<HeroViewModel>();
            if (extraSlotsToAdd > 0)
            {
                var emptySlots = new Hero[extraSlotsToAdd];
                emptyHeroVMs = HeroToViewModelMapper.GetHeroViewModels(emptySlots).ToList();
            }

            return emptyHeroVMs;
        }
        public static HeroViewModel GetHeroViewModel(Hero hero)
        {
            var heroVM = new HeroViewModel();

            if (hero != null)
            {
                heroVM = PopulateValuesOnHeroVM(hero);
            }

            return heroVM;
        }
 private void DrawScreen(Hero hero)
 {
     FullHeroImage.Source = ImageUtils.GetImageSourceFromPath("/" + hero.FullImagePath);
     LevelCurrentAndMax.Text = "Level " + hero.Level + " of " + hero.MaxLevel;
     Heal.Text = "Heals for " + hero.HealsFor.ToString();
     HP.Text = "Hit points " + hero.HitPoints.ToString();
     Attack.Text = "Attacks for " + hero.AttackDamage.ToString();
     HeroName.Text = hero.Name;
     Border.ImageSource = ImageUtils.GetImageSourceFromPath(ImageUtils.GetProfileBorderImagePathFromType(hero.Type));
     OrbImage.Source = ImageUtils.GetImageSourceFromPath("/" + ImageUtils.GetOrbImagePathFromType(hero.Type));
 }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            string heroId = "";
            if (NavigationContext.QueryString.TryGetValue("playerOwnedHeroId", out heroId))
            {
                var heroGuid = new Guid(heroId);
                ThisHero = _heroRepository.GetHeroesOwnedByPlayer().Single(h => h.Id == heroGuid);
                DrawScreen(ThisHero);
            }
        }
        private void DrawExpBar(Hero hero, double expGained)
        {
            ExpBar.Visibility = Visibility.Visible;
            var expFillColor = new SolidColorBrush(Color.FromArgb(250, 254, 226, 116));
            ExpBar.SetColor(expFillColor);

            var expNeededForThisLevel = GetExpNeeded(hero.Level, hero.BaseExpPerLevel);
            var expNeededForNextLevel = GetExpNeeded(hero.Level + 1, hero.BaseExpPerLevel);
            var expOverThisLevel = Convert.ToInt32(hero.CurrentExp - expNeededForThisLevel);
            var expFormThisLevelToNext = expNeededForNextLevel - expNeededForThisLevel;

            ExpBar.SetFillPercentage(expOverThisLevel, expFormThisLevelToNext);
        }
示例#17
0
        private static int CalculateHeroDamage(Hero hero, List<OrbMatch> matches)
        {
            double heroDamage = 0;

            var typeMatches = matches.Where(m => m.Type == hero.Type).ToList();
            foreach (var match in typeMatches)
            {
                heroDamage += CalculateMatchDamage(hero.AttackDamage, match);
            }

            var extraMatches = matches.Count - typeMatches.Count;
            heroDamage *= (MATCH_MULTIPLIER * extraMatches) + 1;

            return Convert.ToInt32(heroDamage);
        }
 private void DrawConditionalElements(Hero hero, double expGained)
 {
     IsMaxLevel = hero.Level == hero.MaxLevel;
     if (IsMaxLevel)
     {
         MaxLevelReached.Text = "Max level of " + hero.MaxLevel + " reached";
         MaxLevelReached.Visibility = Visibility.Visible;
     }
     else
     {
         var nextLevel = hero.Level + 1;
         ExpToNextLevel.Text = "Experience until level " + nextLevel;
         ExpToNextLevel.Visibility = Visibility.Visible;
         DrawExpBar(hero, expGained);
     }
 }
 private void DrawProfile(Hero hero)
 {
     ProfilePicture.Source = ImageUtils.GetImageSourceFromPath("/" + hero.ProfileImagePath);
     BorderImage.ImageSource = GetBorderImageSource(hero.Type);
     PrimaryTypeImage.Source = GetOrbImageFromType(hero.Type);
 }
示例#20
0
 public TeamMember(int slot, Hero hero)
 {
     Slot = slot;
     ThisHero = hero;
 }
 public void DrawHeroProfile(Hero hero)
 {
     ThisHero = hero;
     DrawProfile(ThisHero);
 }