void DestroyAfterDuration()
 {
     if (!buttonPressed)
     {
         duration -= Time.deltaTime;
         if (duration < 0)
         {
             ResetGravity(0);
             emitter.Stop();
             Destroy(gameObject);
         }
     }
 }
Exemplo n.º 2
0
    private void Hide()
    {
        if (!hidden)
        {
            // Change to Show Picture 2
            sr.sprite = stateTwo;

            if (HideOnInteraction)
            {
                GetComponent <SpriteRenderer>().enabled = false;
            }


            if (Sounds)
            {
                myAudio.Stop();
                myAudio.SetEvent(deActivationEvent);
                myAudio.Play();
            }
            hidden = true;
        }
    }
Exemplo n.º 3
0
    void Update()
    {
        PullOrPush();

        Physics2D.queriesStartInColliders = false;
        RaycastHit2D hit = Physics2D.Raycast(rayLine, Vector2.right * transform.localScale.x, distance);

        if (!flip)
        {
            if (playerController.player == Controller.Player1)
            {
                rayLine = new Vector2(transform.position.x, transform.position.y - 1f);
            }
            else
            {
                rayLine = new Vector2(transform.position.x, transform.position.y + 1.5f);
            }
        }
        else
        {
            if (playerController.player == Controller.Player2)
            {
                rayLine = new Vector2(transform.position.x, transform.position.y - 1.5f);
            }
            else
            {
                rayLine = new Vector2(transform.position.x, transform.position.y + 1f);
            }
        }

        if (hit.collider != null && hit.collider.gameObject.tag == tagName && (hit.collider.GetComponent <OverEdgeFalling>() != null) &&
            !playerController.inAir)
        {
            if (hit.transform.GetComponent <DisplayIconTrigger>() != null && !isPulling && hit.transform.GetComponent <OverEdgeFalling>().IsGrounded())
            {
                hit.transform.GetComponent <DisplayIconTrigger>().SetShowIcon(true);
            }

            if (Input.GetKeyDown(KeyCode.G) || Input.GetButtonDown(pushAndPullBox))
            {
                if (hit.collider.GetComponent <OverEdgeFalling>().IsGrounded())
                {
                    box = hit.collider.gameObject;
                    StartDragging();

                    if (hit.transform.GetComponent <DisplayIconTrigger>() != null)
                    {
                        hit.transform.GetComponent <DisplayIconTrigger>().SetShowIcon(false);
                    }
                }
            }
        }
        else if ((Input.GetKeyUp(KeyCode.G) || Input.GetButtonUp(pushAndPullBox)) && isPulling || (isPulling && playerController.inAir))
        {
            StopDragging();
        }
        if (!isPulling)
        {
            playerController.pulling = false;
            emitter.Stop();

            body.Pull(false);
            arm.Pull(false);

            body.Push(false);
            arm.Push(false);
        }
    }