示例#1
0
    public void Down()
    {
        // 슬롯에 아이템이 없으면 함수종료.
        if (!slot.isSlots())
        {
            return;
        }

        // 아이템 사용시.
        if (Input.GetMouseButtonDown(1))
        {
            slot.WeaponThrow();
            return;
        }

        // 빈 이미지 객체를 활성화 시킨다.
        Img.gameObject.SetActive(true);

        // 빈 이미지의 사이즈를 변경한다.(해상도가 바뀔경우를 대비.)
        float Size = slot.transform.GetComponent <RectTransform>().sizeDelta.x;

        EmptyImg.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Size);
        EmptyImg.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Size);

        // 빈 이미지의 스프라이트를 슬롯의 스프라이트로 변경한다.
        EmptyImg.sprite = slot.WeaponReturn().DefaultImg;
        // 빈 이미지의 위치를 마우스위로 가져온다.
        Img.transform.position = Input.mousePosition;
        // 슬롯의 아이템 이미지를 없애준다.
        slot.UpdateInfo(true, slot.DefaultImg);
        // 슬롯의 텍스트 숫자를 없애준다.
        slot.text.text = " [ " + slot.slotNumber + " ] ";
    }
示例#2
0
    // 무기를 넣기위해 모든 슬롯을 검사.
    public bool AddWeapon(WeaponCtrl weapon)
    {
        // 슬롯에 총 개수.
        int slotCount = WeaponAllSlot.Count;

        // 넣기위한 무기가 슬롯에 존재하는지 검사.
        for (int i = 0; i < slotCount; i++)
        {
            // 그 슬롯의 스크립트를 가져온다.
            WeaponSlotCtrl slot = WeaponAllSlot[i].GetComponent <WeaponSlotCtrl>();

            slot.slotNumber = i + 1;

            // 슬롯이 비어있으면 통과.
            if (!slot.isSlots())
            {
                continue;
            }

            // 슬롯에 존재하는 무기 타입과 넣을려는 무기의 타입이 같고.
            // 슬롯에 존재하는 무기의 겹칠수 있는 최대치가 넘지않았을 때. (true일 때)
            if (slot.WeaponReturn().type == weapon.type)
            {
                // 슬롯에 무기을 넣는다.
                Debug.Log("중복 무기 이미 존재");
                //slot.AddWeapon(weapon, true, slot);
                return(false);
            }
        }

        // 빈 슬롯에 무기를 넣기위한 검사.
        for (int i = 0; i < slotCount; i++)
        {
            WeaponSlotCtrl slot = WeaponAllSlot[i].GetComponent <WeaponSlotCtrl>();

            // 슬롯이 비어있지 않으면 통과
            if (slot.isSlots())
            {
                continue;
            }

            slot.AddWeapon(weapon, false, null);
            return(true);
        }

        // 위에 조건에 해당되는 것이 없을 때 아이템을 먹지 못함.
        return(false);
    }
示例#3
0
    // 무기!!!!!!!!!! 1: 비어있는 슬롯, 2: 안 비어있는 슬롯.
    void WeaponSwap2(WeaponSlotCtrl xFirst, WeaponSlotCtrl oSecond)
    {
        int        Count  = oSecond.weaponSlot.Count;
        WeaponCtrl weapon = oSecond.weaponSlot.Peek();

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

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

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