//----------------------------------Enemy Taking Damage-------------------

    void OnTriggerEnter(Collider collider)
    {
        //Damage Animations

        enemyDamageAnimation = EnemyHealthScript.FindObjectOfType <EnemyHealthScript> ();



        blueplasmalaserDamage = bluePlasmaLaser.FindObjectOfType <bluePlasmaLaser>();
        bluePlasmaLaser plasma = collider.gameObject.GetComponent <bluePlasmaLaser>();

        basicLaserDamage = BasicLaserScript.FindObjectOfType <BasicLaserScript>();
        BasicLaserScript laser = collider.gameObject.GetComponent <BasicLaserScript>();

        shielddeflectorenergy = ShieldDeflectorEnergyBackScript.FindObjectOfType <ShieldDeflectorEnergyBackScript>();
        ShieldDeflectorEnergyBackScript shieldDeflectEnergy = collider.gameObject.GetComponent <ShieldDeflectorEnergyBackScript>();

        electricBoltDamage = ElectricBoltScript.FindObjectOfType <ElectricBoltScript> ();
        ElectricBoltScript electricBolt = collider.gameObject.GetComponent <ElectricBoltScript> ();

        Vector3 playerHitPos = collider.transform.position;



        float chanceEnemyHit = Random.Range(1, 100);

        if (EnemyHealth <= 0)
        {
            playercontroller.playerAnimator.SetBool("Evade", false);


            collider.enabled = false;
        }



        if (shieldDeflectEnergy && chanceEnemyHit < playerAccuracy)
        {
            enemyDamageAnimation.ReceiveDamage(shielddeflectorenergy.damage);



            Destroy(collider.gameObject);
            GameObject deflectenergyimpact = Instantiate(ShieldDeflectImpact, playerHitPos, Quaternion.identity) as GameObject;

            xp.GainXP(10);
            //smoke.SetActive(true);
            EnemyHealth = EnemyHealth - shielddeflectorenergy.damage * deflectorDamage;
            Debug.Log("Enemy health is " + EnemyHealth);
            //battlecontroller.enemyText.text = "Health: " + EnemyHealth;

            //SMOKE GRAPHICS
            if (EnemyHealth == 80)
            {
                Vector3    startPostion = transform.position + new Vector3(2, 2, 0);
                GameObject smokeHit     = Instantiate(smoke, playerHitPos, Quaternion.identity) as GameObject;
            }

            if (EnemyHealth == 60)
            {
                Vector3    startPostion = transform.position + new Vector3(0, 0, 0);
                GameObject bigExplosi   = Instantiate(bigExplosion, startPostion, Quaternion.identity) as GameObject;
            }


            if (EnemyHealth < 20)
            {
                Vector3    startPostion = transform.position + new Vector3(0, -.38f, 0.47f);
                GameObject smokeLot     = Instantiate(lotSmoke, startPostion, Quaternion.identity) as GameObject;
                smokeLot.transform.parent = gameObject.transform;
            }

            if (EnemyHealth <= 0)
            {
                EnemyShip.SetActive(false);
                Vector3    startPostion   = transform.position + new Vector3(0, 0, 0);
                GameObject deathexplosion = Instantiate(DeadExplosion, startPostion, Quaternion.identity) as GameObject;
                playercontroller.enemyIsDead = true;
                Character.Credits            = Character.Credits + 100;
                PlayerPrefs.SetInt("PLAYER_CREDITS", Character.Credits);
                xp.UpdateDisplay();
                //xp.GainXP(100);
                Invoke("EnemyDead", 6);
            }
        }


        if (plasma && chanceEnemyHit < playerAccuracy)
        {
            enemyDamageAnimation.ReceiveDamage(blueplasmalaserDamage.damage);



            Debug.Log("EnemyShip hit by plasma");

            Destroy(collider.gameObject);
            //PLASMA IMPACT
            GameObject plas = Instantiate(PlasmaLaserImpact, playerHitPos, Quaternion.identity) as GameObject;

            xp.GainXP(10);
            //smoke.SetActive(true);
            EnemyHealth = EnemyHealth - blueplasmalaserDamage.damage;
            Debug.Log("Enemy health is " + EnemyHealth);
            //battlecontroller.enemyText.text = "Health: " + EnemyHealth;

            //SMOKE GRAPHICS
            if (EnemyHealth == 80)
            {
                Vector3    startPostion = transform.position + new Vector3(2, 2, 0);
                GameObject smokeHit     = Instantiate(smoke, playerHitPos, Quaternion.identity) as GameObject;
            }

            if (EnemyHealth == 60)
            {
                Vector3    startPostion = transform.position + new Vector3(0, 0, 0);
                GameObject bigExplosi   = Instantiate(bigExplosion, startPostion, Quaternion.identity) as GameObject;
            }
            if (EnemyHealth < 20)
            {
                Vector3    startPostion = transform.position + new Vector3(0, -.38f, 0.47f);
                GameObject smokeLot     = Instantiate(lotSmoke, startPostion, Quaternion.identity) as GameObject;
                smokeLot.transform.parent = gameObject.transform;
            }

            if (EnemyHealth <= 0)
            {
                EnemyShip.SetActive(false);
                Vector3    startPostion   = transform.position + new Vector3(0, 0, 0);
                GameObject deathexplosion = Instantiate(DeadExplosion, startPostion, Quaternion.identity) as GameObject;
                playercontroller.enemyIsDead = true;
                Character.Credits            = Character.Credits + 100;
                PlayerPrefs.SetInt("PLAYER_CREDITS", Character.Credits);
                xp.UpdateDisplay();
                //xp.GainXP(100);
                Invoke("EnemyDead", 6);
            }
        }


        if (laser && chanceEnemyHit < playerAccuracy)
        {
            enemyDamageAnimation.ReceiveDamage(basicLaserDamage.damage);



            Debug.Log("EnemyShip hit by laser");

            Destroy(collider.gameObject);
            //LAserIMPACT
            GameObject bLImpact = Instantiate(BlueLaserImpact, playerHitPos, Quaternion.identity) as GameObject;

            xp.GainXP(10);
            //smoke.SetActive(true);
            EnemyHealth = EnemyHealth - basicLaserDamage.damage;
            Debug.Log("Enemy health is " + EnemyHealth);
            //battlecontroller.enemyText.text = "Health: " + EnemyHealth;

            //SMOKE GRAPHICS
            if (EnemyHealth == 80)
            {
                Vector3    startPostion = transform.position + new Vector3(2, 2, 0);
                GameObject smokeHit     = Instantiate(smoke, startPostion, Quaternion.identity) as GameObject;
            }

            if (EnemyHealth == 60)
            {
                Vector3    startPostion = transform.position + new Vector3(0, 0, 0);
                GameObject bigExplosi   = Instantiate(bigExplosion, startPostion, Quaternion.identity) as GameObject;
            }
            if (EnemyHealth < 20)
            {
                Vector3    startPostion = transform.position + new Vector3(0, -.38f, 0.47f);
                GameObject smokeLot     = Instantiate(lotSmoke, startPostion, Quaternion.identity) as GameObject;
                smokeLot.transform.parent = gameObject.transform;
            }

            if (EnemyHealth <= 0)
            {
                if (PlayerPrefs.GetString("WHOS_ATTACKING") == "NGC1300BOSS")
                {
                    EnemyShip.SetActive(false);
                    Vector3    startPostion   = transform.position + new Vector3(0, 0, 0);
                    GameObject deathexplosion = Instantiate(DeadExplosion, startPostion, Quaternion.identity) as GameObject;
                    playercontroller.enemyIsDead = true;
                    Character.Credits            = Character.Credits + 100;
                    PlayerPrefs.SetInt("PLAYER_CREDITS", Character.Credits);
                    xp.UpdateDisplay();
                    //xp.GainXP(100);
                    Invoke("BossEnemyDead", 6);
                }
                EnemyShip.SetActive(false);
                Vector3    startPostion2   = transform.position + new Vector3(0, 0, 0);
                GameObject deathexplosion2 = Instantiate(DeadExplosion, startPostion2, Quaternion.identity) as GameObject;
                playercontroller.enemyIsDead = true;
                Character.Credits            = Character.Credits + 100;
                PlayerPrefs.SetInt("PLAYER_CREDITS", Character.Credits);
                xp.UpdateDisplay();
                //xp.GainXP(100);
                DropItem.DROPITEM = 1;
                Invoke("EnemyDead", 6);
            }
        }


        if (electricBolt && chanceEnemyHit < playerAccuracy)
        {
            enemyDamageAnimation.ReceiveDamage(electricBoltDamage.damage);



            Debug.Log("EnemyShip hit by plasma");

            Destroy(collider.gameObject);
            //Electric Bolt IMPACT
            GameObject electricImpact = Instantiate(ElectricBoltImpact, playerHitPos, Quaternion.identity) as GameObject;

            xp.GainXP(10);
            //smoke.SetActive(true);
            EnemyHealth = EnemyHealth - electricBoltDamage.damage;
            Debug.Log("Enemy health is " + EnemyHealth);
            playercontroller.evade = 100f;
            //battlecontroller.enemyText.text = "Health: " + EnemyHealth;

            //SMOKE GRAPHICS
            if (EnemyHealth == 80)
            {
                Vector3    startPostion = transform.position + new Vector3(2, 2, 0);
                GameObject smokeHit     = Instantiate(smoke, startPostion, Quaternion.identity) as GameObject;
            }

            if (EnemyHealth == 60)
            {
                Vector3    startPostion = transform.position + new Vector3(0, 0, 0);
                GameObject bigExplosi   = Instantiate(bigExplosion, startPostion, Quaternion.identity) as GameObject;
            }
            if (EnemyHealth < 20)
            {
                Vector3    startPostion = transform.position + new Vector3(0, -.38f, 0.47f);
                GameObject smokeLot     = Instantiate(lotSmoke, startPostion, Quaternion.identity) as GameObject;
                smokeLot.transform.parent = gameObject.transform;
            }

            if (EnemyHealth <= 0)
            {
                EnemyShip.SetActive(false);
                Vector3 startPostion = transform.position + new Vector3(0, 0, 0);
                xp.GainXP(50);

                GameObject deathexplosion = Instantiate(DeadExplosion, startPostion, Quaternion.identity) as GameObject;
                playercontroller.enemyIsDead = true;

                PlayerPrefs.SetInt("PLAYER_CREDITS", Character.Credits);
                xp.UpdateDisplay();
                //xp.GainXP(100);
                Invoke("EnemyDead", 6);
            }
        }
    }