Exemplo n.º 1
0
 public SpellBook(SpellBookConfiguration configuration)
     : base(configuration)
 {
     BookSize       = configuration.Size;
     Spells         = new BookSpell[BookSize];
     inventoryImage = configuration.InventoryImage;
     worldImage     = configuration.WorldImage;
 }
Exemplo n.º 2
0
        public void Run(BookSpell spellToEdit, Action <bool, BookSpell> callbackOnExit)
        {
            view.SpellName = spellToEdit.Name;
            view.ManaCost  = spellToEdit.ManaCost;
            callback       = callbackOnExit;

            spellFilePath = editSpellService.PrepareSpellTemplate(spellToEdit.Code);

            view.Show();
        }
Exemplo n.º 3
0
        private string GetName(BookSpell spell)
        {
            if (spellNamesCache.ContainsKey(spell))
            {
                return(spellNamesCache[spell]);
            }

            var name = GenerateName();

            spellNamesCache.Add(spell, name);
            return(name);
        }
Exemplo n.º 4
0
        public SpellBook(SaveData data) : base(data)
        {
            BookSize = data.GetIntValue(SaveKeySize);
            var spellsRaw = data.GetObjectsCollection <BookSpell>(SaveKeySpells);

            Spells = new BookSpell[BookSize];
            for (int index = 0; index < spellsRaw.Length; index++)
            {
                Spells[index] = spellsRaw[index];
            }

            inventoryImage = data.GetObject <SymbolsImageSaveable>(SaveKeyInventoryImage).GetImage();
            worldImage     = data.GetObject <SymbolsImageSaveable>(SaveKeyWorldImage).GetImage();
        }
Exemplo n.º 5
0
        private void View_Ok(object sender, EventArgs e)
        {
            view.Close();

            var code  = editSpellService.ReadSpellCodeFromFile(spellFilePath);
            var spell = new BookSpell
            {
                Name     = view.SpellName,
                ManaCost = view.ManaCost,
                Code     = code
            };

            callback(true, spell);
        }
Exemplo n.º 6
0
        public void RemoveSpell(BookSpell spell)
        {
            var serializer = new XmlSerializer(typeof(XmlSpellsLibrary));
            var library    = LoadSpellsLibrary(serializer);

            var spellToRemove = library?.Spells.FirstOrDefault(xmlSpell => xmlSpell.Equals(spell));

            if (spellToRemove == null)
            {
                return;
            }

            library.Spells = library.Spells.Where(xmlSpell => !ReferenceEquals(xmlSpell, spellToRemove)).ToArray();
            WriteToXml(library, serializer);
        }
Exemplo n.º 7
0
        public void SaveSpell(BookSpell spell)
        {
            var serializer = new XmlSerializer(typeof(XmlSpellsLibrary));
            var library    = LoadSpellsLibrary(serializer);

            if (library == null)
            {
                library = new XmlSpellsLibrary();
                var path = Path.GetDirectoryName(FilePath);
                if (!string.IsNullOrEmpty(path))
                {
                    Directory.CreateDirectory(path);
                }
            }

            var resultSpells = new List <XmlBookSpell>(library.Spells ?? new XmlBookSpell[0])
            {
                new XmlBookSpell(spell)
            };

            library.Spells = resultSpells.ToArray();

            WriteToXml(library, serializer);
        }
Exemplo n.º 8
0
 public SpellListBoxItem(BookSpell spell, int bookIndex)
 {
     Spell     = spell;
     BookIndex = bookIndex;
 }
Exemplo n.º 9
0
 public bool Equals(BookSpell spell)
 {
     return(string.Equals(Name, spell.Name) && string.Equals(Code, spell.Code));
 }
Exemplo n.º 10
0
 public XmlBookSpell(BookSpell spell)
 {
     Name     = spell.Name;
     Code     = spell.Code;
     ManaCost = spell.ManaCost;
 }
Exemplo n.º 11
0
 public CastSpellPlayerAction(BookSpell spell)
 {
     this.spell = spell;
 }