コード例 #1
0
    void OnTriggerEnter(Collider collider)
    {
        bluePlasmaDamage = bluePlasmaLaser.FindObjectOfType <bluePlasmaLaser>();
        bluePlasmaLaser plasma = collider.gameObject.GetComponent <bluePlasmaLaser>();

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

        shieldDeflectorEnergyDamage = 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 (shieldDeflectEnergy && chanceEnemyHit < playerAccuracy)
        {
            Destroy(collider.gameObject);
            GameObject deflectenergyimpact = Instantiate(ShieldDeflectImpact, playerHitPos, Quaternion.identity) as GameObject;

            //xp.GainXP(10);
            //smoke.SetActive(true);
            EnemyHealth = EnemyHealth - shieldDeflectorEnergyDamage.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, 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 (plasma && chanceEnemyHit < playerAccuracy)
        {
            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 - bluePlasmaDamage.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 (laser && chanceEnemyHit < playerAccuracy)
        {
            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 (electricBolt && chanceEnemyHit < playerAccuracy)
        {
            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;
            }


            //	playerController.playerAnimator.SetBool ("Evade", false);


            //Invoke ("ThisEnemyDead", 2f);
        }

        if (EnemyHealth <= 0)
        {
            thisShip.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;
            xp.GainXP(100);
            PlayerPrefs.SetInt("PLAYER_CREDITS", Character.Credits);
            xp.UpdateDisplay();
            //xp.GainXP(100);
            numberOfAttackers = numberOfAttackers - 1;
            playerController.playerAnimator.SetBool("Evade", false);

            thisAiDead = true;


            if (numberOfAttackers == 0)
            {
                Invoke("EnemyDead", 3f);
            }

            //Invoke ("ThisEnemyDead", 2f);
        }
    }
コード例 #2
0
//----------------------------------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);
            }
        }
    }
コード例 #3
0
    //----------------------------------Enemy Taking Damage-------------------

    void OnTriggerEnter(Collider collider)
    {
        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>();



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



        if (shieldDeflectEnergy && chanceEnemyHit > 50)
        {
            Destroy(collider.gameObject);
            Vector3    startPostionDeflectImpact = EnemyShip.transform.position + new Vector3(0, 0, 0);
            GameObject deflectenergyimpact       = Instantiate(ShieldDeflectImpact, startPostionDeflectImpact, Quaternion.identity) as GameObject;

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

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

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

            if (EnemyHealth <= 0)
            {
                EnemyShip.SetActive(false);
                Vector3    startPostion   = EnemyShip.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 > 50)
        {
            Debug.Log("EnemyShip hit by plasma");

            Destroy(collider.gameObject);
            //PLASMA IMPACT
            Vector3    plasmaImpactPostion = EnemyShip.transform.position + new Vector3(2, 2, 0);
            GameObject plas = Instantiate(PlasmaLaserImpact, plasmaImpactPostion, 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 = EnemyShip.transform.position + new Vector3(2, 2, 0);
                GameObject smokeHit     = Instantiate(smoke, startPostion, Quaternion.identity) as GameObject;
            }

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

            if (EnemyHealth <= 0)
            {
                EnemyShip.SetActive(false);
                Vector3    startPostion   = EnemyShip.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 > 50)
        {
            Debug.Log("EnemyShip hit by laser");

            Destroy(collider.gameObject);
            //LAserIMPACT
            Vector3    laserimpactPostion = EnemyShip.transform.position + new Vector3(2, 2, 0);
            GameObject bLImpact           = Instantiate(BlueLaserImpact, laserimpactPostion, 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 = EnemyShip.transform.position + new Vector3(2, 2, 0);
                GameObject smokeHit     = Instantiate(smoke, startPostion, Quaternion.identity) as GameObject;
            }

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

            if (EnemyHealth <= 0)
            {
                EnemyShip.SetActive(false);
                Vector3    startPostion   = EnemyShip.transform.position + new Vector3(0, 0, 0);
                GameObject deathexplosion = Instantiate(DeadExplosion, startPostion, Quaternion.identity) as GameObject;
                deathexplosion.transform.parent = gameObject.transform;

                playercontroller.enemyIsDead = true;
                Character.Credits            = Character.Credits + 100;
                PlayerPrefs.SetInt("PLAYER_CREDITS", Character.Credits);
                xp.UpdateDisplay();
                PlayerPrefs.SetInt("BOSS_FIGHT_NGC1300_DONE", 1);
                //xp.GainXP(100);
                Invoke("EnemyDead", 6);
            }
        }
    }