public void SelectReward(int index) { if (rewards[index].filePath == null) { //CItemManager.Instance.GetObjectForKey(rewards[index].name).GetComponent<IItem>().Use(); if (rewards[index].name == KDefine.ITEM_HEART) { player.RestoreHealth(2); } else if (rewards[index].name == KDefine.ITEM_SHIELD) { player.AddShield(); } else if (rewards[index].name == KDefine.ITEM_BULLETS) { CWeaponManager.Instance.AllReload(1000); } } else { rewardIndex = index; if (CWeaponManager.Instance.IsFullInventory()) { itemName[0].transform.parent.parent.gameObject.SetActive(false); equipGunName[0].transform.parent.parent.gameObject.SetActive(true); for (int i = 0; i < CWeaponManager.weaponList.Count; i++) { equipGunName[i].sprite = CWeaponManager.weaponList[i].weaponUIImage; equipGunImage[i].sprite = CWeaponManager.weaponList[i].weaponUIImage; } return; } else { CWeaponManager.Instance.AddWeapon(GameObject.Instantiate(CResourceManager.Instance.GetObjectForKey(rewards[rewardIndex].filePath), CWeaponManager.Instance.weaponParent).GetComponent <CWeapon>()); } } this.gameObject.SetActive(false); }
public void Trade() { CMerchandiseManager.Instance.MinusCoin(price); bIsTradable = false; itemImage.sprite = null; if (bCoroutineIsRunning) { StopCoroutine("ItemFloating"); } if (filePath == "") { if (itemName == KDefine.ITEM_HEART) { playerHealth.RestoreHealth(2); } else if (itemName == KDefine.ITEM_SHIELD) { playerHealth.AddShield(); } else if (itemName == KDefine.ITEM_BULLETS) { CWeaponManager.Instance.AllReload(1000); } } else { if (CWeaponManager.Instance.IsFullInventory()) { CWeaponManager.Instance.DestroyWeapon(CWeaponManager.Instance.currentWeaponIndex); } Debug.Log(filePath); CWeaponManager.Instance.AddWeapon(GameObject.Instantiate(CResourceManager.Instance.GetObjectForKey(filePath), CWeaponManager.Instance.weaponParent).GetComponent <CWeapon>()); } FinishInteract(); }