Ejemplo n.º 1
0
        private void SubscribeState(ItemType stateType)
        {
            consumablesButton.text.gameObject.SetActive(false);
            consumablesButton.selectedText.gameObject.SetActive(false);
            costumesButton.text.gameObject.SetActive(false);
            costumesButton.selectedText.gameObject.SetActive(false);
            equipmentsButton.text.gameObject.SetActive(false);
            equipmentsButton.selectedText.gameObject.SetActive(false);
            materialsButton.text.gameObject.SetActive(false);
            materialsButton.selectedText.gameObject.SetActive(false);
            switch (stateType)
            {
            case ItemType.Consumable:
                equipmentsButton.image.sprite  = _deselectedButtonSprite;
                costumesButton.image.sprite    = _deselectedButtonSprite;
                consumablesButton.image.sprite = _selectedButtonSprite;
                materialsButton.image.sprite   = _deselectedButtonSprite;
                scroll.UpdateData(SharedModel.Consumables, stateType != _stateType);
                equipmentsButton.text.gameObject.SetActive(true);
                costumesButton.text.gameObject.SetActive(true);
                consumablesButton.selectedText.gameObject.SetActive(true);
                materialsButton.text.gameObject.SetActive(true);
                break;

            case ItemType.Costume:
                equipmentsButton.image.sprite  = _deselectedButtonSprite;
                costumesButton.image.sprite    = _selectedButtonSprite;
                consumablesButton.image.sprite = _deselectedButtonSprite;
                materialsButton.image.sprite   = _deselectedButtonSprite;
                scroll.UpdateData(SharedModel.Costumes, stateType != _stateType);
                equipmentsButton.text.gameObject.SetActive(true);
                costumesButton.selectedText.gameObject.SetActive(true);
                consumablesButton.text.gameObject.SetActive(true);
                materialsButton.text.gameObject.SetActive(true);
                break;

            case ItemType.Equipment:
                equipmentsButton.image.sprite  = _selectedButtonSprite;
                costumesButton.image.sprite    = _deselectedButtonSprite;
                consumablesButton.image.sprite = _deselectedButtonSprite;
                materialsButton.image.sprite   = _deselectedButtonSprite;
                scroll.UpdateData(SharedModel.Equipments, stateType != _stateType);
                equipmentsButton.selectedText.gameObject.SetActive(true);
                costumesButton.text.gameObject.SetActive(true);
                consumablesButton.text.gameObject.SetActive(true);
                materialsButton.text.gameObject.SetActive(true);
                break;

            case ItemType.Material:
                equipmentsButton.image.sprite  = _deselectedButtonSprite;
                costumesButton.image.sprite    = _deselectedButtonSprite;
                consumablesButton.image.sprite = _deselectedButtonSprite;
                materialsButton.image.sprite   = _selectedButtonSprite;
                scroll.UpdateData(SharedModel.Materials, stateType != _stateType);
                equipmentsButton.text.gameObject.SetActive(true);
                costumesButton.text.gameObject.SetActive(true);
                consumablesButton.text.gameObject.SetActive(true);
                materialsButton.selectedText.gameObject.SetActive(true);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(stateType), stateType, null);
            }

            _stateType = stateType;

            // 선택된 버튼의 스프라이트가 1픽셀 내려가는 문제가 있음.

            foreach (var pair in _switchButtonTransforms)
            {
                var btn = pair.Value;
                // TextMeshPro 그림자 마테리얼 변경 해줘야함
                if (pair.Key == stateType)
                {
                    btn.anchoredPosition = new Vector2(btn.anchoredPosition.x, 1);
                    btn.sizeDelta        = BtnHighlightSize;
                }
                else
                {
                    btn.anchoredPosition = new Vector2(btn.anchoredPosition.x, 0);
                    btn.sizeDelta        = BtnSize;
                }
            }

            Widget.Find <ItemInformationTooltip>().Close();
        }