Exemple #1
0
    private bool checkClick = false; // 이미 한 개의 슬롯을 선택했는지 안했는지


    // Start is called before the first frame update
    void Start()
    {
        // 현재 슬롯의 스크립트를 가져온다.
        slot = GetComponent <Unit_Slot>();
        // 빈 이미지 객체를 태그를 이용하여 가져온다.
        Img = GameObject.FindGameObjectWithTag("DragImg").transform;
        // 빈 이미지 객체가 가진 Image컴포넌트를 가져온다.
        EmptyImg = Img.GetComponent <Image>();
    }
Exemple #2
0
    // 아이템 옮기기 및 교환.
    public void Swap(Unit_Slot slot, Vector3 Pos)
    {
        Unit_Slot FirstSlot = NearDisSlot(Pos);

        // 현재 슬롯과 옮기려는 슬롯이 같으면 함수 종료.
        if (slot == FirstSlot || FirstSlot == null)
        {
            slot.UpdateInfo(true, slot.slot.Peek().DefaultImg);
            return;
        }

        // 가까운 슬롯이 비어있으면 옮기기.
        if (!FirstSlot.isSlots())
        {
            //Swap(FirstSlot, slot);
        }
        // 교환.
        else
        {
            int                Count = slot.slot.Count;
            ItemObject         item  = slot.slot.Peek();
            Stack <ItemObject> temp  = new Stack <ItemObject>();

            {
                for (int i = 0; i < Count; i++)
                {
                    temp.Push(item);
                }

                slot.slot.Clear();
            }

            Swap(slot, FirstSlot);

            {
                Count = temp.Count;
                item  = temp.Peek();

                for (int i = 0; i < Count; i++)
                {
                    FirstSlot.slot.Push(item);
                }

                FirstSlot.UpdateInfo(true, temp.Peek().DefaultImg);
            }
        }
    }
Exemple #3
0
    // 1: 비어있는 슬롯, 2: 안 비어있는 슬롯.
    void Swap(Unit_Slot xFirst, Unit_Slot oSecond)
    {
        int        Count = oSecond.slot.Count;
        ItemObject item  = oSecond.slot.Peek();

        for (int i = 0; i < Count; i++)
        {
            if (xFirst != null)
            {
                xFirst.slot.Push(item);
            }
        }

        if (xFirst != null)
        {
            xFirst.UpdateInfo(true, oSecond.ItemReturn().DefaultImg);
        }

        oSecond.slot.Clear();
        oSecond.UpdateInfo(false, oSecond.DefaultImg);
    }