public void LoadToGameWorld(GameWorld gameWorld) { var player = new Player { BaseStats = Stats, Class = Game.Class.FromName(Class), Level = Level, Gold = Gold, Experience = Experience, Name = CharacterName, Race = Game.Race.FromName(Race), Weapon = Weapon }; player.CurrentHitPoints = player.MaxHitPoints; player.CurrentEnergy = player.MaxEnergy; gameWorld.Player = player; gameWorld.SaveGameId = Id; gameWorld.CurrentDungeonLevel = CurrentDungeonLevel; gameWorld.TotalNumberOfMonstersDefeated = TotalNumberOfMonstersDefeated; gameWorld.Player.ClearInventory(); if (Inventory != null) { foreach (var item in Inventory) { gameWorld.Player.AddItemToInventory(item); } } gameWorld.Player.ClearSpellBook(); if (SpellBook != null) { foreach (var spell in SpellBook) { gameWorld.Player.AddSpellToSpellBook(spell); } } gameWorld.BossesDefeated.Clear(); if (BossesDefeated != null) { foreach (var boss in BossesDefeated) { gameWorld.BossesDefeated.Add(boss); } } }
public static StatsViewModel FromPlayer(Player player) { return new StatsViewModel { Name = player.Name, Level = string.Format("Level {0}", player.Level), Gold = string.Format("Gold {0}", player.Gold), Strength = string.Format("STR {0}", player.Strength), Endurance = string.Format("END {0}", player.Endurance), Dexterity = string.Format("DEX {0}", player.Dexterity), Agility = string.Format("AGI {0}", player.Agility), Intelligence = string.Format("INT {0}", player.Intelligence), Wisdom = string.Format("WIS {0}", player.Wisdom), Luck = string.Format("LUC {0}", player.Luck), HitPoints = string.Format("HP : {0} / {1}", player.CurrentHitPoints, player.MaxHitPoints), HitPointsMeter = GetMeter(player.CurrentHitPoints, player.MaxHitPoints), Energy = string.Format("EN : {0} / {1}", player.CurrentEnergy, player.MaxEnergy), EnergyMeter = GetMeter(player.CurrentEnergy, player.MaxEnergy), Experience = string.Format("XP : {0}", player.Experience), ExperienceMeter = GetMeter(player.ProgressTowardsNextLevel()), Weapon = string.Format("W: {0}", player.Weapon.GetLeveledName()) }; }