Example #1
0
    public void Ring(InvisibleMan target)
    {
        //if the alarm isn't already sounding, it will ring
        if (!alarmSound.isPlaying)
        {
            alarmSound.Play();
        }

        //make the target invisible man chase the alarm
        target.destination = this;

        //make a list of who's chasing the alarm so we can send them back to their own tracks later
        peopleChasingThisAlarm.Add(target);
    }
Example #2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        InvisibleMan invis = collision.GetComponent <InvisibleMan>();

        if (invis != null)
        {
            //the destination will only be changed if the colliding object is an invisible man AND this destination is the intended destination
            if (invis.destination == this)
            {
                invis.destination           = GetNextDestination();
                invis.persistentDestination = invis.destination;
            }
        }
    }
Example #3
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        //if something enters collision with this gameobject, check if it's a person
        InvisibleMan invisMan = collision.GetComponent <InvisibleMan>();

        //if the person game object exists, then make them leave prints
        if (invisMan != null)
        {
            if (!invisMan.caught)
            {
                StartCoroutine(invisMan.StartBeingPainted());
            }
        }
    }
Example #4
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        //when touched by an invisible person, this alarm will brea

        InvisibleMan iv = collision.GetComponent <InvisibleMan>();

        //the alarm will ring when invisible people are near and if it's not broken
        if (iv != null && !isBroken)
        {
            isBroken = true;
            alarmSound.Stop();
            breakSound.Play();
            mySprite.sprite = brokenSprite;
            foreach (InvisibleMan man in peopleChasingThisAlarm)
            {
                man.destination = man.persistentDestination;
            }
        }
    }
    private void OnTriggerStay2D(Collider2D collision)
    {
        string[] masks   = { "hazards", "activeradii", "waypoint" };
        int      masking = LayerMask.GetMask(masks);
        //print(masking + " " + ~masking);
        //masking = ~masking;

        //print(LayerMask.NameToLayer("hazards") + " " + LayerMask.NameToLayer("activeradii"));

        RaycastHit2D hit = Physics2D.Linecast(transform.position, collision.transform.position, ~masking);
        //print(hit.collider);
        //print(hit.transform.position);
        InvisibleMan iv = hit.collider.GetComponent <InvisibleMan>();

        //the alarm will ring when invisible people are near and if it's not broken
        if (iv != null && !attachedAlarm.isBroken)
        {
            attachedAlarm.Ring(iv);
        }
    }
    private void OnCollisionEnter2D(Collision2D collision)
    {
        InvisibleMan target = collision.collider.GetComponent <InvisibleMan>();

        if (target != null)
        {
            rb2d.velocity = Vector2.zero;
            target.caught = true;
            collision.collider.attachedRigidbody.velocity = Vector2.zero;
            target.GetComponent <SpriteRenderer>().color  = target.caughtColor;
            EnemyCapturedDelegate();
        }

        if (!alreadyHit)
        {
            Instantiate(GameManager.s_gamePickups[1], transform.position, transform.rotation);
        }

        alreadyHit = true;

        Destroy(gameObject);
    }