示例#1
0
    public void OnTriggerEnter2D(Collider2D collider)
    {
        GameObject effect = Instantiate(hitEffect);

        effect.transform.position = transform.position;

        GameObject other = collider.gameObject;

        if (other.tag == "Bomb")
        {
            Bomb bomb = other.GetComponent <Bomb>();
            bomb.Explode();
        }
        else if (other.tag == "Plane")
        {
            Triplane plane = other.GetComponent <Triplane>();
            plane.Hurt(Damage);
            GooseAI ai = other.GetComponent <GooseAI>();
            if (ai != null)
            {
                ai.Hurt();
            }
        }

        Kill();
    }
示例#2
0
    void OnCollisionEnter2D(Collision2D collision2D)
    {
        GameObject other = collision2D.collider.gameObject;

        if (other.tag == "Plane")
        {
            Triplane plane = other.GetComponent <Triplane>();
            plane.Hurt(1000);
        }
        Explode();
    }
示例#3
0
    // Start is called before the first frame update
    void Start()
    {
        throttle          = 12f;
        engineSoundSource = GetComponent <AudioSource>();
        if (engineSoundSource != null)
        {
            originalEngineSoundvolume = engineSoundSource.volume;
        }
        body     = GetComponent <Rigidbody2D>();
        triplane = GetComponentInChildren <Triplane>();

        GameObject  world    = GameObject.FindWithTag("WorldConfines");
        BoxCollider collider = world.GetComponent <BoxCollider>();
        float       width    = world.transform.localScale.x * collider.size.x;
        float       height   = world.transform.localScale.y * collider.size.y;
        float       centerx  = world.transform.localScale.x * collider.center.x;
        float       centery  = world.transform.localScale.y * collider.center.y;

        worldMin = new Vector2(world.transform.position.x + centerx - width / 2, world.transform.position.y + centery - height / 2);
        worldMax = new Vector2(world.transform.position.x + centerx + width / 2, world.transform.position.y + centery + height / 2);

        GROUND = LayerMask.NameToLayer("Ground");
    }