コード例 #1
0
    //아이템을 놓을때
    bool ItemDropGrid()
    {
        Vector2 pos = rectTr.anchoredPosition;

        //아이템이 인벤토리 밖에서 드랍될시(x좌표가 음수일때or 0보다 작을때)
        if (pos.x <= 0 - leftSpace)
        {
            if (shopManager.isOn && ShopOverlapCheck())
            {
                //ItemSellCheck();
                ItemSell(1);
            }
            else
            {
                ItemInvenOutCheck();
            }
            return(false);
        }
        if (pos.y >= downSpace + (slotSize * 4))
        {
            //아이템 착용
            if (needLevel > MonkSkill.instance.Level)
            {
                return(false);
            }

            equipmentManager.DropEquipment(Mathf.RoundToInt(pos.x), Mathf.RoundToInt(pos.y), xSize, ySize, ref itemManager);

            equipmentManager.ItemStatusSet();

            return(false);
        }

        //x,y포지션 카운트 계산
        int _xPosition = Mathf.RoundToInt((pos.x - leftSpace) / slotSize);
        int _yPosition = Mathf.RoundToInt((pos.y - downSpace) / slotSize);

        //사이즈와 인벤 배열크기 비교 (초과하는지 확인) 후 예외처리 추가해야함
        if (!ItemArrOverCheck(_xPosition, _yPosition))
        {
            return(false);
        }

        //배열에 아이템이 존재하는지 확인
        if (!inventoryManager.ArrInputCheck(_xPosition, _yPosition, xSize, ySize))
        {
            //존재 한다면 스왑을 시켜야함
            DoSwap(_xPosition, _yPosition);

            return(false);
        }

        rectTr.anchoredPosition = new Vector2((_xPosition * slotSize) + leftSpace, (_yPosition * slotSize) + downSpace);

        //배열에 아이템이 존재하는지 확인 후 배열에 추가 로직 추가

        xPosition = _xPosition;
        yPosition = _yPosition;

        return(true);
    }