public void SetGunSlotIcon(int index, GunSlot slot) { if (slot.IsEmpty) { gunIcons[index].gameObject.SetActive(false); } else { gunIcons[index].gameObject.SetActive(true); gunIcons[index].sprite = slot.gun.stats.icon; } }
public void Add(Gun newGun, GameObject gunModel) { for (int i = 0; i < slots.Length; i++) { GunSlot slot = slots[i]; if (slot.type == newGun.stats.type) { slot.SetGun(newGun); gunModel.transform.SetParent(modelSlots[i]); gunModel.transform.localPosition = Vector3.zero; gunModel.transform.localRotation = Quaternion.identity; gunModel.transform.localScale = Vector3.one; GameManager.Instance.SetGunSlotIcon(i, slot); SetSlot(i); return; } } }
private void SetGunUI() { for (int i = 0; i < gunSlots.Length; i++) { Image uiSlot = gunSlots[i]; GunSlot slot = controller.guns.slots[i]; SetGunSlotIcon(i, slot); if (!slot.IsEmpty) { if (i == controller.guns.selectedSlot) { uiSlot.sprite = slotSelected; } else { uiSlot.sprite = slotNormal; } } } SetAmmoText(controller.guns.SelectedGun); }