Commit 667ec91f authored by 18류지석's avatar 18류지석

인벤토리창 버그 고침

parent 6d68fd23
...@@ -18,15 +18,19 @@ public class AddonDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDra ...@@ -18,15 +18,19 @@ public class AddonDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDra
} }
public void OnBeginDrag(PointerEventData eventData) public void OnBeginDrag(PointerEventData eventData)
{ {
if (eventData.button == PointerEventData.InputButton.Left)
transform.SetAsLastSibling(); transform.SetAsLastSibling();
} }
public void OnDrag(PointerEventData eventData) public void OnDrag(PointerEventData eventData)
{ {
if (eventData.button == PointerEventData.InputButton.Left)
transform.position = Input.mousePosition; transform.position = Input.mousePosition;
} }
public void OnEndDrag(PointerEventData eventData) public void OnEndDrag(PointerEventData eventData)
{
if (eventData.button == PointerEventData.InputButton.Left)
{ {
if (CheckBetween(Input.mousePosition, discardBin.position, discardBin.GetComponent<RectTransform>().sizeDelta)) if (CheckBetween(Input.mousePosition, discardBin.position, discardBin.GetComponent<RectTransform>().sizeDelta))
{ {
...@@ -56,8 +60,11 @@ public class AddonDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDra ...@@ -56,8 +60,11 @@ public class AddonDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDra
} }
manager.SetOnPosition(); manager.SetOnPosition();
} }
}
public void OnPointerClick(PointerEventData eventData) public void OnPointerClick(PointerEventData eventData)
{
if (eventData.button == PointerEventData.InputButton.Right)
{ {
if (num < 9) if (num < 9)
{ {
...@@ -73,6 +80,7 @@ public class AddonDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDra ...@@ -73,6 +80,7 @@ public class AddonDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDra
manager.DetachAddon(ui.selectedItem, (AddonType)(num - 9)); manager.DetachAddon(ui.selectedItem, (AddonType)(num - 9));
manager.SetOnPosition(); manager.SetOnPosition();
} }
}
bool CheckBetween(Vector3 mouse, Vector3 center, Vector2 size) bool CheckBetween(Vector3 mouse, Vector3 center, Vector2 size)
{ {
return Mathf.Abs(mouse.x - center.x) <= size.x / 2f && Mathf.Abs(mouse.y - center.y) <= size.y / 2f; return Mathf.Abs(mouse.x - center.x) <= size.x / 2f && Mathf.Abs(mouse.y - center.y) <= size.y / 2f;
......
...@@ -145,6 +145,11 @@ public class InventoryManager : Singleton<InventoryManager> { ...@@ -145,6 +145,11 @@ public class InventoryManager : Singleton<InventoryManager> {
{ {
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);
for (int i = 0; i < 4; i++)
if (itemPool[i].Contains(str))
itemPool[i].Remove(str);
tmpItem.transform.SetParent(MapManager.currentRoom.roomInGame.transform); tmpItem.transform.SetParent(MapManager.currentRoom.roomInGame.transform);
PopoutGenerator(tmpItem, popoutStrength); PopoutGenerator(tmpItem, popoutStrength);
} }
...@@ -183,6 +188,11 @@ public class InventoryManager : Singleton<InventoryManager> { ...@@ -183,6 +188,11 @@ public class InventoryManager : Singleton<InventoryManager> {
{ {
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);
for (int i = 0; i < 4; i++)
if (addonPool[i].Contains(str))
addonPool[i].Remove(str);
tmpItem.transform.SetParent(MapManager.currentRoom.roomInGame.transform); tmpItem.transform.SetParent(MapManager.currentRoom.roomInGame.transform);
PopoutGenerator(tmpItem, popoutStrength); PopoutGenerator(tmpItem, popoutStrength);
} }
......
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