예제 #1
0
    public void Drag()
    {
        if (!slot.isSlots())
        {
            return;
        }

        if (!isDrag && Vector2.Distance((Vector2)Input.mousePosition, firMousePos) >= min)
        { // 처음에 드래그 일정 거리 이상 했을 경우
            isDrag = true;
            ObjManager.objManager.inventory.RenewInfo();

            img.gameObject.SetActive(true);
            emptyImg.sprite = slot.ItemReturn().sprite;
            slot.UpdateInfo(true, slot.DefaultImg);
            gameObject.transform.GetChild(0).gameObject.GetComponent <Image>().color = Color.white;

            if (!ItemIO.isItemGot(slot.item.ID))
            {
                emptyImg.color = Color.black;
            }
            else
            {
                emptyImg.color = Color.white;
            }
        }

        if (img.gameObject.activeInHierarchy)
        {
            img.transform.position = Input.mousePosition;
        }
    }
예제 #2
0
    public void ShowInfo()
    {
        ObjManager.objManager.inventory.RenewInfo(this);

        if (!ItemIO.isItemGot(item.ID))
        {
            ItemImg.color = Color.black;
        }
    }
예제 #3
0
    public void RenewInfo(Slot slot) // 아이템 상세정보 띄우기
    {
        InfoSlot.gameObject.SetActive(true);
        Item item = slot.ItemReturn();

        if (item.type != Item.ItemType.food && item.type != Item.ItemType.memo)
        {
            useBtn.enabled = false;
        }
        else
        {
            useBtn.enabled = true;
        }

        Image image = InfoSlot.GetChild(1).GetComponent <Image>();

        image.sprite = item.sprite;

        /* 기존 버튼 리스너 모두 제거 */
        checkBtn.onClick.RemoveAllListeners();
        useBtn.onClick.RemoveAllListeners();
        trashBtn.onClick.RemoveAllListeners();

        /* 해당 아이템 슬롯에 맞는 버튼 리스너 붙이기 */
        useBtn.onClick.AddListener(() => slot.UseItem());     // 아이템 사용 함수 리스너 등록
        trashBtn.onClick.AddListener(() => slot.ThrowItem()); // 아이템 버리기 함수 리스너 등록

        if (!ItemIO.isItemGot(item.ID))                       // 처음 줍거나 써본 적 없을 때
        {
            checkBtn.interactable = true;                     // 체크 버튼 사용 가능

            /* 설명 슬롯 설정 */
            InfoSlot.GetChild(0).GetComponent <Text>().text = "???";
            image.color = Color.black;
            InfoSlot.GetChild(2).GetComponent <Text>().text = "???";
            InfoSlot.GetChild(3).GetComponent <Text>().text = "???";

            /* 버튼 리스너 붙이기 */
            checkBtn.onClick.AddListener(() => slot.CheckItem()); // 아이템 조사 함수 리스너 등록
        }
        else // 조사했거나 사용해 봤을 때
        {
            checkBtn.interactable = false; // 조사 버튼 사용 불가능

            /* 설명 슬롯 설정 */
            InfoSlot.GetChild(0).GetComponent <Text>().text = item.name;
            image.color = Color.white;
            InfoSlot.GetChild(2).GetComponent <Text>().text = item.type.ToString().ToUpper();
            InfoSlot.GetChild(3).GetComponent <Text>().text = item.effect;
        }
    }
예제 #4
0
 public void CheckGotItem()
 {
     if (item != null)
     {
         if (ItemIO.isItemGot(item.ID))
         {
             ItemImg.color = Color.white;
         }
         else
         {
             ItemImg.color = Color.black;
         }
     }
 }
예제 #5
0
    public virtual void UpdateInfo(bool isSlot, Sprite sprite)
    {
        // 인벤토리 저장 및 그림자 설정

        SetSlots(isSlot);
        ItemImg.sprite = sprite;

        if (item != null && !ItemIO.isItemGot(item.ID))
        {
            ItemImg.color = Color.black;
        }
        else if (item == null)
        {
            ItemImg.color = Color.white;
        }

        ItemIO.SaveData();
    }