Commit 40cfe404 authored by 18류지석's avatar 18류지석

아이템 이제 떨굼. 지금 인벤토리 키고 끄는게 없어서 인스펙터에서 직접 키고 꺼야함

parent a4590655
...@@ -10,11 +10,14 @@ public class InventoryManager : MonoBehaviour { ...@@ -10,11 +10,14 @@ public class InventoryManager : MonoBehaviour {
public List<string> itemPool = new List<string>(); public List<string> itemPool = new List<string>();
public List<string> addonPool = new List<string>(); public List<string> addonPool = new List<string>();
public GameObject droppedPrefab; public GameObject droppedPrefab;
GameObject player;
private void Start() private void Start()
{ {
ui = GameObject.Find("InventoryCanvas").GetComponent<InventoryUI>(); ui = GameObject.Find("InventoryCanvas").GetComponent<InventoryUI>();
//GameObject.Find("InventoryCanvas").SetActive(false); GameObject.Find("InventoryCanvas").SetActive(false);
player = GameObject.Find("Player");
//itemPool //itemPool
itemPool.Add("Baculus"); itemPool.Add("Baculus");
...@@ -37,17 +40,17 @@ public class InventoryManager : MonoBehaviour { ...@@ -37,17 +40,17 @@ public class InventoryManager : MonoBehaviour {
PushItem((Item)System.Activator.CreateInstance(System.Type.GetType(itemPool[0]))); PushItem((Item)System.Activator.CreateInstance(System.Type.GetType(itemPool[0])));
PushItem((Item)System.Activator.CreateInstance(System.Type.GetType(itemPool[2]))); PushItem((Item)System.Activator.CreateInstance(System.Type.GetType(itemPool[2])));
yield return new WaitForSeconds(1.5f); yield return new WaitForSeconds(1.5f);
ItemInstantiate(itemPool[0], GameObject.Find("Player").transform.position); ItemInstantiate(itemPool[0], player.transform.position);
yield return new WaitForSeconds(1.5f); yield return new WaitForSeconds(1.5f);
ItemInstantiate(itemPool[1], GameObject.Find("Player").transform.position); ItemInstantiate(itemPool[1], player.transform.position);
yield return new WaitForSeconds(1.5f); yield return new WaitForSeconds(1.5f);
ItemInstantiate(itemPool[2], GameObject.Find("Player").transform.position); ItemInstantiate(itemPool[2], player.transform.position);
yield return new WaitForSeconds(1.5f); yield return new WaitForSeconds(1.5f);
ItemInstantiate(itemPool[3], GameObject.Find("Player").transform.position); ItemInstantiate(itemPool[3], player.transform.position);
yield return new WaitForSeconds(1.5f); yield return new WaitForSeconds(1.5f);
AddonInstantiate(addonPool[0], GameObject.Find("Player").transform.position); AddonInstantiate(addonPool[0], player.transform.position);
yield return new WaitForSeconds(1.5f); yield return new WaitForSeconds(1.5f);
AddonInstantiate(addonPool[1], GameObject.Find("Player").transform.position); AddonInstantiate(addonPool[1], player.transform.position);
/*ItemSelect(0); /*ItemSelect(0);
yield return new WaitForSeconds(1f); yield return new WaitForSeconds(1f);
PushItem((Item)System.Activator.CreateInstance(System.Type.GetType(itemPool[1]))); PushItem((Item)System.Activator.CreateInstance(System.Type.GetType(itemPool[1])));
...@@ -67,11 +70,21 @@ public class InventoryManager : MonoBehaviour { ...@@ -67,11 +70,21 @@ public class InventoryManager : MonoBehaviour {
GameObject tmpItem = Instantiate(droppedPrefab); GameObject tmpItem = Instantiate(droppedPrefab);
tmpItem.GetComponent<DroppedItem>().Init((Item)System.Activator.CreateInstance(System.Type.GetType(str)), pos); tmpItem.GetComponent<DroppedItem>().Init((Item)System.Activator.CreateInstance(System.Type.GetType(str)), pos);
} }
public void ItemInstantiate(Item item, Vector3 pos)
{
GameObject tmpItem = Instantiate(droppedPrefab);
tmpItem.GetComponent<DroppedItem>().Init(item, pos);
}
public void AddonInstantiate(string str, Vector3 pos) public void AddonInstantiate(string str, Vector3 pos)
{ {
GameObject tmpItem = Instantiate(droppedPrefab); GameObject tmpItem = Instantiate(droppedPrefab);
tmpItem.GetComponent<DroppedItem>().Init((Addon)System.Activator.CreateInstance(System.Type.GetType(str)), pos); tmpItem.GetComponent<DroppedItem>().Init((Addon)System.Activator.CreateInstance(System.Type.GetType(str)), pos);
} }
public void AddonInstantiate(Addon addon, Vector3 pos)
{
GameObject tmpItem = Instantiate(droppedPrefab);
tmpItem.GetComponent<DroppedItem>().Init(addon, pos);
}
public void SetOnPosition() public void SetOnPosition()
{ {
ui.SetOnPosition(itemList, addonList); ui.SetOnPosition(itemList, addonList);
...@@ -106,21 +119,30 @@ public class InventoryManager : MonoBehaviour { ...@@ -106,21 +119,30 @@ public class InventoryManager : MonoBehaviour {
public void DiscardItem(int index) public void DiscardItem(int index)
{ {
if (itemList.Count > index) if (itemList.Count > index)
{
ItemInstantiate(itemList[index], player.transform.position);
itemList.RemoveAt(index); itemList.RemoveAt(index);
if (index == ui.selectedItem) if (index == ui.selectedItem)
ui.selectedItem = -1; ui.selectedItem = -1;
}
ui.SetOnPosition(itemList, addonList); ui.SetOnPosition(itemList, addonList);
} }
public void DiscardAddon(int index) public void DiscardAddon(int index)
{ {
if (addonList.Count > index) if (addonList.Count > index)
{
AddonInstantiate(addonList[index], player.transform.position);
addonList.RemoveAt(index); addonList.RemoveAt(index);
}
ui.SetOnPosition(itemList, addonList); ui.SetOnPosition(itemList, addonList);
} }
public void DiscardAddon(int itemIndex, AddonType addonType) public void DiscardAddon(int itemIndex, AddonType addonType)
{ {
if (itemList[itemIndex].addons[(int)addonType] != null) if (itemList[itemIndex].addons[(int)addonType] != null)
{
AddonInstantiate(itemList[itemIndex].addons[(int)addonType], player.transform.position);
itemList[itemIndex].addons[(int)addonType] = null; itemList[itemIndex].addons[(int)addonType] = null;
}
ui.SetOnPosition(itemList, addonList); ui.SetOnPosition(itemList, addonList);
} }
public void AttachAddon(int itemIndex, int addonIndex) public void AttachAddon(int itemIndex, int addonIndex)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment