/// <summary> /// Removes resourceCollected from the character and adds it to its box and updates box and characters labels. /// </summary> void DropOffResources() { mineBoxController.TotalResource += resourceCollected; mineBoxController.UpdateResourceCounterTextMesh(); resourceCollected = 0f; UpdateResourceCounterTextMesh(); }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.transform.tag == "elevator_shaft_top") { DropOffResources(); collectResources = true; ChangeDirection(); } else if (collision.transform.tag == "elevator_shaft_bottom") { collectResources = false; ChangeDirection(); } else if (collision.transform.tag == "mine_trigger" && collectResources) { GameObject mineBoxControllerObj = collision.transform.parent.Find("Mine Box").gameObject; mineBoxController = mineBoxControllerObj.GetComponent <MineboxController>(); CollectResources(); mineBoxController.UpdateResourceCounterTextMesh(); } }