Example #1
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag("Player"))
     {
         visibility.setPlayerVisible(false);
         Debug.Log("Player in range");
     }
 }
Example #2
0
 void Update()
 {
     if (!haunted)
     {
         if (playerInRange && Input.GetButton("Interact"))
         {
             if (hauntAmount >= hauntTime)
             {
                 AudioManager.PlaySound("haunt");
                 slider.gameObject.SetActive(false);
                 haunted = true;
                 playerMovement.setCanMove(false);
                 playerVisibility.setPlayerVisible(false);
                 playerMovement.setCanMove(false);
                 camControl.ChangeTarget(transform, offsetScale);
                 playerCollision.enabled = false;
                 player.GetComponent <SpriteRenderer>().color = new Color(0, 0, 0, 0); //TEMP to make player "invisible"
                 SwitchDimension();
             }
             else
             {
                 slider.gameObject.SetActive(true);
                 hauntAmount += Time.deltaTime;
                 slider.value = hauntAmount / hauntTime;
             }
         }
         else if (hauntAmount > 0f)
         {
             hauntAmount = 0f;
             slider.gameObject.SetActive(false);
         }
     }
     else
     {
         if (!Input.GetButton("Interact"))
         {
             AudioManager.PlaySound("dehaunt");
             hauntAmount = 0f;
             haunted     = false;
             playerVisibility.setPlayerVisible(true);
             playerMovement.setCanMove(true);
             camControl.ChangeTarget(player.transform, 1f);
             playerCollision.enabled = true;
             player.GetComponent <SpriteRenderer>().color = Color.white; //TEMP to make player visible again
             SwitchDimension();
         }
         else
         {
             Interact();
         }
     }
 }