Commit ba73c3c7 authored by 18김상언's avatar 18김상언

인벤토리에서 아이템 정보창에서 아이템 설명 뜨는거 만드는중.

parent 6c9e5bfa
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -3,7 +3,7 @@ using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class AddonDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
public class AddonDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler, IPointerClickHandler
{
public int num;
InventoryUI ui;
......@@ -56,6 +56,23 @@ public class AddonDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDra
}
manager.SetOnPosition();
}
public void OnPointerClick(PointerEventData eventData)
{
if (num < 9)
{
int type = (int)manager.addonList[num].type;
if (ui.selectedItem != -1 && manager.itemList[ui.selectedItem].attachable[type])
{
if (manager.itemList[ui.selectedItem].addons[type] != null)
manager.DetachAddon(ui.selectedItem, (AddonType)type);
manager.AttachAddon(ui.selectedItem, num);
}
}
else
manager.DetachAddon(ui.selectedItem, (AddonType)(num - 9));
manager.SetOnPosition();
}
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;
......
......@@ -24,6 +24,7 @@ public class InventoryManager : MonoBehaviour {
SetPool();
ItemInstantiate("Dagger", player.transform.position, 0f);
AddonInstantiate("ParchmentPiece", player.transform.position, 0f);
StartCoroutine(TestCoroutine());
}
......
......@@ -30,6 +30,7 @@ public class InventoryUI : MonoBehaviour {
public GameObject[] infoAddonsFrame;
public GameObject[] comboStringFrame;
public GameObject[] comboCharPrefab;
public GameObject[] comboNameFrame;
public float pixelBetweenChar;
GameObject[,] comboChars = new GameObject[3, 8];
GameObject[] infoAddons;
......@@ -65,6 +66,7 @@ public class InventoryUI : MonoBehaviour {
comboChars[i, j].SetActive(false);
}
comboStringFrame[i].SetActive(false);
comboNameFrame[i].SetActive(false);
}
infoSpace.transform.Find("Frame").gameObject.SetActive(false);
......@@ -100,11 +102,13 @@ public class InventoryUI : MonoBehaviour {
frameObj.transform.Find("ItemSprite").gameObject.GetComponent<Image>().sprite = itemFrameQuality[(int)itemList[selectedItem].quality];
frameObj.transform.Find("ItemSprite").Find("Sprite").gameObject.GetComponent<Image>().sprite = itemList[selectedItem].sprite;
frameObj.transform.Find("ItemSprite").Find("Sprite").gameObject.GetComponent<RectTransform>().sizeDelta = itemList[selectedItem].sizeInventory;
frameObj.transform.Find("ItemDescription").gameObject.GetComponent<Text>().text = itemList[selectedItem].itemInfo;
for (int i = 0; i < 3; i++)
{
if (i < itemList[selectedItem].skillNum)
{
comboStringFrame[i].SetActive(true);
comboNameFrame[i].SetActive(true);
float tmpx = 0;
for (int j = 0; j < 8; j++)
{
......@@ -115,6 +119,7 @@ public class InventoryUI : MonoBehaviour {
comboChars[i, j].GetComponent<RectTransform>().sizeDelta = comboCharPrefab[itemList[selectedItem].combo[i][j] - 'A'].GetComponent<RectTransform>().sizeDelta;
comboChars[i, j].GetComponent<RectTransform>().localPosition = new Vector3(tmpx, 0, 0);
tmpx = comboChars[i, j].GetComponent<RectTransform>().sizeDelta.x + pixelBetweenChar;
comboNameFrame[i].GetComponent<Text>().text = itemList[selectedItem].comboName[i];
}
else
{
......
......@@ -14,6 +14,8 @@ public abstract class Item {
public Sprite sprite;
public Sprite highlight;
public Vector2 sizeInventory;
public string itemInfo;
public string[] comboName = new string[3];
public bool ComboAction(string currentCombo)
{
......@@ -53,6 +55,9 @@ public abstract class Item {
animation[1] = null;
animation[2] = null;
sizeInventory = new Vector2(0, 0);
itemInfo = null;
comboName = new string[3] { "", "", "" };
}
protected virtual void PlaySkill1()
{
......
......@@ -20,5 +20,7 @@ public class Dagger : Item
animation[1] = Resources.Load<AnimationClip>("Animations/daggerAttack2");
animation[2] = null;
sizeInventory = new Vector2(127.5f, 125);
itemInfo = "옛날 옛적 호랑이 담배 피던 시절부터 존재하던 단검이다.";
comboName = new string[3] { "베기", "찌르기", "" };
}
}
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