private void InitHero() { SaveHero sh = (SaveHero)Functions.Deserialize(Path.Make(Path.Save, Globals.HeroFile)); Hero h = sh.ToHero(); Globals.Players.Add(h); }
public MenuCharacter(string fileName) { Immovable = true; zFileName = fileName; SaveHero shero = (SaveHero)Functions.Deserialize(fileName); zHeroName = shero.Name; Text = $"{shero.Name}\nLvl{shero.Level.ToString()}"; zText.RelativePosition.Y += 3; zText.RelativePosition.X += 0.5f; zText.HorizontalAlignment = HorizontalAlignment.Center; var s1 = SetSprite(shero); SpriteManager.RemoveSprite(s1); zSprite.Texture = s1.Texture; zSprite.LeftTextureCoordinate = 0.333f; zSprite.RightTextureCoordinate = 0.667f; zSprite.ColorOperation = ColorOperation.Texture; Size = new Vector2(8, 8); OnClick = delegate() { MainMenu m = (MainMenu)ScreenManager.CurrentScreen; m.SelectCharacter(this); }; }
private void CreateNewCharacter() { if (!IsNameValid()) { string msg = "Invalid name\n*letter, number and spaces only\n*cannot begin or end with space\n*no 2 spaces in a row\n*min 3 characters"; new MessageBox(msg); return; } if (zHeroClass == HeroClass.Invalid) { new MessageBox("Select class"); return; } string fileName = Path.Make(Path.Save, zNametextbox.Text); fileName = fileName.Replace(" ", "_"); fileName += ".hero"; if (System.IO.File.Exists(Path.Make(Path.Save, fileName))) { new MessageBox("This name is taken"); return; } Hero hero = new Hero(zNametextbox.Text, zHeroClass); SaveHero shero = hero.ToSavehero(); Functions.Serialize(fileName, shero); hero.Destroy(); MainMenu m = (MainMenu)ScreenManager.CurrentScreen; m.ReloadCharacterList(); Destroy(); }
private Sprite SetSprite(SaveHero shero) { switch (shero.Class) { case HeroClass.Elf: return Functions.AddSpriteFromAchx(Path.Make(Path.Hero, "elf.achx")); case HeroClass.Knight: return Functions.AddSpriteFromAchx(Path.Make(Path.Hero, "knight.achx")); case HeroClass.Wizard: return Functions.AddSpriteFromAchx(Path.Make(Path.Hero, "wizard.achx")); default: return null; } }
private Sprite SetSprite(SaveHero shero) { switch (shero.Class) { case HeroClass.Elf: return(Functions.AddSpriteFromAchx(Path.Make(Path.Hero, "elf.achx"))); case HeroClass.Knight: return(Functions.AddSpriteFromAchx(Path.Make(Path.Hero, "knight.achx"))); case HeroClass.Wizard: return(Functions.AddSpriteFromAchx(Path.Make(Path.Hero, "wizard.achx"))); default: return(null); } }
public SaveHero ToSavehero() { SaveHero shero = new SaveHero(); shero.Class = Class; shero.Name = Name; shero.Str = Str; shero.Vit = Vit; shero.Agi = Agi; shero.Ene = Ene; shero.Level = Level; shero.Exp = Exp; shero.ExpNext = ExpNext; shero.ExpPrevious = ExpPrevious; shero.StatPoints = StatPoints; shero.Gold = Gold; shero.Map = Map; shero.Online = Online; shero.ExperienceBoost = ExperienceBoost; return(shero); }
public SaveHero ToSavehero() { SaveHero shero = new SaveHero(); shero.Class = Class; shero.Name = Name; shero.Str = Str; shero.Vit = Vit; shero.Agi = Agi; shero.Ene = Ene; shero.Level = Level; shero.Exp = Exp; shero.ExpNext = ExpNext; shero.ExpPrevious = ExpPrevious; shero.StatPoints = StatPoints; shero.Gold = Gold; shero.Map = Map; shero.Online = Online; shero.ExperienceBoost = ExperienceBoost; return shero; }