Example #1
0
        public BattleState()
        {
            _clock = new ScaledClock(Globals.BattleSpeed);

            _allies = new Ally[3];

            if (Globals.Party[0] != null) _allies[0] = new Ally(Globals.Party[0], 550, 100, 2000);
            if (Globals.Party[1] != null) _allies[1] = new Ally(Globals.Party[1], 580, 200, 2500);
            if (Globals.Party[2] != null) _allies[2] = new Ally(Globals.Party[2], 610, 300, 2300);

            if (_allies[0] == null && _allies[1] == null && _allies[2] == null)
                throw new GamedataException("Must have at least one ally in battle.");

            int numberOfEnemies = 1;//Game.Random.Next(1, 3);
            //_enemies = new List<Enemy>(numberOfEnemies);
            //for (int i = 0; i < numberOfEnemies; i++)
            //    _enemies.Add(Enemy.GetRandomEnemy(Game.Random.Next(100, 250), Game.Random.Next(100, 300)));

            _enemies = new List<Enemy>();
            _enemies.Add(new Enemy("mothslasher"));

            _turnQueue = new Queue<Ally>();

            _abilityQueue = new Queue<AbilityState>();

            _abilityMutex = new Mutex();

            _gainedItems = new List<IItem>();
        }
Example #2
0
        public Ally(Character c, int x, int y, int e)
        {
            _c = c;

            _abilityState = new AbilityState();

            int vStep = Globals.BattleSpeed;

            _c_timer   = new ScaledClock(10000);
            _v_timer   = new ScaledClock(vStep);
            _turnTimer = new ScaledTimer(6000, e, Globals.TurnTimerSpeed(this, vStep));

            _x = x;
            _y = y;

            GetMagicSpells();
            GetSummons();

            _battleMenu = new BattleMenu(this);

            _magicMenu = new MagicMenu(MagicSpells, _battleMenu.WMagic);
            if (!_magicMenu.IsValid)
            {
                _magicMenu = null;
            }

            _summonMenu = new SummonMenu(Summons, _battleMenu.WSummon);
            if (!_summonMenu.IsValid)
            {
                _summonMenu = null;
            }

            EnemySkillMateria m = new EnemySkillMateria(GetEnemySkillMask());

            if (m.AP > 0)
            {
                _enemySkillMenu = new EnemySkillMenu(m);
            }

            if (HP == 0)
            {
                InflictDeath();
            }
        }
Example #3
0
        public BattleState()
        {
            _clock = new ScaledClock(Globals.BattleSpeed);


            _allies = new Ally[3];

            if (Globals.Party[0] != null)
            {
                _allies[0] = new Ally(Globals.Party[0], 550, 100, 2000);
            }
            if (Globals.Party[1] != null)
            {
                _allies[1] = new Ally(Globals.Party[1], 580, 200, 2500);
            }
            if (Globals.Party[2] != null)
            {
                _allies[2] = new Ally(Globals.Party[2], 610, 300, 2300);
            }

            if (_allies[0] == null && _allies[1] == null && _allies[2] == null)
            {
                throw new GamedataException("Must have at least one ally in battle.");
            }


            int numberOfEnemies = 1;//Game.Random.Next(1, 3);

            //_enemies = new List<Enemy>(numberOfEnemies);
            //for (int i = 0; i < numberOfEnemies; i++)
            //    _enemies.Add(Enemy.GetRandomEnemy(Game.Random.Next(100, 250), Game.Random.Next(100, 300)));

            _enemies = new List <Enemy>();
            _enemies.Add(new Enemy("mothslasher"));

            _turnQueue = new Queue <Ally>();

            _abilityQueue = new Queue <AbilityState>();

            _abilityMutex = new Mutex();

            _gainedItems = new List <IItem>();
        }
Example #4
0
        public Enemy(string xmlstring, int x, int y)
        {
            _xml = xmlstring;

            _weak = new List<Element>();
            _halve = new List<Element>();
            _void = new List<Element>();
            _absorb = new List<Element>();
            _immune = new List<Status>();

            _win = new List<EnemyItem>();
            _steal = new List<EnemyItem>();

            _abilityState = new AbilityState();

            XmlDocument xml = new XmlDocument();
            xml.Load(new MemoryStream(Encoding.UTF8.GetBytes(xmlstring)));

            _name = xml.SelectSingleNode("//name").InnerText;
            _attack = Int32.Parse(xml.SelectSingleNode("//atk").InnerText);
            _defense = Int32.Parse(xml.SelectSingleNode("//def").InnerText);
            _defensePercent = Int32.Parse(xml.SelectSingleNode("//defp").InnerText);
            _dexterity = Int32.Parse(xml.SelectSingleNode("//dex").InnerText);
            _magicAttack = Int32.Parse(xml.SelectSingleNode("//mat").InnerText);
            _magicDefense = Int32.Parse(xml.SelectSingleNode("//mdf").InnerText);
            _luck = Int32.Parse(xml.SelectSingleNode("//lck").InnerText);

            _level = Int32.Parse(xml.SelectSingleNode("//lvl").InnerText);
            _maxhp = _hp = Int32.Parse(xml.SelectSingleNode("//hp").InnerText);
            _maxmp = _mp = Int32.Parse(xml.SelectSingleNode("//mp").InnerText);

            _exp = Int32.Parse(xml.SelectSingleNode("//exp").InnerText);
            _ap = Int32.Parse(xml.SelectSingleNode("//ap").InnerText);
            _gil = Int32.Parse(xml.SelectSingleNode("//gil").InnerText);

            foreach (XmlNode weak in xml.SelectSingleNode("//weaks").ChildNodes)
                _weak.Add((Element)Enum.Parse(typeof(Element), weak.InnerText));
            foreach (XmlNode halve in xml.SelectSingleNode("//halves").ChildNodes)
                _halve.Add((Element)Enum.Parse(typeof(Element), halve.InnerText));
            foreach (XmlNode v in xml.SelectSingleNode("//voids").ChildNodes)
                _void.Add((Element)Enum.Parse(typeof(Element), v.InnerText));
            foreach (XmlNode absorb in xml.SelectSingleNode("//absorbs").ChildNodes)
                _absorb.Add((Element)Enum.Parse(typeof(Element), absorb.InnerText));
            foreach (XmlNode immunity in xml.SelectSingleNode("//immunities").ChildNodes)
                _immune.Add((Status)Enum.Parse(typeof(Status), immunity.InnerText));

            foreach (XmlNode win in xml.SelectSingleNode("//win").ChildNodes)
                _win.Add(new EnemyItem(win.OuterXml));
            foreach (XmlNode steal in xml.SelectSingleNode("//steal").ChildNodes)
                _steal.Add(new EnemyItem(steal.OuterXml));
            foreach (XmlNode morph in xml.SelectSingleNode("//morph").ChildNodes)
                if (morph.Attributes["id"] != null)
                {
                    string id = morph.Attributes["id"].Value;
                    string type = morph.Attributes["type"].Value;

                    _morph = Atmosphere.BattleSimulator.Item.GetItem(id, type);
                }

            int vStep = Globals.BattleSpeed;

            _c_timer = new ScaledClock(vStep);
            _v_timer = new ScaledClock(vStep);
            _turnTimer = new ScaledTimer(6000, _dexterity * vStep / Globals.NormalSpeed());

            _ai = new Thread(new ThreadStart(AI));

            _x = x;
            _y = y;
        }
Example #5
0
        public Enemy(string xmlstring, int x, int y)
        {
            _xml = xmlstring;

            _weak   = new List <Element>();
            _halve  = new List <Element>();
            _void   = new List <Element>();
            _absorb = new List <Element>();
            _immune = new List <Status>();

            _win   = new List <EnemyItem>();
            _steal = new List <EnemyItem>();

            _abilityState = new AbilityState();

            XmlDocument xml = new XmlDocument();

            xml.Load(new MemoryStream(Encoding.UTF8.GetBytes(xmlstring)));

            _name           = xml.SelectSingleNode("//name").InnerText;
            _attack         = Int32.Parse(xml.SelectSingleNode("//atk").InnerText);
            _defense        = Int32.Parse(xml.SelectSingleNode("//def").InnerText);
            _defensePercent = Int32.Parse(xml.SelectSingleNode("//defp").InnerText);
            _dexterity      = Int32.Parse(xml.SelectSingleNode("//dex").InnerText);
            _magicAttack    = Int32.Parse(xml.SelectSingleNode("//mat").InnerText);
            _magicDefense   = Int32.Parse(xml.SelectSingleNode("//mdf").InnerText);
            _luck           = Int32.Parse(xml.SelectSingleNode("//lck").InnerText);

            _level = Int32.Parse(xml.SelectSingleNode("//lvl").InnerText);
            _maxhp = _hp = Int32.Parse(xml.SelectSingleNode("//hp").InnerText);
            _maxmp = _mp = Int32.Parse(xml.SelectSingleNode("//mp").InnerText);

            _exp = Int32.Parse(xml.SelectSingleNode("//exp").InnerText);
            _ap  = Int32.Parse(xml.SelectSingleNode("//ap").InnerText);
            _gil = Int32.Parse(xml.SelectSingleNode("//gil").InnerText);


            foreach (XmlNode weak in xml.SelectSingleNode("//weaks").ChildNodes)
            {
                _weak.Add((Element)Enum.Parse(typeof(Element), weak.InnerText));
            }
            foreach (XmlNode halve in xml.SelectSingleNode("//halves").ChildNodes)
            {
                _halve.Add((Element)Enum.Parse(typeof(Element), halve.InnerText));
            }
            foreach (XmlNode v in xml.SelectSingleNode("//voids").ChildNodes)
            {
                _void.Add((Element)Enum.Parse(typeof(Element), v.InnerText));
            }
            foreach (XmlNode absorb in xml.SelectSingleNode("//absorbs").ChildNodes)
            {
                _absorb.Add((Element)Enum.Parse(typeof(Element), absorb.InnerText));
            }
            foreach (XmlNode immunity in xml.SelectSingleNode("//immunities").ChildNodes)
            {
                _immune.Add((Status)Enum.Parse(typeof(Status), immunity.InnerText));
            }

            foreach (XmlNode win in xml.SelectSingleNode("//win").ChildNodes)
            {
                _win.Add(new EnemyItem(win.OuterXml));
            }
            foreach (XmlNode steal in xml.SelectSingleNode("//steal").ChildNodes)
            {
                _steal.Add(new EnemyItem(steal.OuterXml));
            }
            foreach (XmlNode morph in xml.SelectSingleNode("//morph").ChildNodes)
            {
                if (morph.Attributes["id"] != null)
                {
                    string id   = morph.Attributes["id"].Value;
                    string type = morph.Attributes["type"].Value;

                    _morph = Atmosphere.BattleSimulator.Item.GetItem(id, type);
                }
            }


            int vStep = Globals.BattleSpeed;

            _c_timer   = new ScaledClock(vStep);
            _v_timer   = new ScaledClock(vStep);
            _turnTimer = new ScaledTimer(6000, _dexterity * vStep / Globals.NormalSpeed());

            _ai = new Thread(new ThreadStart(AI));

            _x = x;
            _y = y;
        }