コード例 #1
0
ファイル: SpellFactory.cs プロジェクト: RoBorg/particles-bug
        public static Spell Create(XmlNode spellNode)
        {
            var name            = spellNode.SelectSingleNode("name").InnerText;
            var firingMethod    = (Spell.FiringMethod)System.Enum.Parse(typeof(Spell.FiringMethod), spellNode.SelectSingleNode("firingMethod").InnerText);
            var title           = spellNode.SelectSingleNode("title").InnerText;
            var description     = spellNode.SelectSingleNode("description").InnerText;
            var rank            = int.Parse(spellNode.SelectSingleNode("rank").InnerText);
            var locked          = bool.Parse(spellNode.SelectSingleNode("locked").InnerText);
            var unlockCost      = int.Parse(spellNode.SelectSingleNode("unlockCost").InnerText);
            var manaCost        = int.Parse(spellNode.SelectSingleNode("manaCost").InnerText);
            var projectileSpeed = float.Parse(spellNode.SelectSingleNode("projectileSpeed").InnerText);
            var parentName      = spellNode.SelectSingleNode("parentName").InnerText;
            var chargedObject   = Resources.Load <GameObject>("Spells/" + name + "/Charged");
            var damageHealth    = GetDamageValue(spellNode, "health");
            var damageMana      = GetDamageValue(spellNode, "mana");
            var damageFire      = GetDamageValue(spellNode, "fire");
            var damageIce       = GetDamageValue(spellNode, "ice");
            var damageWater     = GetDamageValue(spellNode, "water");
            var damageLightning = GetDamageValue(spellNode, "lightning");

            var standardSpellProperties = new StandardSpellProperties(name, firingMethod, title, description,
                                                                      rank, locked, unlockCost, manaCost, projectileSpeed, parentName, chargedObject, damageHealth,
                                                                      damageMana, damageFire, damageIce, damageWater, damageLightning);

            SpellInstanceFactory spellInstanceFactory = null;

            string[] types      = { "flamethrower" };
            var      typesXpath = string.Join("|", types);


            var node = spellNode.SelectSingleNode(typesXpath);

            Assert.IsNotNull(node, "XML error - no spell type node found");

            switch (node.Name)
            {
            case "flamethrower":
            {
                var spreadAngle     = float.Parse(node.SelectSingleNode("spreadAngle").InnerText);
                var damagePerSecond = float.Parse(node.SelectSingleNode("damagePerSecond").InnerText);
                var duration        = float.Parse(node.SelectSingleNode("duration").InnerText);

                spellInstanceFactory = new FlamethrowerFactory(standardSpellProperties, spreadAngle, damagePerSecond, duration);
                break;
            }

            default:
            {
                throw new System.ArgumentException("No creation code for " + node.Name);
            }
            }

            spellFactories[standardSpellProperties.name] = spellInstanceFactory;

            return(spellInstanceFactory.GetSpell());
        }
コード例 #2
0
ファイル: SpellFactory.cs プロジェクト: RoBorg/particles-bug
            public FlamethrowerFactory(StandardSpellProperties standardSpellProperties, float spreadAngle, float damagePerSecond, float duration)
            {
                this.standardSpellProperties = standardSpellProperties;
                this.spreadAngle             = spreadAngle;
                this.damagePerSecond         = damagePerSecond;
                this.duration = duration;

                flameObject            = LoadObject <Projectiles.Projectile>("Flame");
                flameDamageProbeObject = LoadObject <Projectiles.Projectile>("FlameDamageProbe");
            }
コード例 #3
0
ファイル: Flamethrower.cs プロジェクト: RoBorg/particles-bug
        public Flamethrower(StandardSpellProperties standardSpellProperties, Projectiles.Projectile flameObject,
                            Projectiles.Projectile flameDamageProbeObject, float spreadAngle, float damagePerSecond,
                            float duration)
            : base(standardSpellProperties)
        {
            this.flameObject            = flameObject;
            this.flameDamageProbeObject = flameDamageProbeObject;
            this.spreadAngle            = spreadAngle;
            this.damagePerSecond        = damagePerSecond;
            this.duration = duration;

            isCasting = false;
        }
コード例 #4
0
        /**
         * Create the new spell
         * 
         * @param name The spell's standard properties
         */
        public Spell(StandardSpellProperties standardSpellProperties)
        {
            name = standardSpellProperties.name;
            firingMethod = standardSpellProperties.firingMethod;
            title = standardSpellProperties.title;
            description = standardSpellProperties.description;
            rank = standardSpellProperties.rank;
            unlockCost = standardSpellProperties.unlockCost;
            manaCost = standardSpellProperties.manaCost;
            parentName = standardSpellProperties.parentName;
            projectileSpeed = standardSpellProperties.projectileSpeed;
            chargedObject = standardSpellProperties.chargedObject;

            children = new List<Spell>();
            projectiles = new List<Spells.Projectiles.Projectile>();
        }