コード例 #1
0
ファイル: momEnemy.cs プロジェクト: EimCode/SpaceImpact2018
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "PlayerProjectile")
        {
            Projectile missile = collision.gameObject.GetComponent <Projectile>();
            player = GameObject.FindWithTag("Player");
            ReceiveDamage(player.GetComponent <Movement>().damage);
            missile.Hit();
        }
        else if (collision.gameObject.tag == "PlasmaBull")
        {
            PlasmaBull missile = collision.gameObject.GetComponent <PlasmaBull>();
            Movement   player  = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>();
            ReceiveDamage(player.damage);
            missile.Hit();
        }
        else if (collision.gameObject.tag == "FlatBull")
        {
            FlatBull missile = collision.gameObject.GetComponent <FlatBull>();
            Movement player  = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>();
            ReceiveDamage(player.damage);
            missile.Hit();
        }
        else if (collision.gameObject.tag == "DefensiveBull")
        {
            DefensiveBull missile = collision.gameObject.GetComponent <DefensiveBull>();
            Movement      player  = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>();
            ReceiveDamage(player.damage);
            missile.Hit();
        }
        else if (collision.gameObject.tag == "RocketBull")
        {
            RocketBull missile = collision.gameObject.GetComponent <RocketBull>();
            Movement   player  = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>();
            ReceiveDamage(player.damage);
            missile.Hit();
        }
        else if (collision.gameObject.tag == "LaserBull")
        {
            LaserBull missile = collision.gameObject.GetComponent <LaserBull>();
            Movement  player  = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>();
            ReceiveDamage(player.damage);
            missile.Hit();
        }
        else if (collision.gameObject.tag == "Player")
        {
            ReceiveDamage(health);
        }

        else if (collision.gameObject.tag == "SpecialMove")
        {
            ReceiveDamage(health);
        }
    }
コード例 #2
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "PlayerProjectile")
     {
         Projectile missile = collision.gameObject.GetComponent <Projectile>();
         healthSlider.value -= missile.GetDamage();
         hitPoints          -= missile.GetDamage();
         missile.Hit();
     }
     else if (collision.gameObject.tag == "PlasmaBull")
     {
         PlasmaBull missile = collision.gameObject.GetComponent <PlasmaBull>();
         healthSlider.value -= missile.GetDamage();
         hitPoints          -= missile.GetDamage();
         missile.Hit();
     }
     else if (collision.gameObject.tag == "FlatBull")
     {
         FlatBull missile = collision.gameObject.GetComponent <FlatBull>();
         healthSlider.value -= missile.GetDamage();
         hitPoints          -= missile.GetDamage();
         missile.Hit();
     }
     else if (collision.gameObject.tag == "RocketBull")
     {
         RocketBull missile = collision.gameObject.GetComponent <RocketBull>();
         healthSlider.value -= missile.GetDamage();
         hitPoints          -= missile.GetDamage();
         missile.Hit();
     }
     else if (collision.gameObject.tag == "LaserBull")
     {
         LaserBull missile = collision.gameObject.GetComponent <LaserBull>();
         healthSlider.value -= missile.GetDamage();
         hitPoints          -= missile.GetDamage();
         Destroy(missile);
     }
     else if (collision.gameObject.tag == "SpecialMove")
     {
         healthSlider.value -= specialAttackDmg;
         hitPoints          -= specialAttackDmg;
         dealDamage          = true;
     }
 }
コード例 #3
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "PlayerProjectile")
     {
         Projectile missile = collision.gameObject.GetComponent <Projectile>();
         ReceiveDamage(player.GetComponent <Movement>().damage);
         missile.Hit();
     }
     else if (collision.gameObject.tag == "PlasmaBull")
     {
         PlasmaBull missile = collision.gameObject.GetComponent <PlasmaBull>();
         Movement   player  = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>();
         ReceiveDamage(player.damage);
         missile.Hit();
     }
     else if (collision.gameObject.tag == "FlatBull")
     {
         FlatBull missile = collision.gameObject.GetComponent <FlatBull>();
         Movement player  = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>();
         ReceiveDamage(player.damage);
         missile.Hit();
     }
     else if (collision.gameObject.tag == "DefensiveBull")
     {
         DefensiveBull missile = collision.gameObject.GetComponent <DefensiveBull>();
         Movement      player  = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>();
         Destroy();
         missile.Hit();
     }
     else if (collision.gameObject.tag == "LaserBull")
     {
         LaserBull missile = collision.gameObject.GetComponent <LaserBull>();
         Movement  player  = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>();
         Destroy();
     }
     else if (collision.gameObject.tag == "RocketBull")
     {
         RocketBull missile = collision.gameObject.GetComponent <RocketBull>();
         Movement   player  = GameObject.FindGameObjectWithTag("Player").GetComponent <Movement>();
         ReceiveDamage(player.damage);
         missile.Hit();
     }
     else if (collision.gameObject.tag == "Player")
     {
         ReceiveDamage(health);
     }
     else if (collision.gameObject.tag == "SpecialMove")
     {
         ReceiveDamage(health);
     }
     if (health <= 0)
     {
         FindObjectOfType <Movement>().IncreasePoints(pointsDropped);
         Slider test = GameObject.FindGameObjectWithTag("ChargeBar").GetComponent <Slider>();
         test.value += chargeBarValue;
         explosionPooler.GetPooledObject(transform.position, transform.rotation);
         Destroy();
         if (Random.Range(1f, 100f) <= 20f)
         {
             Vector3 position = transform.position + new Vector3(0f, -0.8f);
             Instantiate(Drop1, position, transform.rotation);
         }
         if (Random.Range(1f, 100f) > 95f)
         {
             Vector3 position = transform.position + new Vector3(0f, -0.8f);
             Instantiate(TripleShot, position, TripleShot.transform.rotation);
         }
     }
 }