Commit 89782746 authored by 18류지석's avatar 18류지석

애드온에 손올리면 정보뜸

parent 667ec91f
This diff is collapsed.
fileFormatVersion: 2
guid: b14e5a385d9465448931ccf15d2518e9
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:
......@@ -3,14 +3,17 @@ using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class AddonDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler, IPointerClickHandler
public class AddonDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler, IPointerClickHandler, IPointerEnterHandler, IPointerExitHandler
{
public int num;
InventoryUI ui;
InventoryManager manager;
Transform addonGroup, discardBin;
bool pointerOn;
void Start()
{
pointerOn = false;
ui = GameObject.Find("InventoryCanvas").GetComponent<InventoryUI>();
manager = InventoryManager.Instance;
addonGroup = ui.gameObject.transform.Find("AddonGroup");
......@@ -18,6 +21,7 @@ public class AddonDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDra
}
public void OnBeginDrag(PointerEventData eventData)
{
pointerOn = false;
if (eventData.button == PointerEventData.InputButton.Left)
transform.SetAsLastSibling();
}
......@@ -81,8 +85,40 @@ public class AddonDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDra
manager.SetOnPosition();
}
}
public void OnPointerEnter(PointerEventData eventData)
{
pointerOn = true;
StartCoroutine(AddonInfoReveal());
}
public void OnPointerExit(PointerEventData eventData)
{
pointerOn = false;
}
IEnumerator AddonInfoReveal()
{
if (num < 9)
{
for (float timer = 0; timer < 0.5f; timer += Time.deltaTime)
{
yield return null;
if (!pointerOn) yield break;
}
ui.SetAddonInfo(num);
while (pointerOn)
{
yield return null;
}
ui.SetAddonInfo();
}
}
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;
}
}
......@@ -32,12 +32,18 @@ public class InventoryUI : MonoBehaviour {
public GameObject[] comboCharPrefab;
public GameObject[] comboNameFrame;
public float pixelBetweenChar;
public GameObject addonInfoPrefab;
GameObject[,] comboChars = new GameObject[3, 8];
GameObject[] infoAddons;
GameObject addonInfo;
public int selectedItem = -1;
string[] qualityString = new string[4] { "습작", "범작", "수작", "걸작" };
InventoryManager inventoryManager;
void Awake () {
inventoryManager = InventoryManager.Instance;
items = new GameObject[9];
addons = new GameObject[9];
infoAddons = new GameObject[4];
......@@ -71,7 +77,38 @@ public class InventoryUI : MonoBehaviour {
}
infoSpace.transform.Find("Frame").gameObject.SetActive(false);
addonInfo = Instantiate(addonInfoPrefab, transform);
addonInfo.SetActive(false);
}
public void SetAddonInfo()
{
addonInfo.SetActive(false);
}
public void SetAddonInfo(int addonNum)
{
if (addons[addonNum].activeSelf)
{
addonInfo.SetActive(true);
addonInfo.transform.position = addonCell[addonNum].transform.position + new Vector3(0, 200, 0);
addonInfo.transform.position += new Vector3(-addonInfo.transform.position.x + Mathf.Min(addonInfo.transform.position.x, 1650), 0, 0);
Addon currentAddon = inventoryManager.addonList[addonNum];
GameObject tmpObj = addonInfo.transform.Find("AddonPrefab").gameObject;
tmpObj.GetComponent<Image>().sprite = addonFrameQuality[(int)currentAddon.type * 4 + (int)currentAddon.quality];
tmpObj.transform.Find("Sprite").gameObject.GetComponent<Image>().sprite = currentAddon.sprite;
tmpObj.transform.Find("Sprite").gameObject.GetComponent<RectTransform>().sizeDelta = currentAddon.sizeInventory;
tmpObj.SetActive(true);
addonInfo.transform.Find("Quality").GetComponent<Text>().text = qualityString[(int)currentAddon.quality];
addonInfo.transform.Find("Name").GetComponent<Text>().text = currentAddon.name;
addonInfo.transform.Find("Description").GetComponent<Text>().text = currentAddon.addonDescription;
addonInfo.transform.Find("Info").GetComponent<Text>().text = currentAddon.addonInfo;
}
}
public void SetOnPosition(List<Item> itemList, List<Addon> addonList)
{
for(int i=0; i<itemList.Count; i++)
......
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