/* 씨앗 심기 */
    void PlantingProcess()
    {
        if (!m_BlockManager.IS_Focus)
        {
            return;
        }

        // 블록 포커스 상태에서 마우스 클릭
        else
        {
            if (Input.GetMouseButtonDown(0))
            {
                if (m_BlockManager.Hit_Info.transform.tag != "FarmLand")
                {
                    return;
                }
                // 씨앗 개수 부족
                if (Inven.MySeedCount <= 0)
                {
                    Text temptext = GameObject.Instantiate(EventMgr.ErrorMsg);
                    temptext.transform.SetParent(EventMgr.transform);
                    temptext.transform.localPosition = Vector3.up * 300f;
                    temptext.transform.localScale    = Vector3.one;
                    StartCoroutine(ErrorMsg.ErrorMsgCoroutine(temptext, EventMgr.SeedErrorMsg));
                    return;
                }

                ObjectManagement(Seed);
                --Inven.MySeedCount;
                Inven.UpdateInvenUI();
            }
        }
    }
示例#2
0
    // 포인터를 누르고 뗄 때 호출
    public void OnPointerClick(PointerEventData eventData)
    {
        if (!Store.gameObject.activeSelf)
        {
            return;
        }

        Slot slot = eventData.pointerPress.GetComponent <Slot>();

        if (eventData.pointerId != -2 || slot.SlotState == E_SLOTSTATE.EMPTY)
        {
            return;
        }

        switch (slot.SlotType)
        {
        case E_SLOTTYPE.INVENTORY:     // 인벤토리 슬롯 우클릭
            // 작물 판매
            --slot.Count;
            Inven.MyGold += slot.ItemInfo.ItemPrice;
            if (slot.Count <= 0)
            {
                SlotReset(slot);     // 작물이 0개가 되면 슬롯 초기화
            }

            slot.UpdateSlotUI();
            Inven.UpdateInvenUI();
            break;

        case E_SLOTTYPE.STORE:                          // 상점 슬롯 우클릭
            if (Inven.MyGold < slot.ItemInfo.ItemPrice) // 골드 부족
            {
                Text temptext = GameObject.Instantiate(EventMgr.ErrorMsg);
                temptext.transform.SetParent(EventMgr.transform);
                temptext.transform.localPosition = Vector3.up * 300f;
                temptext.transform.localScale    = Vector3.one;
                StartCoroutine(ErrorMsg.ErrorMsgCoroutine(temptext, EventMgr.GoldErrorMsg));
                return;
            }
            // 씨앗 구입
            --slot.Count;
            ++Inven.MySeedCount;
            if (slot.Count <= 0)
            {
                slot.Count = 99;
            }
            Inven.MyGold -= slot.ItemInfo.ItemPrice;

            slot.UpdateSlotUI();
            Inven.UpdateInvenUI();
            break;
        }
    }