void CastSpell()
    {
        if (heroEquipment.paused == false)
        {
            //If the spell cast is not on cooldown
            if (!heroCooldowns.spellCooling)
            {
                if (heroLight.currentLight < 20)
                {
                    Camera.main.SendMessage("ScreenShake");
                    return;
                }
                heroEquipment.EmberLoseDurability();
                heroLight.LoseLight(20);
                playersLight.intensity = 5.5f;
                ///Instantiate(castParticles, transform.position, transform.rotation);
                heroCooldowns.spellCooling = true;
                anim.CrossFade("Spellcasting", 0.01f);
                shoot = true;

                if (heroEquipment.equippedAccessory == accessory.BoltOfLight)
                {
                    audioPlayer.PlayOneShot(boltAudio);
                }
                else if (heroEquipment.equippedAccessory == accessory.OrbOfLight)
                {
                    audioPlayer.PlayOneShot(orbAudio);
                }
            }
            else
            {
                UICD.FlashCooldown(0);
            }
        }
    }
    void Interact()
    {
        Vector3 dist = transform.position - player.transform.position;

        if (dist.magnitude < 1.0f)
        {
            theoptions.OpenChest();
            heroLight.LoseLight(5);
            gameObject.GetComponent <GenerateLoot>().Generateloot();
            //Instantiate (loot, transform.position, new Quaternion (0, 0, 0, 0));
            temp.SetActive(false);
            Destroy(temp);
            Destroy(this.gameObject);
        }
    }
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Wall")
        {
            Explode();
        }
        else if (other.tag == "Player")
        {
            int temp = (int)theLight.currentLight / 18;
            theLight.LoseLight(theLight.currentLight);
            for (int i = 0; i < temp; i++)
            {
                GameObject temps = (GameObject)Instantiate(the_remains, transform.position + new Vector3(Random.value * Random.Range(0, 4), Random.value * Random.Range(0, 4), transform.position.z), transform.rotation);
                if (temps.transform.position.x < -5 || temps.transform.position.x > 10 || temps.transform.position.y < -10 || temps.transform.position.y > 10)
                {
                    int forchoosing = Random.Range(0, 4);
                    switch (forchoosing)
                    {
                    case 0:
                        temps.transform.position = new Vector3(0, 0, temps.transform.position.z);
                        break;

                    case 1:
                        temps.transform.position = new Vector3(3, 0, temps.transform.position.z);

                        break;

                    case 2:
                        temps.transform.position = new Vector3(1, 3, temps.transform.position.z);

                        break;

                    case 3:
                        temps.transform.position = new Vector3(4, 8, temps.transform.position.z);

                        break;
                    }
                }
            }
            Explode();
        }
    }
    void Dash()
    {
        //If the player isnt already dashing, begin dashing
        if (!heroCooldowns.dashCooling)
        {
            if (heroLight.currentLight < 10)
            {
                return;
            }

            theoptions.AddToDash();

            //Make the player spend light
            heroLight.LoseLight(10);
            heroEquipment.EmberLoseDurability();
            heroCooldowns.dashCooling = true;
            timeRemaining             = dashDuration;
            if (heroEquipment.equippedBoot != boot.Whirlwind && heroEquipment.equippedBoot != boot.Decoy)
            {
                //Change the animation state into dashing
                anim.CrossFade("PlayerDashing", 0.01f);
            }

            //Set up the local variables
            trailBlazerDropTimer = 0.1f;

            lockRot = transform.rotation;

            if (heroEquipment.equippedBoot == boot.Trailblazer)
            {
                aPlayer.PlayOneShot(trail);
            }

            if (heroEquipment.equippedBoot == boot.Charge)
            {
                aPlayer.PlayOneShot(charge);
                oldPos = transform.position;
                once   = true;
                //No ember equipped
                if (heroEquipment.equippedEmber == ember.None)
                {
                    Instantiate(LightCharge, transform.position, new Quaternion(0, 0, 0, 0));
                }
                //Ice ember equipped
                else if (heroEquipment.equippedEmber == ember.Ice)
                {
                    Instantiate(IceCharge, transform.position, new Quaternion(0, 0, 0, 0));
                }
                //Fire ember equipped
                else if (heroEquipment.equippedEmber == ember.Fire)
                {
                    Instantiate(FireCharge, transform.position, new Quaternion(0, 0, 0, 0));
                }
                //Wind ember equipped
                else if (heroEquipment.equippedEmber == ember.Wind)
                {
                    Instantiate(WindCharge, transform.position, new Quaternion(0, 0, 0, 0));
                }
                //Life ember equipped
                else if (heroEquipment.equippedEmber == ember.Life)
                {
                    Instantiate(LifeCharge, transform.position, new Quaternion(0, 0, 0, 0));
                }
                else if (heroEquipment.equippedEmber == ember.Death)
                {
                    Instantiate(DeathCharge, transform.position, new Quaternion(0, 0, 0, 0));
                }
                else if (heroEquipment.equippedEmber == ember.Earth)
                {
                    Instantiate(EarthCharge, transform.position, new Quaternion(0, 0, 0, 0));
                }
            }

            if (heroEquipment.equippedBoot == boot.Blink)
            {
                aPlayer.PlayOneShot(blink);
                oldPos = transform.position;
                once   = true;
                Vector3 temp = (transform.TransformDirection(Vector3.up.normalized) * 3.0f) + transform.position;

                //No ember equipped
                if (heroEquipment.equippedEmber == ember.None)
                {
                    Instantiate(LightBlink, temp, new Quaternion(0, 0, 0, 0));
                }
                //Ice ember equipped
                else if (heroEquipment.equippedEmber == ember.Ice)
                {
                    Instantiate(IceBlink, temp, new Quaternion(0, 0, 0, 0));
                }
                //Fire ember equipped
                else if (heroEquipment.equippedEmber == ember.Fire)
                {
                    Instantiate(FireBlink, temp, new Quaternion(0, 0, 0, 0));
                }
                //Wind ember equipped
                else if (heroEquipment.equippedEmber == ember.Wind)
                {
                    Instantiate(WindBlink, temp, new Quaternion(0, 0, 0, 0));
                }
                //Life ember equipped
                else if (heroEquipment.equippedEmber == ember.Life)
                {
                    Instantiate(LifeBlink, temp, new Quaternion(0, 0, 0, 0));
                }
                else if (heroEquipment.equippedEmber == ember.Death)
                {
                    Instantiate(DeathBlink, temp, new Quaternion(0, 0, 0, 0));
                }
                else if (heroEquipment.equippedEmber == ember.Earth)
                {
                    Instantiate(EarthBlink, temp, new Quaternion(0, 0, 0, 0));
                }
            }
            if (heroEquipment.equippedBoot == boot.Whirlwind)
            {
                aPlayer.PlayOneShot(whirl);
                oldPos = transform.position;
                once   = true;
                //No ember equipped
                if (heroEquipment.equippedEmber == ember.None)
                {
                    Instantiate(lightWhirl, transform.position, transform.rotation);
                }
                //Ice ember equipped
                else if (heroEquipment.equippedEmber == ember.Ice)
                {
                    Instantiate(iceWhirl, transform.position, transform.rotation);
                }
                //Fire ember equipped
                else if (heroEquipment.equippedEmber == ember.Fire)
                {
                    Instantiate(fireWhirl, transform.position, transform.rotation);
                }
                //Wind ember equipped
                else if (heroEquipment.equippedEmber == ember.Wind)
                {
                    Instantiate(windWhirl, transform.position, transform.rotation);
                }
                //Life ember equipped
                else if (heroEquipment.equippedEmber == ember.Life)
                {
                    Instantiate(lifeWhirl, transform.position, transform.rotation);
                }
                //Death ember equipped
                else if (heroEquipment.equippedEmber == ember.Death)
                {
                    Instantiate(deathWhirl, transform.position, transform.rotation);
                }
                //Earth ember equipped
                else if (heroEquipment.equippedEmber == ember.Earth)
                {
                    Instantiate(earthWhirl, transform.position, transform.rotation);
                }
            }
            if (heroEquipment.equippedBoot == boot.Decoy)
            {
                aPlayer.PlayOneShot(decoy);
                oldPos = transform.position;

                Vector3 temp = (transform.TransformDirection(Vector3.up.normalized));

                controller.Move(temp);

                //No ember equipped
                if (heroEquipment.equippedEmber == ember.None)
                {
                    Instantiate(lightDecoy, oldPos, transform.rotation);
                }
                //Ice ember equipped
                else if (heroEquipment.equippedEmber == ember.Ice)
                {
                    Instantiate(iceDecoy, oldPos, transform.rotation);
                }
                //Fire ember equipped
                else if (heroEquipment.equippedEmber == ember.Fire)
                {
                    Instantiate(fireDecoy, oldPos, transform.rotation);
                }
                //Wind ember equipped
                else if (heroEquipment.equippedEmber == ember.Wind)
                {
                    Instantiate(windDecoy, oldPos, transform.rotation);
                }
                //Life ember equipped
                else if (heroEquipment.equippedEmber == ember.Life)
                {
                    Instantiate(lifeDecoy, oldPos, transform.rotation);
                }
                //Death ember equipped
                else if (heroEquipment.equippedEmber == ember.Death)
                {
                    Instantiate(deathDecoy, oldPos, transform.rotation);
                }
                //Earth ember equipped
                else if (heroEquipment.equippedEmber == ember.Earth)
                {
                    Instantiate(earthDecoy, oldPos, transform.rotation);
                }
            }
        }
        else
        {
            UICD.FlashCooldown(1);
        }
    }