private void OnTriggerStay2D(Collider2D collision) { if (collision.CompareTag("Npc")) { CpuInventory cpuInventory = collision.GetComponent <CpuInventory>(); cpuInventory.ShowInventory(); } }
public void HideActualCpuInventory() { if (_cpuInventory != null) { _cpuInventory.HideIventory(); _cpuInventory = null; this.gameObject.SetActive(false); } }
void Update() { if (cpuInventoryUi != null) { CpuInventory cpuInventory = cpuInventoryUi.GetCpuInventory(); if (cpuInventory != null) { Item cpuItem = cpuInventory.GetAttachedItem(); Item playerItem = _playerInventory.GetAttachedItem(); if (cpuItem != null && playerItem != null) { ItemGroup[] groupsCpu = cpuItem.GetGroups(); ItemGroup[] groupsPlayer = playerItem.GetGroups(); bool isTheSameGroup = false; foreach (ItemGroup cpuGroup in groupsCpu) { foreach (ItemGroup playerGroup in groupsPlayer) { if (cpuGroup == playerGroup) { isTheSameGroup = true; break; } } if (isTheSameGroup) { break; } } if (isTheSameGroup) { //Item auxItem = cpuItem; cpuInventoryUi.GetCpuInventory().SetItem(cpuItem, playerItem); _playerInventory.SetItem(playerItem, cpuItem); } } } } }
public void SetCpu(CpuInventory cpuInventory) { if (_cpuInventory != cpuInventory) { HideActualCpuInventory(); this.gameObject.SetActive(true); this._cpuInventory = cpuInventory; for (int i = 0; i < buttonsUi.Length; i++) { int position = i; Button button = buttonsUi[position]; button.onClick.RemoveAllListeners(); button.onClick.AddListener(delegate() { _cpuInventory.Attach(position); }); } } }