Skip to content
Snippets Groups Projects
Select Git revision
  • 432e8d9f53c24db5aca2ec19a6b331dda30d69b9
  • main default protected
  • save-debug2
  • save-debug
  • pet-v2
  • febrr/weapon
  • v1.3
  • v1.2
  • v1.1
  • v1.0
10 results

ShopColliderDetection.cs

Blame
  • ShopColliderDetection.cs 1019 B
    using UnityEngine;
    using TMPro;
    using System.Collections;
    
    public class ColliderChecker : MonoBehaviour
    {
        public GameObject shopKeeper;
        public Canvas shopInstructionCanvas;
        public TMP_Text instructionText;
        public SaveRadius saveRadius;
    
        void Update()
        {
            // Check if the targetObject is within the collider of this GameObject
            if (!GetComponent<Collider>().bounds.Intersects(shopKeeper.GetComponent<SphereCollider>().bounds))
            {
                if ((Input.GetKeyDown(KeyCode.Z) || Input.GetButton("X Button")) && Time.timeScale == 1 && !saveRadius.playerInRange)
                {
                    StartCoroutine(ErrorMessage());
                }
            }
        }
    
        IEnumerator ErrorMessage()
        {
            instructionText.text = "Shop is out of range";
            shopInstructionCanvas.gameObject.SetActive(true);
    
            yield return new WaitForSeconds(2f);
    
            shopInstructionCanvas.gameObject.SetActive(false);
            instructionText.text = "Press Z to open the shop";
        }
    }