Exemplo n.º 1
0
        public Materiatory(DataStore data, XmlNode savegame)
            : this()
        {
            foreach (XmlNode node in savegame.SelectNodes("./materiatory/orb"))
            {
                if (node.NodeType == XmlNodeType.Comment)
                {
                    continue;
                }

                string id = node.Attributes ["id"].Value;
                int ap = Int32.Parse(node.Attributes ["ap"].Value);
                int slot = Int32.Parse(node.Attributes ["slot"].Value);

                _materiatory[slot] = data.GetMateria(id, ap);
            }
        }
Exemplo n.º 2
0
 public Materiatory(DataStore data, XmlNode savegame)
     : this()
 {            
     foreach (XmlNode node in savegame.SelectNodes("./materiatory/orb"))
     {
         if (node.NodeType == XmlNodeType.Comment)
         {
             continue;
         }
                         
         string id = node.Attributes ["id"].Value;
         int ap = Int32.Parse(node.Attributes ["ap"].Value);
         int slot = Int32.Parse(node.Attributes ["slot"].Value);
         
         _materiatory[slot] = data.GetMateria(id, ap);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Loads a saved character.
        /// </summary>
        /// <param name="savexmlstring"></param>
        /// <param name="dataxmlstring"></param>
        public Character(XmlNode savexml, XmlNode dataxml, DataStore data)
            : this()
        {
            _halve  = new List <Element>();
            _void   = new List <Element>();
            _absorb = new List <Element>();
            _immune = new List <Status>();


            Name = savexml.Name;


            // Stats
            _strength_base  = Int32.Parse(savexml.SelectSingleNode("./stats/str").InnerText);
            _dexterity_base = Int32.Parse(savexml.SelectSingleNode("./stats/dex").InnerText);
            _vitality_base  = Int32.Parse(savexml.SelectSingleNode("./stats/vit").InnerText);
            _magic_base     = Int32.Parse(savexml.SelectSingleNode("./stats/mag").InnerText);
            _spirit_base    = Int32.Parse(savexml.SelectSingleNode("./stats/spi").InnerText);
            _luck_base      = Int32.Parse(savexml.SelectSingleNode("./stats/lck").InnerText);
            _level          = Int32.Parse(savexml.SelectSingleNode("./stats/lvl").InnerText);

            // Experience and Level
            _exp      = Int32.Parse(savexml.SelectSingleNode("./exp").InnerText);
            _limitlvl = Int32.Parse(savexml.SelectSingleNode("./limitlvl").InnerText);

            // HP
            _hp    = Int32.Parse(savexml.SelectSingleNode("./hp").InnerText);
            _maxhp = Int32.Parse(savexml.SelectSingleNode("./maxhp").InnerText);
            if (_hp > _maxhp)
            {
                throw new SaveStateException("HP > MAXHP for " + Name);
            }
            //_death = (_hp == 0);

            // MP
            _mp    = Int32.Parse(savexml.SelectSingleNode("./mp").InnerText);
            _maxmp = Int32.Parse(savexml.SelectSingleNode("./maxmp").InnerText);
            if (_mp > _maxmp)
            {
                throw new SaveStateException("MP > MAXMP for " + Name);
            }

            // Fury/Sadness
            Sadness = Boolean.Parse(savexml.SelectSingleNode("./sadness").InnerText);
            Fury    = Boolean.Parse(savexml.SelectSingleNode("./fury").InnerText);
            if (Sadness && Fury)
            {
                throw new SaveStateException("Can't be both sad and furious");
            }

            // Sex
            _sex = (Sex)Enum.Parse(typeof(Sex), dataxml.SelectSingleNode("./sex").InnerText);

            // Back row?
            BackRow = Boolean.Parse(savexml.SelectSingleNode("./backRow").InnerText);

            // Equipment
            _weapon = data.GetWeapon(savexml.SelectSingleNode("./weapon/name").InnerText);

            foreach (XmlNode orb in savexml.SelectNodes("./weapon/materia/orb"))
            {
                string id   = orb.Attributes["id"].Value;
                int    ap   = Int32.Parse(orb.Attributes["ap"].Value);
                int    slot = Int32.Parse(orb.Attributes["slot"].Value);
                if (slot >= _weapon.Slots.Length)
                {
                    throw new SaveStateException("Materia orb assigned to slot that doesnt exist on weapon.");
                }

                _weapon.Slots[slot] = data.GetMateria(id, ap);
            }

            _armor = data.GetArmor(savexml.SelectSingleNode("./armor/name").InnerText);

            foreach (XmlNode orb in savexml.SelectNodes("./armor/materia/orb"))
            {
                string id   = orb.Attributes["id"].Value;
                int    ap   = Int32.Parse(orb.Attributes["ap"].Value);
                int    slot = Int32.Parse(orb.Attributes["slot"].Value);
                if (slot >= _weapon.Slots.Length)
                {
                    throw new SaveStateException("Materia orb assigned to slot that doesnt exist on armor.");
                }

                _armor.Slots[slot] = data.GetMateria(id, ap);
            }

            string acc = savexml.SelectSingleNode("./accessory").InnerText;

            _accessory = String.IsNullOrEmpty(acc) ? null : data.GetAccessory(acc);


            // Q-Values
            _qvals = InitTable(dataxml.SelectSingleNode("./qvals").InnerText);

            // Luck base/gradient tables
            _lck_base     = InitTable(dataxml.SelectSingleNode("./lbvals").InnerText);
            _lck_gradient = InitTable(dataxml.SelectSingleNode("./lgvals").InnerText);

            // HP base/gradient tables
            _hp_base     = InitTable(dataxml.SelectSingleNode("./hpbvals").InnerText);
            _hp_gradient = InitTable(dataxml.SelectSingleNode("./hpgvals").InnerText);

            // MP base/gradient tables
            _mp_base     = InitTable(dataxml.SelectSingleNode("./mpbvals").InnerText);
            _mp_gradient = InitTable(dataxml.SelectSingleNode("./mpgvals").InnerText);

            // Stat ranks
            _stat_ranks = InitTable(dataxml.SelectSingleNode("./ranks").InnerText);


            Profile      = new Gdk.Pixbuf(data.Assembly, "charfull." + Name.ToLower() + ".jpg");
            ProfileSmall = new Gdk.Pixbuf(data.Assembly, "charsmall." + Name.ToLower() + ".jpg");
            ProfileTiny  = new Gdk.Pixbuf(data.Assembly, "chartiny." + Name.ToLower() + ".jpg");


            // Sanity checks. Sometimes we'll load materia onto a save file which
            //    causes the max to drop, but we don't otherwise modify the current
            //    values. So we'll do that here.

            if (_hp > _maxhp)
            {
                _hp = _maxhp;
            }
            else if (_hp <= 0)
            {
                _hp = 0;
                InflictDeath();
            }

            if (_mp > _maxmp)
            {
                _mp = _maxmp;
            }
            else if (_mp < 0)
            {
                _mp = 0;
            }

            CharacterMetrics = data.CharacterMetrics;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Loads a saved character.
        /// </summary>
        /// <param name="savexmlstring"></param>
        /// <param name="dataxmlstring"></param>
        public Character(XmlNode savexml, XmlNode dataxml, DataStore data)
            : this()
        {
            _halve = new List<Element>();
            _void = new List<Element>();
            _absorb = new List<Element>();
            _immune = new List<Status>();

            Name = savexml.Name;

            // Stats
            _strength_base = Int32.Parse(savexml.SelectSingleNode("./stats/str").InnerText);
            _dexterity_base = Int32.Parse(savexml.SelectSingleNode("./stats/dex").InnerText);
            _vitality_base = Int32.Parse(savexml.SelectSingleNode("./stats/vit").InnerText);
            _magic_base = Int32.Parse(savexml.SelectSingleNode("./stats/mag").InnerText);
            _spirit_base = Int32.Parse(savexml.SelectSingleNode("./stats/spi").InnerText);
            _luck_base = Int32.Parse(savexml.SelectSingleNode("./stats/lck").InnerText);
            _level = Int32.Parse(savexml.SelectSingleNode("./stats/lvl").InnerText);

            // Experience and Level
            _exp = Int32.Parse(savexml.SelectSingleNode("./exp").InnerText);
            _limitlvl = Int32.Parse(savexml.SelectSingleNode("./limitlvl").InnerText);

            // HP
            _hp = Int32.Parse(savexml.SelectSingleNode("./hp").InnerText);
            _maxhp = Int32.Parse(savexml.SelectSingleNode("./maxhp").InnerText);
            if (_hp > _maxhp)
            {
                throw new SaveStateException("HP > MAXHP for " + Name);
            }
            //_death = (_hp == 0);

            // MP
            _mp = Int32.Parse(savexml.SelectSingleNode("./mp").InnerText);
            _maxmp = Int32.Parse(savexml.SelectSingleNode("./maxmp").InnerText);
            if (_mp > _maxmp)
            {
                throw new SaveStateException("MP > MAXMP for " + Name);
            }

            // Fury/Sadness
            Sadness = Boolean.Parse(savexml.SelectSingleNode("./sadness").InnerText);
            Fury = Boolean.Parse(savexml.SelectSingleNode("./fury").InnerText);
            if (Sadness && Fury)
            {
                throw new SaveStateException("Can't be both sad and furious");
            }

            // Sex
            _sex = (Sex)Enum.Parse(typeof(Sex), dataxml.SelectSingleNode("./sex").InnerText);

            // Back row?
            BackRow = Boolean.Parse(savexml.SelectSingleNode("./backRow").InnerText);

            // Equipment
            _weapon = data.GetWeapon(savexml.SelectSingleNode("./weapon/name").InnerText);

            foreach (XmlNode orb in savexml.SelectNodes("./weapon/materia/orb"))
            {
                string id = orb.Attributes["id"].Value;
                int ap = Int32.Parse(orb.Attributes["ap"].Value);
                int slot = Int32.Parse(orb.Attributes["slot"].Value);
                if (slot >= _weapon.Slots.Length)
                {
                    throw new SaveStateException("Materia orb assigned to slot that doesnt exist on weapon.");
                }

                _weapon.Slots[slot] = data.GetMateria(id, ap);
            }

            _armor = data.GetArmor(savexml.SelectSingleNode("./armor/name").InnerText);

            foreach (XmlNode orb in savexml.SelectNodes("./armor/materia/orb"))
            {
                string id = orb.Attributes["id"].Value;
                int ap = Int32.Parse(orb.Attributes["ap"].Value);
                int slot = Int32.Parse(orb.Attributes["slot"].Value);
                if (slot >= _weapon.Slots.Length)
                {
                    throw new SaveStateException("Materia orb assigned to slot that doesnt exist on armor.");
                }

                _armor.Slots[slot] = data.GetMateria(id, ap);
            }

            string acc = savexml.SelectSingleNode("./accessory").InnerText;
            _accessory = String.IsNullOrEmpty(acc) ? null : data.GetAccessory(acc);

            // Q-Values
            _qvals = InitTable(dataxml.SelectSingleNode("./qvals").InnerText);

            // Luck base/gradient tables
            _lck_base = InitTable(dataxml.SelectSingleNode("./lbvals").InnerText);
            _lck_gradient = InitTable(dataxml.SelectSingleNode("./lgvals").InnerText);

            // HP base/gradient tables
            _hp_base = InitTable(dataxml.SelectSingleNode("./hpbvals").InnerText);
            _hp_gradient = InitTable(dataxml.SelectSingleNode("./hpgvals").InnerText);

            // MP base/gradient tables
            _mp_base = InitTable(dataxml.SelectSingleNode("./mpbvals").InnerText);
            _mp_gradient = InitTable(dataxml.SelectSingleNode("./mpgvals").InnerText);

            // Stat ranks
            _stat_ranks = InitTable(dataxml.SelectSingleNode("./ranks").InnerText);

            Profile = new Gdk.Pixbuf(data.Assembly, "charfull." + Name.ToLower() + ".jpg");
            ProfileSmall = new Gdk.Pixbuf(data.Assembly, "charsmall." + Name.ToLower() + ".jpg");
            ProfileTiny = new Gdk.Pixbuf(data.Assembly, "chartiny." + Name.ToLower() + ".jpg");

            // Sanity checks. Sometimes we'll load materia onto a save file which
            //    causes the max to drop, but we don't otherwise modify the current
            //    values. So we'll do that here.

            if (_hp > _maxhp)
            {
                _hp = _maxhp;
            }
            else if (_hp <= 0)
            {
                _hp = 0;
                InflictDeath();
            }

            if (_mp > _maxmp)
            {
                _mp = _maxmp;
            }
            else if (_mp < 0)
            {
                _mp = 0;
            }

            CharacterMetrics = data.CharacterMetrics;
        }