public override void applyAffect(GameObject spell)
 {
     SpellCore spellCoreScript = spell.GetComponent<SpellCore>();
     Object explosionPrefab = Resources.Load("ExplosionPrefab", typeof(GameObject));
     GameObject explosionBall = (GameObject)Object.Instantiate(explosionPrefab, spell.transform);
     spellCoreScript.explosionDamage = true;
 }
    // Use this for initialization
    public override void applyAffect(GameObject spell)
    {
        SpellCore spellCoreScript = spell.GetComponent <SpellCore>();

        if (spellCoreScript.speedMulti == 0)
        {
            spellCoreScript.livingTime *= (float)1.4;
        }
        else
        {
            spellCoreScript.speedMulti *= (float)1.4;
        }
    }
 private void CopySpellCoreValues(SpellCore toBeCopiedTo)
 {
     toBeCopiedTo.damageMulti     = this.damageMulti;
     toBeCopiedTo.speedMulti      = this.speedMulti;
     toBeCopiedTo.livingTime      = this.livingTime;
     toBeCopiedTo.livingTimeDecay = this.livingTimeDecay;
     if (this.setOffChildEffects)
     {
         toBeCopiedTo.hasItBeenCastedYet = this.hasItBeenCastedYet;
     }
     toBeCopiedTo.animateTextureOffsetY = this.animateTextureOffsetY;
     toBeCopiedTo.animateTextureOffsetX = this.animateTextureOffsetX;
     toBeCopiedTo.elementalAlignment    = this.elementalAlignment;
     toBeCopiedTo.scale = this.scale;
     toBeCopiedTo.dontDestroyOnImpactWithEnemies = this.dontDestroyOnImpactWithEnemies;
     toBeCopiedTo.isBeam          = this.isBeam;
     toBeCopiedTo.isProjectile    = this.isProjectile;
     toBeCopiedTo.residualDamage  = this.residualDamage;
     toBeCopiedTo.isThrowable     = this.isThrowable;
     toBeCopiedTo.explosionDamage = this.explosionDamage;
     toBeCopiedTo.paralyzer       = this.paralyzer;
     toBeCopiedTo.gravity         = this.gravity;
 }
    private void CopySpellCoreValues(SpellCore toBeCopiedTo)
    {
        SpellCore thisSpellCore = gameObject.GetComponent <SpellCore>();

        toBeCopiedTo.damageMulti     = thisSpellCore.damageMulti;
        toBeCopiedTo.speedMulti      = thisSpellCore.speedMulti;
        toBeCopiedTo.livingTime      = thisSpellCore.livingTime;
        toBeCopiedTo.livingTimeDecay = thisSpellCore.livingTimeDecay;

        toBeCopiedTo.hasItBeenCastedYet    = thisSpellCore.hasItBeenCastedYet;
        toBeCopiedTo.animateTextureOffsetY = thisSpellCore.animateTextureOffsetY;
        toBeCopiedTo.animateTextureOffsetX = thisSpellCore.animateTextureOffsetX;
        toBeCopiedTo.elementalAlignment    = thisSpellCore.elementalAlignment;
        toBeCopiedTo.scale = thisSpellCore.scale;
        toBeCopiedTo.dontDestroyOnImpactWithEnemies = thisSpellCore.dontDestroyOnImpactWithEnemies;
        toBeCopiedTo.isBeam          = thisSpellCore.isBeam;
        toBeCopiedTo.isProjectile    = thisSpellCore.isProjectile;
        toBeCopiedTo.residualDamage  = thisSpellCore.residualDamage;
        toBeCopiedTo.isThrowable     = thisSpellCore.isThrowable;
        toBeCopiedTo.explosionDamage = thisSpellCore.explosionDamage;
        toBeCopiedTo.paralyzer       = thisSpellCore.paralyzer;
        toBeCopiedTo.gravity         = thisSpellCore.gravity;
    }
    // Use this for initialization
    public override void applyAffect(GameObject spell)
    {
        SpellCore spellCoreScript = spell.GetComponent <SpellCore>();

        spellCoreScript.damageMulti *= (float)1.2;
    }
    public void DoOnCast()
    {
        base.DoOnCast();

        RaycastHit hit;

        GameObject.Destroy(gameObject.GetComponent <Collider>());
        GameObject.Destroy(gameObject.GetComponent <MeshRenderer>());
        GameObject.Destroy(gameObject.GetComponent <MeshFilter>());

        if (Physics.Raycast(transform.position, transform.up, out hit))
        {
            GameObject effect = Instantiate(effectToBePlaced);
            effect.transform.position = hit.point;

            SpellCore effectSpellCore = effect.GetComponent <SpellCore>();
            if (effectSpellCore != null)
            {
                CopySpellCoreValues(effectSpellCore);
                if (effectSpellCore.explosionDamage)
                {
                    ExplosionModifier explosionModifier = new ExplosionModifier();
                    explosionModifier.applyAffect(effect);
                    if (setOffChildEffects)
                    {
                        effect.GetComponentInChildren <ExplosionEffect>().Explode();
                    }
                }

                if (effectSpellCore.gravity)
                {
                    GravityModifier gravityModifier = new GravityModifier();
                    gravityModifier.applyAffect(effect);
                }

                if (effectSpellCore.scale.x > 1)
                {
                    Vector3 effectScale = effect.transform.localScale;
                    effectScale.x *= effectSpellCore.scale.x;
                    effectScale.y *= effectSpellCore.scale.y;
                    effectScale.z *= effectSpellCore.scale.z;
                    effect.transform.localScale = effectScale;
                }

                if (effectSpellCore.elementalAlignment != "")
                {
                    Renderer[] renderers = effect.GetComponentsInChildren <Renderer>();
                    foreach (Renderer someRenderer in renderers)
                    {
                        if (effectSpellCore.elementalAlignment == "Water")
                        {
                            someRenderer.material.color = Color.blue;
                        }
                        else if (effectSpellCore.elementalAlignment == "Nature")
                        {
                            someRenderer.material.color = Color.green;
                        }
                        else if (effectSpellCore.elementalAlignment == "Fire")
                        {
                            someRenderer.material.color = Color.red;
                        }
                    }
                }
            }
        }

        GameObject.Destroy(gameObject);
    }
    public override void applyAffect(GameObject spell)
    {
        SpellCore spellCoreScript = spell.GetComponent <SpellCore>();

        spellCoreScript.paralyzer = true;
    }
    // Update is called once per frame
    void Update()
    {
        frameTracker++;
        lifeSpan--;
        if (frameTracker % spawningPeriod == 0)
        {
            System.Random random = new System.Random();
            GameObject    meteor = GameObject.Instantiate(meteorBallPrefab, new Vector3((float)(random.NextDouble() * 14) + transform.position.x - 7, transform.position.y, (float)(random.NextDouble() * 14) + transform.position.z - 7),
                                                          new Quaternion());
            meteor.GetComponent <Rigidbody>().velocity        = new Vector3(0f, -70f, 0f);
            meteor.GetComponent <Rigidbody>().angularVelocity = new Vector3(((float)random.NextDouble() * 2) - 1, ((float)random.NextDouble() * 2) - 1, ((float)random.NextDouble() * 2) - 1) * 10;
            spawningPeriod            = random.Next(10, 25);
            meteor.transform.rotation = new Quaternion((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble());

            SpellCore spellCore = meteor.GetComponent <SpellCore>();
            CopySpellCoreValues(spellCore);
            spellCore.hasItBeenCastedYet = true;
            //spellCore.DoOnCast();

            if (spellCore.explosionDamage)
            {
                ExplosionModifier explosionModifier = new ExplosionModifier();
                explosionModifier.applyAffect(spellCore.gameObject);
            }

            if (spellCore.gravity)
            {
                GravityModifier gravityModifier = new GravityModifier();
                gravityModifier.applyAffect(spellCore.gameObject);
            }

            if (spellCore.scale.x > 1)
            {
                Vector3 effectScale = spellCore.gameObject.transform.localScale;
                effectScale.x *= spellCore.scale.x;
                effectScale.y *= spellCore.scale.y;
                effectScale.z *= spellCore.scale.z;
                spellCore.gameObject.transform.localScale = effectScale;
            }

            if (spellCore.elementalAlignment != "")
            {
                Renderer[] renderers  = spellCore.gameObject.GetComponentsInChildren <Renderer>();
                Texture    newTexture = Resources.Load("Asteroids_Grey") as Texture;
                foreach (Renderer someRenderer in renderers)
                {
                    someRenderer.material.SetTexture("_MainTex", newTexture);
                    if (spellCore.elementalAlignment == "Water")
                    {
                        someRenderer.material.color = Color.blue;
                    }
                    else if (spellCore.elementalAlignment == "Nature")
                    {
                        someRenderer.material.color = Color.green;
                    }
                    else if (spellCore.elementalAlignment == "Fire")
                    {
                        someRenderer.material.color = Color.red;
                    }
                }
            }



            frameTracker = 1;
        }

        if (lifeSpan <= 0)
        {
            Destroy(gameObject);
        }
    }
    public override void applyAffect(GameObject spell)
    {
        SpellCore spellCoreScript = spell.GetComponent <SpellCore>();

        spellCoreScript.residualDamage = true;
    }