private void Update() { distanceToHand = Vector3.Distance(raccoonArm.transform.position, transform.position); if (distanceToHand < reachRange) { if (Input.GetKeyDown(KeyCode.Space)) { CollectTrash(); DeactivateTrash(); scorekeeper.addScore(scoreValue); //add to the trash collected per type table if (scorekeeper.trashCollected.ContainsKey(myType)) //does the table already contain data for my trash type? { //if yes, add to the type's record scorekeeper.trashCollected[myType] += 1; } else { //if no, add the key to the record and initialize with 1 scorekeeper.trashCollected.Add(myType, 1); } } } }
void OnTriggerEnter2D(Collider2D other) { Cursor.visible = true; if (other.gameObject == player) { movingArm.GetComponent <FaceMouse>().enabled = false; scorekeeper.addScore(100); SuccessScreen.SetActive(true); Time.timeScale = 0; } }