Advertisement
jretchy

Untitled

May 17th, 2022
566
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.15 KB | None | 0 0
  1.  
  2.     public bool allTrashCollected;
  3.  
  4.     private GameObject throwTrashText;
  5.     private GameObject gainedPointText;
  6.  
  7.     private GameObject trashCollected;
  8.  
  9.     public GameObject trash;
  10.  
  11.     private void Start()
  12.     {
  13.         allTrashCollected = false;
  14.  
  15.         throwTrashText = GameObject.Find("Main Camera/ExtraUI/ThrowAwayTrash");
  16.         throwTrashText.SetActive(false);
  17.  
  18.         gainedPointText = GameObject.Find("Main Camera/ExtraUI/SkillPointGained");
  19.  
  20.         trashCollected = GameObject.Find("Main Camera/OnboardingUI/TrashCollected");
  21.  
  22.         this.gameObject.GetComponent<BoxCollider2D>().enabled = false;
  23.     }
  24.  
  25.     private void Update()
  26.     {
  27.         if (FindObjectOfType<EnableTrashEvent>().allBagsCollected == true)
  28.         {
  29.             allTrashCollected = true;
  30.         }
  31.  
  32.  
  33.         if (allTrashCollected == true)
  34.         {
  35.             this.gameObject.GetComponent<BoxCollider2D>().enabled = true;
  36.             trashCollected.GetComponent<Animator>().SetBool("WaitingToFind", true);
  37.         }
  38.  
  39.  
  40.         if (throwTrashText.activeInHierarchy == true && Input.GetKeyDown(KeyCode.E))
  41.         {
  42.             throwTrashText.SetActive(false);
  43.             allTrashCollected = false;
  44.             FindObjectOfType<EnableTrashEvent>().allBagsCollected = false;
  45.  
  46.             Points.pointsValue += 1;
  47.             FindObjectOfType<InWorldEvents>().trashCheckmark.SetActive(true);
  48.  
  49.             FindObjectOfType<PlayerMovement>().trashCollected = true;
  50.  
  51.             Destroy(throwTrashText);
  52.  
  53.             gainedPointText.GetComponent<Animator>().SetBool("GainedPoint", true);
  54.  
  55.             this.gameObject.GetComponent<BoxCollider2D>().enabled = false;
  56.  
  57.             trash.SetActive(true);
  58.             trash.GetComponent<SpriteRenderer>().enabled = false;
  59.         }
  60.     }
  61.  
  62.     private void OnTriggerEnter2D(Collider2D col)
  63.     {
  64.         if (col.gameObject.CompareTag("Player"))
  65.         {
  66.             throwTrashText.SetActive(true);
  67.         }
  68.     }
  69.  
  70.     private void OnTriggerExit2D(Collider2D col)
  71.     {
  72.         if (col.gameObject.CompareTag("Player"))
  73.         {
  74.             throwTrashText.SetActive(false);
  75.         }
  76.     }
  77.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement