コード例 #1
0
ファイル: MonsterFactory.cs プロジェクト: donblas/magecrawl
        private Monster CreateMonsterCore(string baseType, int level, Point p)
        {
            var monsterInstance = m_monsterInstances[baseType].Find(x => x.Second == level);
            if (monsterInstance == null)
                return null;

            string monsterName = monsterInstance.First;

            string AIType = m_monsterStats[baseType]["AIType"];
            int baseHP = int.Parse(m_monsterStats[baseType]["BaseHP"], CultureInfo.InvariantCulture);
            int hpPerLevel = int.Parse(m_monsterStats[baseType]["HPPerLevel"], CultureInfo.InvariantCulture);
            int maxHP = baseHP + (level * hpPerLevel);
            bool intelligent = bool.Parse(m_monsterStats[baseType]["Intelligent"]);
            int vision = int.Parse(m_monsterStats[baseType]["BaseVision"], CultureInfo.InvariantCulture);
            string baseDamageString = m_monsterStats[baseType]["BaseDamage"];
            DiceRoll damagePerLevel = new DiceRoll(m_monsterStats[baseType]["DamagePerLevel"]);
            DiceRoll damage = new DiceRoll(baseDamageString);
            for (int i = 0; i < level; ++i)
                damage.Add(damagePerLevel);
            int evade = int.Parse(m_monsterStats[baseType]["BaseEvade"], CultureInfo.InvariantCulture);
            double ctIncreaseModifer = double.Parse(m_monsterStats[baseType]["BaseCTIncrease"], CultureInfo.InvariantCulture);
            double ctMoveCost = double.Parse(m_monsterStats[baseType]["BaseCTMoveCost"], CultureInfo.InvariantCulture);
            double ctActCost = double.Parse(m_monsterStats[baseType]["BaseCTActCost"], CultureInfo.InvariantCulture);
            double ctAttackCost = double.Parse(m_monsterStats[baseType]["BaseCTAttackCost"], CultureInfo.InvariantCulture);
            return CreateMonsterCore(baseType, AIType, monsterName, level, p, maxHP, intelligent, vision, damage, evade, ctIncreaseModifer, ctMoveCost, ctActCost, ctAttackCost);
        }
コード例 #2
0
ファイル: Spell.cs プロジェクト: donblas/magecrawl
 internal Spell(string name, string school, string effectType, int cost, TargetingInfo.TargettingType targettingType, int range, DiceRoll baseDamage, DiceRoll damagePerLevel)
 {
     m_name = name;
     m_effectType = effectType;
     m_cost = cost;
     m_school = school;
     m_targettingType = targettingType;
     m_range = range;
     BaseDamage = baseDamage;
     DamagePerLevel = damagePerLevel;
 }
コード例 #3
0
ファイル: StatsBasedWeapon.cs プロジェクト: donblas/magecrawl
        private void Calculate()
        {
            BaseWeaponStats.Instance.LoadMappingIntoAttributes(this);

            m_damage = new DiceRoll(Attributes["BaseDamage"]);
            double damageBonus = 1 + (int.Parse(m_material.MaterialAttributes["DamageBonus"]) / 100.0);
            if (m_quality.Attributes.ContainsKey("DamageModifier"))
                damageBonus += (int.Parse(m_quality.Attributes["DamageModifier"]) / 100.0);

            m_damage.Rolls = (short)Math.Round(m_damage.Rolls * damageBonus);
            
            m_CTCost = double.Parse(Attributes["BaseSpeed"], CultureInfo.InvariantCulture);
            m_CTCost += double.Parse(m_material.MaterialAttributes["ExtraCTCost"], CultureInfo.InvariantCulture);
            if (m_quality.Attributes.ContainsKey("SpeedModifier"))
                m_CTCost *= 1 + (int.Parse(m_quality.Attributes["SpeedModifier"], CultureInfo.InvariantCulture) / 100.0);
        }
コード例 #4
0
ファイル: SpellFactory.cs プロジェクト: donblas/magecrawl
        private void ReadFileCallback(XmlReader reader, object data)
        {
            if (reader.LocalName != "Spells")
                throw new System.InvalidOperationException("Bad spell defination file");

            while (true)
            {
                reader.Read();
                if (reader.NodeType == XmlNodeType.EndElement && reader.LocalName == "Spells")
                {
                    break;
                }
                if (reader.LocalName == "Spell")
                {
                    string name = reader.GetAttribute("Name");
                    string school = reader.GetAttribute("School");
                    string effectType = reader.GetAttribute("EffectType");

                    string costString = reader.GetAttribute("Cost");
                    int cost = int.Parse(costString);
                    
                    DiceRoll baseDamage = DiceRoll.Invalid;
                    string baseDamageString = reader.GetAttribute("BaseDamageString");
                    if (baseDamageString != null)
                        baseDamage = new DiceRoll(baseDamageString);

                    DiceRoll damagePerLevel = DiceRoll.Invalid;
                    string damagePerLevelString = reader.GetAttribute("DamagePerLevel");
                    if (damagePerLevelString != null)
                        damagePerLevel = new DiceRoll(damagePerLevelString);

                    int range = -1;
                    string rangeString = reader.GetAttribute("Range");
                    if (rangeString != null)
                        range = int.Parse(rangeString);

                    TargetingInfo.TargettingType targettingType = TargetingInfo.TargettingType.Self;
                    string targettingString = reader.GetAttribute("TargettingType");
                    if (targettingString != null)
                        targettingType = (TargetingInfo.TargettingType)Enum.Parse(typeof(TargetingInfo.TargettingType), targettingString, false);

                    m_spellMapping.Add(name, new Spell(name, school, effectType, cost, targettingType, range, baseDamage, damagePerLevel));
                }
            }
        }
コード例 #5
0
ファイル: Monster.cs プロジェクト: donblas/magecrawl
 internal Monster(string baseType, string name, int level, Point p, int maxHP, bool intelligent, int vision, DiceRoll damage, double evade,
                double ctIncreaseModifer, double ctMoveCost, double ctActCost, double ctAttackCost, List<IMonsterTactic> tactics)
     : base(name, p, ctIncreaseModifer, ctMoveCost, ctActCost)
 {
     m_baseType = baseType;
     m_level = level;
     CTAttackCost = ctAttackCost;
     m_currentHP = maxHP;
     m_maxHP = maxHP;
     m_damage = damage;
     PlayerLastKnownPosition = Point.Invalid;
     m_evade = evade;
     m_baseVision = vision;
     Intelligent = intelligent;
     Attributes = new SerializableDictionary<string, string>();
     m_tactics = tactics;
     m_tactics.ForEach(t => t.SetupAttributesNeeded(this));
 }
コード例 #6
0
ファイル: DiceRoll.cs プロジェクト: donblas/magecrawl
        public void Add(DiceRoll other)
        {
            // If the other is zero, nothing to do.
            if (other.Equals(Zero))
                return;

            // If we're zero, take their values
            if (this.Equals(Zero))
            {
                Rolls = other.Rolls;
                DiceFaces = other.DiceFaces;
                Multiplier = other.Multiplier;
                ToAdd = other.ToAdd;
                return;
            }

            // If neither are zero, the d'ness better match
            if (DiceFaces != other.DiceFaces)
                throw new InvalidOperationException(string.Format("Can't add dice rolls: {0} + {1}", this, other));

            Rolls += other.Rolls;
            ToAdd += other.ToAdd;
            Multiplier += 1 - other.Multiplier;
        }
コード例 #7
0
ファイル: DiceRoll.cs プロジェクト: donblas/magecrawl
 public bool Equals(DiceRoll other)
 {
     return Rolls == other.Rolls && DiceFaces == other.DiceFaces && ToAdd == other.ToAdd && Multiplier == other.Multiplier;
 }
コード例 #8
0
ファイル: MonsterFactory.cs プロジェクト: donblas/magecrawl
        private Monster CreateMonsterCore(string baseType, string AIType, string name, int level, Point p, int maxHP, bool intelligent, int vision, DiceRoll damage, double evade, double ctIncreaseModifer, double ctMoveCost, double ctActCost, double ctAttackCost)
        {
            List<IMonsterTactic> tactics = new List<IMonsterTactic>();

            switch (AIType)
            {
                case "Bruiser":
                    tactics.Add(new DoubleSwingTactic());
                    tactics.Add(new DefaultTactic());
                    break;
                case "Healer":
                    tactics.Add(new UseFirstAidTactic());
                    tactics.Add(new MoveToWoundedAllyTactic());
                    tactics.Add(new DefaultTactic());
                    break;
                case "Ranged":
                    tactics.Add(new KeepAwayFromMeleeRangeIfAbleTactic());
                    tactics.Add(new UseSlingStoneTactic());
                    tactics.Add(new KeepAwayFromPlayerWithOtherMonstersNearbyTactic());
                    tactics.Add(new PossiblyRunFromPlayerTactic());
                    tactics.Add(new DefaultTactic());
                    break;
                case "Sprinter":
                    tactics.Add(new RushTactic());
                    tactics.Add(new DefaultTactic());
                    break;
                default:
                    tactics.Add(new DefaultTactic());
                    break;
            }

            Monster monster = new Monster(baseType, name, level, p, maxHP, intelligent, vision, damage, evade, ctIncreaseModifer, ctMoveCost, ctActCost, ctAttackCost, tactics);
            return monster;
        }