Example #1
0
 public Monster(int[] stats, int[] resists, MonsterFight mf, Classess monClass, int baseM, int basePh, string desc, char vis, ConsoleColor color)
 {
     _isPassable = false;
     _type = ObjectType.O_MONSTER;
     _monsterBehaviur = MonsterState.MS_IDLE;
     _pathAvaible = false;
     _route = new List<Point>();
     _movement = new List<Point>();
     _seen = false;
     _description = desc;
     _visual = vis;
     _color = color;
     _class = monClass;
     _primaryStats = new Dictionary<PrimaryStats, Stat>();
     _resists = new Dictionary<Resists, Stat>();
     _BaseResists = new Dictionary<ResistGroup, Stat>();
     _monsterWeapons = mf.ListOfWeapons;
     _monsterArmor = mf.monsterArmor;
     _weaponProficiencies = new int[mf.ListOfWeapons.GetLength(0)];
     _states = new bool[(int)PlayerStates.MAX_SIZE];
     changeState(PlayerStates.NORMAL);
     for (PrimaryStats i = PrimaryStats.VITALITY; i < PrimaryStats.MAX_SIZE; i++)
     {
         _primaryStats.Add(i, new Stat(stats[(int)i]));
     }
     for (Resists i = Resists.RESIST_1; i < Resists.MAX_SIZE; i++)
     {
         _resists.Add(i, new Stat(resists[(int)i]));
     }
     _BaseResists.Add(ResistGroup.MENTAL, new Stat(baseM));
     _BaseResists.Add(ResistGroup.PHYSICAL, new Stat(basePh));
     Level = 0;
     _Stamina = new Stat(_primaryStats[PrimaryStats.VITALITY].currentValue / 10 + _primaryStats[PrimaryStats.STRENGTH].currentValue / 10);
     //recalculate dex and spd based on armor limitation
     _primaryStats[PrimaryStats.DEXTERITY].actualValue /= _monsterArmor.Limitation[0];
     _primaryStats[PrimaryStats.SPEED].actualValue /= _monsterArmor.Limitation[1];
     //calculate defence without weapon
     _defence = new Stat(_monsterArmor.Defence + Convert.ToInt16(Math.Round((_primaryStats[PrimaryStats.DEXTERITY].actualValue / 10.0f))));
     _protection = new int[3];
     _protection[0] = _monsterArmor.Protection[0];
     _protection[1] = _monsterArmor.Protection[1];
     _protection[2] = _monsterArmor.Protection[2];
     //genereate weapon proficiency for all weapons
     for (int i = 0; i < _monsterWeapons.GetLength(0); i++)
     {
         int bonus = _monsterWeapons[i].ProfBonus;
         int prof = bonus + Data.PlayerClass.ClassProficiencyTable[_class][1] + Dice.Roll("d50");
         _weaponProficiencies[i] = prof;
     }
     _steps = 0;
     _exp = MonsterGenerator.CalcualteMonsterExp(this);
     //calcualte magic potential for future casters
     _MagicPotential = new Stat(0);
     CalculateMagicPotential();
 }
        private static void readFile(string name)
        {
            int count = 0;
            int size;
            bool readStats = false;
            bool readResists = false;
            bool readClasses = false;
            bool readGlyph = false;
            bool readDesc = false;
            string line;
            string[] classes = null;
            string[] glyph = null;
            string weaponData = "";
            List<string> weaponsData = new List<string>();
            string armorData = "";
            StreamReader file = new StreamReader("Data\\Monsters\\" + name + ".txt");

            while ((line = file.ReadLine()) != null)
            {
                if (line == "//STATS")
                {
                    readStats = true;
                    count = 0;
                    continue;
                }
                if (line == "//RESISTS")
                {
                    readStats = false;
                    readResists = true;
                    count = 0;
                    continue;
                }
                if (line == "//CLASSES")
                {   
                    readResists = false;
                    readClasses = true;
                    continue;
                }
                if (line == "//GLYPH")
                {
                    readClasses = false;
                    readGlyph = true;
                }
                if (line == "//DESCRIPTION")
                {
                    readGlyph = false;
                    readDesc = true;
                }
                if (line == "//WEAPONS")
                {
                    readDesc = false;
                    //read all weapons
                    while ((line = file.ReadLine()) != "//ARMOR")
                    {   
                        if (line == "{")
                        {
                            //read all weapon's data
                            while ((line = file.ReadLine()) != "}")
                            {
                                int pos = line.IndexOf(',');
                                weaponData += line.Substring(pos + 1) + "\n";
                            }
                            weaponsData.Add(weaponData);
                        }
                        weaponData = "";
                    }
                }
                if (line == "//ARMOR")
                {
                    while ((line = file.ReadLine()) != "//OTHER STATS NOT IMPLEMENTED YET")
                    {
                        if (line == "{")
                        {
                            //read all weapon's data
                            while ((line = file.ReadLine()) != "}")
                            {
                                int pos = line.IndexOf(',');
                                armorData += line.Substring(pos + 1) + "\n";
                            }
                        }
                    }
                }
                if (line == "//OTHER STATS NOT IMPLEMENTED YET")
                {
                    break;
                }
                if (readStats)
                {
                    _stats[count] = line;
                }
                if (readResists)
                {
                    _resists[count] = line;
                }
                if (readClasses)
                {
                    classes = line.Split(',');
                }
                if (readGlyph)
                {
                    glyph = line.Split('\t');
                }
                if (readDesc)
                {
                    _description = line;
                }
                count++;
            }
            size = classes.Length;
            _classes = new Classess[size];
            for (int i = 0; i < size; i++)
            {
                _classes[i] = (Classess)Enum.Parse(typeof(Classess), classes[i]);
            }
            color = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), glyph[0]);
            vis = Convert.ToChar(glyph[1]);
            foreach (string data in weaponsData)
            {
                string[] newData = data.Split('\n');
                MonsterWeapon mw = new MonsterWeapon();
                mw.Name = (StringName)Enum.Parse(typeof(StringName), newData[0]);
                mw.ProfBonus = Convert.ToInt16(newData[1]);
                mw.Latency = Convert.ToInt16(newData[2]);
                string[] dmg = newData[3].Split('/');
                int[] damage = new int[3];
                damage[0] = Convert.ToInt16(dmg[0]);
                damage[1] = Convert.ToInt16(dmg[1]);
                damage[2] = Convert.ToInt16(dmg[2]);
                mw.Damage = damage;
                mw.Attacks = Convert.ToInt16(newData[4]);
                mw.DefBonus = Convert.ToInt16(newData[5]);
                mwList.Add(mw);
            }
            string[] ad = armorData.Split('\n');
            ma = new MonsterArmor();
            ma.Defence = Convert.ToInt16(ad[0]);
            int[] prot = new int[3];
            string[] protStr = ad[1].Split('/');
            prot[0] = Convert.ToInt16(protStr[0]);
            prot[1] = Convert.ToInt16(protStr[1]);
            prot[2] = Convert.ToInt16(protStr[2]);
            ma.Protection = prot;
            int[] limit = new int[2];
            string[] limitStr = ad[2].Split('/');
            limit[0] = Convert.ToInt16(limitStr[0]);
            limit[1] = Convert.ToInt16(limitStr[1]);
            ma.Limitation = limit;
        }