void Start() { _effect = new ConsumableEffect(transform.parent.transform.parent.Find("ConsumableList").transform); _consumablePlayerUI = transform.parent.transform.parent.Find("UI").Find("Consumable").GetComponent <ConsumableUI>(); _playerTransform = transform.parent.transform; _playerAnimator = transform.parent.GetComponent <Animator>(); }
void OnTriggerEnter2D(Collider2D other) { if (!other.CompareTag("Player")) { return; } ConsumableUI consumablePlayerUI = other.transform.parent.Find("UI").Find("Consumable").GetComponent <ConsumableUI>(); UseConsumable consumablePlayer = other.transform.Find("UseConsumable").GetComponent <UseConsumable>(); if (consumablePlayerUI.ConsumableExist()) { return; } int consumable = _GenerateConsumable(); consumablePlayerUI.AddConsumable(consumable); consumablePlayer.SetConsumable(consumable); _SetUsedSprite(); Destroy(GetComponent <BoxCollider2D>()); }