コード例 #1
0
    // Update is called once per frame
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary")
        {
            return;
        }

        if (explosion != null)
        {
            Instantiate(explosion, transform.position, transform.rotation);
        }

        if (other.tag == "Player")
        {
            player = other.gameObject;
            int    pHealth  = other.GetComponent <PlayerHealth>().playerHealth;
            int    pShield  = other.GetComponent <PlayerHealth>().playerShield;
            int    pArmor   = other.GetComponent <PlayerHealth>().playerArmor;
            double pMit     = other.GetComponent <PlayerHealth>().playerShieldMitigation;
            float  mPercent = (float)(100 - pMit) / 100;

            int hDamage = gameController.GetComponent <WeaponDamages>().healthDamage;
            int sDamage = gameController.GetComponent <WeaponDamages>().shieldDamage;

            if (this.gameObject.name == "BH_Bolt-Enemy(Clone)")
            {
                hDamage = gameController.GetComponent <WeaponDamages>().bossDamage;
                sDamage = gameController.GetComponent <WeaponDamages>().bossDamage;
            }

            if (this.gameObject.name == "Big_Bolt-Enemy(Clone)")
            {
                hDamage = gameController.GetComponent <WeaponDamages>().bossBigDamage;
                sDamage = gameController.GetComponent <WeaponDamages>().bossBigDamage;
            }

            if (pShield > 0)
            {
                other.GetComponent <PlayerHealth>().playerShield -= Mathf.RoundToInt(sDamage * mPercent);
            }
            else
            {
                other.GetComponent <PlayerHealth>().playerHealth -= (hDamage - pArmor);
            }

            if (other.GetComponent <PlayerHealth>().playerHealth <= 0)
            {
                //Destroy(other.gameObject);
                Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
                //gameController.GameOver("player");
            }

            Destroy(gameObject);
        }
    }
コード例 #2
0
 void Start()
 {
     startPosition = transform.position;
     gamecon       = gamecon.GetComponent <Done_GameController>();
 }
コード例 #3
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary" || other.tag == "Enemy")
        {
            return;
        }

        if (explosion != null)
        {
            Instantiate(explosion, transform.position, transform.rotation);
            Destroy(gameObject);
        }

        if (other.tag == "Player")
        {
            player = other.gameObject;
            int    pHealth  = other.GetComponent <PlayerHealth>().playerHealth;
            int    pShield  = other.GetComponent <PlayerHealth>().playerShield;
            int    pArmor   = other.GetComponent <PlayerHealth>().playerArmor;
            double pMit     = other.GetComponent <PlayerHealth>().playerShieldMitigation;
            float  mPercent = (float)(100 - pMit) / 100;



            int hDamage = gameController.GetComponent <WeaponDamages>().healthDamage;
            int sDamage = gameController.GetComponent <WeaponDamages>().shieldDamage;

            Component playerScript = other.GetComponent <PlayerHealth>();

            if (pShield > 0)
            {
                other.GetComponent <PlayerHealth>().playerShield -= Mathf.RoundToInt(sDamage * mPercent);
            }
            else
            {
                other.GetComponent <PlayerHealth>().playerHealth -= (hDamage - pArmor);
            }

            if (other.GetComponent <PlayerHealth>().playerHealth <= 0)
            {
                //Destroy(other.gameObject);
                Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
                //gameController.GameOver("player");
            }
            Destroy(gameObject);
        }

        if (other.tag == "Boss")
        {
            boss = other.gameObject;
            int pHealth = other.GetComponent <BossHealth>().bossHealth;
            int pArmor  = other.GetComponent <BossHealth>().bossArmor;

            int hDamage = gameController.GetComponent <WeaponDamages>().playerDamage;

            if (boss.GetComponent <BossMover>().isLoading == false)
            {
                other.GetComponent <BossHealth>().bossHealth -= (hDamage - pArmor);
            }

            if (other.GetComponent <BossHealth>().bossHealth <= 0)
            {
                //Destroy(other.gameObject);
                Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
                //gameController.GameOver("null");
            }
            Destroy(gameObject);
        }

        gameController.AddScore(scoreValue);

        if (other.tag != "Player" && other.tag != "Boss")
        {
            Destroy(other.gameObject);
            Destroy(gameObject);
        }
    }