Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public bool allTrashCollected;
- private GameObject throwTrashText;
- private GameObject gainedPointText;
- private GameObject trashCollected;
- public GameObject trash;
- private void Start()
- {
- allTrashCollected = false;
- throwTrashText = GameObject.Find("Main Camera/ExtraUI/ThrowAwayTrash");
- throwTrashText.SetActive(false);
- gainedPointText = GameObject.Find("Main Camera/ExtraUI/SkillPointGained");
- trashCollected = GameObject.Find("Main Camera/OnboardingUI/TrashCollected");
- this.gameObject.GetComponent<BoxCollider2D>().enabled = false;
- }
- private void Update()
- {
- if (FindObjectOfType<EnableTrashEvent>().allBagsCollected == true)
- {
- allTrashCollected = true;
- }
- if (allTrashCollected == true)
- {
- this.gameObject.GetComponent<BoxCollider2D>().enabled = true;
- trashCollected.GetComponent<Animator>().SetBool("WaitingToFind", true);
- }
- if (throwTrashText.activeInHierarchy == true && Input.GetKeyDown(KeyCode.E))
- {
- throwTrashText.SetActive(false);
- allTrashCollected = false;
- FindObjectOfType<EnableTrashEvent>().allBagsCollected = false;
- Points.pointsValue += 1;
- FindObjectOfType<InWorldEvents>().trashCheckmark.SetActive(true);
- FindObjectOfType<PlayerMovement>().trashCollected = true;
- Destroy(throwTrashText);
- gainedPointText.GetComponent<Animator>().SetBool("GainedPoint", true);
- this.gameObject.GetComponent<BoxCollider2D>().enabled = false;
- trash.SetActive(true);
- trash.GetComponent<SpriteRenderer>().enabled = false;
- }
- }
- private void OnTriggerEnter2D(Collider2D col)
- {
- if (col.gameObject.CompareTag("Player"))
- {
- throwTrashText.SetActive(true);
- }
- }
- private void OnTriggerExit2D(Collider2D col)
- {
- if (col.gameObject.CompareTag("Player"))
- {
- throwTrashText.SetActive(false);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement