Exemplo n.º 1
0
        /// <summary>
        /// Cast a <see cref="Spell"/> with the supplied <see cref="SpellParameters"/>.
        /// </summary>
        public void CastSpell(SpellParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException();
            }

            if (DisableManager.Instance.IsDisabled(DisableType.BaseSpell, parameters.SpellInfo.BaseInfo.Entry.Id))
            {
                if (this is Player player)
                {
                    player.SendSystemMessage($"Unable to cast base spell {parameters.SpellInfo.BaseInfo.Entry.Id} because it is disabled.");
                }
                return;
            }

            if (DisableManager.Instance.IsDisabled(DisableType.Spell, parameters.SpellInfo.Entry.Id))
            {
                if (this is Player player)
                {
                    player.SendSystemMessage($"Unable to cast spell {parameters.SpellInfo.Entry.Id} because it is disabled.");
                }
                return;
            }

            var spell = new Spell.Spell(this, parameters);

            spell.Cast();
            pendingSpells.Add(spell);
        }
Exemplo n.º 2
0
        protected SpellParameters getParams()
        {
            SpellParameters parameters = 0;

            if (TimePerMana != 500)
            {
                parameters |= SpellParameters.TimePerMana;
            }
            if (DamagePerLevel != 1)
            {
                parameters |= SpellParameters.DamagePerLevel;
            }
            if (DamageType != GUC.Enumeration.DamageTypes.DAM_MAGIC)
            {
                parameters |= SpellParameters.DamageType;
            }
            if (SpellType != SPELL_TYPE.BAD)
            {
                parameters |= SpellParameters.SpellType;
            }
            if (CanTurnDuringInvest != true)
            {
                parameters |= SpellParameters.CanTurnDuringInvest;
            }
            if (CanChangeTargetDuringInvest != true)
            {
                parameters |= SpellParameters.CanChangeTargetDuringInvest;
            }
            if (isMultiEffect != true)
            {
                parameters |= SpellParameters.isMultiEffect;
            }
            if (TargetCollectionAlgo != SPELL_TARGET_COLLECT.TARGET_COLLECT_FOCUS_FALLBACK_NONE)
            {
                parameters |= SpellParameters.TargetCollectionAlgo;
            }
            if (TargetCollectType != SPELL_TARGET_TYPES.TARGET_TYPE_NPCS)
            {
                parameters |= SpellParameters.TargetCollectType;
            }
            if (TargetCollectRange != 10000)
            {
                parameters |= SpellParameters.TargetCollectRange;
            }
            if (TargetCollectAzi != 60)
            {
                parameters |= SpellParameters.TargetCollectAzi;
            }
            if (TargetCollectElev != 60)
            {
                parameters |= SpellParameters.TargetCollectElev;
            }

            return(parameters);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Cast a <see cref="Spell"/> with the supplied <see cref="SpellParameters"/>.
        /// </summary>
        public void CastSpell(SpellParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException();
            }

            var spell = new Spell.Spell(this, parameters);

            spell.Cast();
            pendingSpells.Add(spell);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Cast a <see cref="Spell"/> with the supplied spell id and <see cref="SpellParameters"/>.
        /// </summary>
        public void CastSpell(uint spell4Id, SpellParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException();
            }

            Spell4Entry spell4Entry = GameTableManager.Instance.Spell4.GetEntry(spell4Id);

            if (spell4Entry == null)
            {
                throw new ArgumentOutOfRangeException();
            }

            CastSpell(spell4Entry.Spell4BaseIdBaseSpell, (byte)spell4Entry.TierIndex, parameters);
        }
Exemplo n.º 5
0
    public override void Cast(SpellParameters spellParameters)
    {
        switch (spellParameters.element)
        {
        case Element.WATER:
            WaterControllerScript.instance.AddWater(spellParameters.activeProjectile.transform.position, spellParameters.elementAmount);
            break;

        case Element.FIRE:
            FireControllerScript.instance.AddFire(spellParameters.activeProjectile.transform.position);
            break;

        case Element.NATURE:
            CrawlController.instance.CreateCrawl(spellParameters.activeProjectile.transform.position, spellParameters.elementAmount, 3);
            break;
        }
    }
    public override void Cast(SpellParameters spellParameters)
    {
        Vector2 dir = ((Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition) - (Vector2)spellParameters.positionToCast).normalized;

        GameObject projectile = Instantiate(spellParameters.projectileObject, spellParameters.positionToCast, Quaternion.identity);

        ProjectileScript projectileScript = projectile.GetComponent <ProjectileScript>();

        spellParameters.activeProjectile = projectile;

        projectileScript.spellParameters = spellParameters;

        projectileScript.collisionBehaviour = spellParameters.collisionBehaviour;

        projectileScript.maxRangeBehaviour = spellParameters.maxRangeBehaviour;

        projectileScript.projectileSpeed = spellParameters.projectileSpeed;

        projectileScript.direction = dir;

        projectileScript.maxRange = spellParameters.maxRange;
    }
Exemplo n.º 7
0
        /// <summary>
        /// Cast a <see cref="Spell"/> with the supplied spell base id, tier and <see cref="SpellParameters"/>.
        /// </summary>
        public void CastSpell(uint spell4BaseId, byte tier, SpellParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException();
            }

            SpellBaseInfo spellBaseInfo = GlobalSpellManager.Instance.GetSpellBaseInfo(spell4BaseId);

            if (spellBaseInfo == null)
            {
                throw new ArgumentOutOfRangeException();
            }

            SpellInfo spellInfo = spellBaseInfo.GetSpellInfo(tier);

            if (spellInfo == null)
            {
                throw new ArgumentOutOfRangeException();
            }

            parameters.SpellInfo = spellInfo;
            CastSpell(parameters);
        }
Exemplo n.º 8
0
 public override void Cast(SpellParameters spellParameters)
 {
     spellParameters.targetHit.TakeDamage(spellParameters.damage);
 }
Exemplo n.º 9
0
    public override void Cast(SpellParameters spellParameters)
    {
        Vector2 pos = spellParameters.activeProjectile.transform.position;

        CrawlController.instance.AddFire(pos);
    }
Exemplo n.º 10
0
 public abstract void Cast(SpellParameters spellParameters);
Exemplo n.º 11
0
 public override void Cast(SpellParameters spellParameters)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 12
0
        public void Write(BitStream stream)
        {
            stream.Write(this.id);
            stream.Write(this.Name);
            stream.Write(this.FXName);
            stream.Write(this.AniName);

            stream.Write(processMana.Length);
            for (int i = 0; i < processMana.Length; i++)
            {
                stream.Write(processMana[i]);
            }

            SpellParameters paramI = getParams();

            BitStreamExtension.Write(stream, (ushort)paramI);

            if (paramI.HasFlag(SpellParameters.TimePerMana))
            {
                stream.Write(this.TimePerMana);
            }
            if (paramI.HasFlag(SpellParameters.DamagePerLevel))
            {
                stream.Write(this.DamagePerLevel);
            }
            if (paramI.HasFlag(SpellParameters.DamageType))
            {
                stream.Write((byte)DamageType);
            }
            if (paramI.HasFlag(SpellParameters.SpellType))
            {
                stream.Write((byte)SpellType);
            }
            if (paramI.HasFlag(SpellParameters.CanTurnDuringInvest))
            {
                stream.Write(this.CanTurnDuringInvest);
            }
            if (paramI.HasFlag(SpellParameters.CanChangeTargetDuringInvest))
            {
                stream.Write(this.CanChangeTargetDuringInvest);
            }
            if (paramI.HasFlag(SpellParameters.isMultiEffect))
            {
                stream.Write(this.isMultiEffect);
            }
            if (paramI.HasFlag(SpellParameters.TargetCollectionAlgo))
            {
                stream.Write((byte)TargetCollectionAlgo);
            }
            if (paramI.HasFlag(SpellParameters.TargetCollectType))
            {
                stream.Write((byte)TargetCollectType);
            }
            if (paramI.HasFlag(SpellParameters.TargetCollectRange))
            {
                stream.Write(this.TargetCollectRange);
            }
            if (paramI.HasFlag(SpellParameters.TargetCollectAzi))
            {
                stream.Write(this.TargetCollectAzi);
            }
            if (paramI.HasFlag(SpellParameters.TargetCollectElev))
            {
                stream.Write(this.TargetCollectElev);
            }
        }
Exemplo n.º 13
0
        public void Read(BitStream stream)
        {
            stream.Read(out this.id);
            stream.Read(out this.Name);
            stream.Read(out this.FXName);
            stream.Read(out this.AniName);

            int chargeCount = 0;

            stream.Read(out chargeCount);
            this.processMana = new int[chargeCount];
            for (int i = 0; i < chargeCount; i++)
            {
                stream.Read(out processMana[i]);
            }

            ushort param = 0;

            BitStreamExtension.Read(stream, out param);
            SpellParameters paramI = (SpellParameters)param;

            if (paramI.HasFlag(SpellParameters.TimePerMana))
            {
                stream.Read(out this.TimePerMana);
            }
            if (paramI.HasFlag(SpellParameters.DamagePerLevel))
            {
                stream.Read(out this.DamagePerLevel);
            }
            if (paramI.HasFlag(SpellParameters.DamageType))
            {
                byte dt = 0;
                stream.Read(out dt);
                DamageType = (DamageTypes)dt;
            }
            if (paramI.HasFlag(SpellParameters.SpellType))
            {
                byte dt = 0;
                stream.Read(out dt);
                SpellType = (SPELL_TYPE)dt;
            }
            if (paramI.HasFlag(SpellParameters.CanTurnDuringInvest))
            {
                stream.Read(out this.CanTurnDuringInvest);
            }
            if (paramI.HasFlag(SpellParameters.CanChangeTargetDuringInvest))
            {
                stream.Read(out this.CanChangeTargetDuringInvest);
            }
            if (paramI.HasFlag(SpellParameters.isMultiEffect))
            {
                stream.Read(out this.isMultiEffect);
            }
            if (paramI.HasFlag(SpellParameters.TargetCollectionAlgo))
            {
                byte dt = 0;
                stream.Read(out dt);
                TargetCollectionAlgo = (SPELL_TARGET_COLLECT)dt;
            }
            if (paramI.HasFlag(SpellParameters.TargetCollectType))
            {
                byte dt = 0;
                stream.Read(out dt);
                TargetCollectType = (SPELL_TARGET_TYPES)dt;
            }
            if (paramI.HasFlag(SpellParameters.TargetCollectRange))
            {
                stream.Read(out this.TargetCollectRange);
            }
            if (paramI.HasFlag(SpellParameters.TargetCollectAzi))
            {
                stream.Read(out this.TargetCollectAzi);
            }
            if (paramI.HasFlag(SpellParameters.TargetCollectElev))
            {
                stream.Read(out this.TargetCollectElev);
            }
        }
    public override void OnInspectorGUI()
    {
        TestSO.Update();

        EditorGUILayout.BeginVertical();

        int i = 0;

        for (int index = 0; index < myTestData.spells.Count; index++)
        {
            Spell spell = myTestData.spells[i];

            showSpellData[i] = EditorGUILayout.Foldout(showSpellData[i], (spell.name != null && spell.name.Length > 0) ? spell.name : "Spell #" + i);
            if (showSpellData[i])
            {
                SpellParameters sp = spell.spellParams;

                spell.name = EditorGUILayout.TextField("Name:", spell.name);

                spell.spellType = (SpellTypes)EditorGUILayout.EnumPopup("Spell Type:", spell.spellType);

                sp.element = (Element)EditorGUILayout.EnumPopup("Element:", sp.element);

                sp.elementCost = EditorGUILayout.IntField("Element Cost:", sp.elementCost);

                sp.staminaCost = EditorGUILayout.IntField("Stamina Cost:", sp.staminaCost);

                sp.castTime = EditorGUILayout.FloatField("Cast Time:", sp.castTime);

                sp.damage = EditorGUILayout.IntField("Damage:", sp.damage);



                switch (sp.element)
                {
                case Element.FIRE:
                    sp.fireStrength = EditorGUILayout.IntField("Fire Strength:", sp.fireStrength);
                    break;

                case Element.EARTH:
                    sp.earthStrength = EditorGUILayout.IntField("Earth Strength:", sp.earthStrength);
                    break;

                case Element.NATURE:
                    sp.natureStrength = EditorGUILayout.IntField("Nature Strength:", sp.natureStrength);
                    break;

                case Element.WATER:
                    sp.waterStrength = EditorGUILayout.IntField("Water Strength:", sp.waterStrength);
                    break;
                }

                spell.castingBehaviour = (ICast)EditorGUILayout.ObjectField("Casting Behaviour", spell.castingBehaviour, typeof(ICast), true);

                if (spell.castingBehaviour != null)
                {
                    Debug.Log(spell.castingBehaviour.name);
                    switch (spell.castingBehaviour.name)
                    {
                    case "ICastProjectileObject":

                        EditorGUILayout.TextArea("Projectile Params:");

                        sp.projectileObject   = (GameObject)EditorGUILayout.ObjectField("Projectile Object:", sp.projectileObject, typeof(GameObject), true);
                        sp.collisionBehaviour = (ICast)EditorGUILayout.ObjectField("Collision Behaviour:", sp.collisionBehaviour, typeof(ICast), true);
                        sp.maxRangeBehaviour  = (ICast)EditorGUILayout.ObjectField("Max Range Behaviour:", sp.maxRangeBehaviour, typeof(ICast), true);
                        sp.projectileSpeed    = EditorGUILayout.IntField("Projectile Speed:", sp.projectileSpeed);
                        sp.maxRange           = EditorGUILayout.IntField("Max Range:", sp.maxRange);
                        sp.updateBehaviour    = (ICast)EditorGUILayout.ObjectField("Update Behaviour:", sp.updateBehaviour, typeof(ICast), true);

                        sp.elementAmount = EditorGUILayout.IntField("Element amount:", sp.elementAmount);

                        switch (sp.element)
                        {
                        case Element.NATURE:
                            sp.maxCrawl   = EditorGUILayout.IntField("Max crawl:", sp.maxCrawl);
                            sp.growthRate = EditorGUILayout.FloatField("Growth Rate:", sp.growthRate);
                            break;
                        }

                        break;
                    }
                }

                if (GUILayout.Button("Reset Parameters", GUILayout.Width(150)))
                {
                    myTestData.spells[index] = new Spell();
                }

                if (GUILayout.Button("Remove Spell", GUILayout.Width(150)))
                {
                    myTestData.spells.RemoveAt(index);
                    showSpellData.RemoveAt(index);
                }
            }
            i++;
        }

        EditorGUILayout.EndVertical();

        if (GUILayout.Button("Add Spell"))
        {
            myTestData.spells.Add(new Spell());
            showSpellData.Add(false);
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
            EditorUtility.SetDirty(myTestData);
        }

        TestSO.ApplyModifiedProperties();
    }
Exemplo n.º 15
0
    public override void Cast(SpellParameters spellParameters)
    {
        Vector2 pos = spellParameters.activeProjectile.transform.position;

        CrawlController.instance.CreateCrawl(pos, spellParameters.maxCrawl, spellParameters.growthRate);
    }