Beispiel #1
0
 Slot GetSlot(ItemSubType type)
 {
     for (int i = 0; i < Slots.Count; i++)
     {
         if (Slots[i].SlotType.ToString() == type.ToString())
         {
             return(Slots[i]);
         }
     }
     return(null);
 }
Beispiel #2
0
 public override IValue Serialize() =>
 Bencodex.Types.Dictionary.Empty
 .Add("item_id", Id)
 .Add("item_sub_type", ItemSubType.ToString())
 .Add("grade", Grade)
 .Add("elemental_type", ElementalType.ToString());
Beispiel #3
0
        private void Awake()
        {
            _eventTrigger = GetComponent <EventTrigger>();
            if (!_eventTrigger)
            {
                throw new NotFoundComponentException <EventTrigger>();
            }

            EventTrigger.Entry entry = new EventTrigger.Entry();
            entry.eventID = EventTriggerType.PointerClick;
            entry.callback.AddListener(OnClick);
            _eventTrigger.triggers.Add(entry);

            RectTransform = GetComponent <RectTransform>();

            switch (ItemSubType)
            {
            case ItemSubType.FullCostume:
                _requireLevel = GameConfig.RequireCharacterLevel.CharacterFullCostumeSlot;
                break;

            case ItemSubType.HairCostume:
                _requireLevel = GameConfig.RequireCharacterLevel.CharacterHairCostumeSlot;
                break;

            case ItemSubType.EarCostume:
                _requireLevel = GameConfig.RequireCharacterLevel.CharacterEarCostumeSlot;
                break;

            case ItemSubType.EyeCostume:
                _requireLevel = GameConfig.RequireCharacterLevel.CharacterEyeCostumeSlot;
                break;

            case ItemSubType.TailCostume:
                _requireLevel = GameConfig.RequireCharacterLevel.CharacterTailCostumeSlot;
                break;

            case ItemSubType.Title:
                _requireLevel = GameConfig.RequireCharacterLevel.CharacterTitleSlot;
                break;

            case ItemSubType.Weapon:
                _requireLevel = GameConfig.RequireCharacterLevel.CharacterEquipmentSlotWeapon;
                break;

            case ItemSubType.Armor:
                _requireLevel = GameConfig.RequireCharacterLevel.CharacterEquipmentSlotArmor;
                break;

            case ItemSubType.Belt:
                _requireLevel = GameConfig.RequireCharacterLevel.CharacterEquipmentSlotBelt;
                break;

            case ItemSubType.Necklace:
                _requireLevel = GameConfig.RequireCharacterLevel.CharacterEquipmentSlotNecklace;
                break;

            case ItemSubType.Ring:
                _requireLevel = ItemSubTypeIndex == 1
                        ? GameConfig.RequireCharacterLevel.CharacterEquipmentSlotRing1
                        : GameConfig.RequireCharacterLevel.CharacterEquipmentSlotRing2;
                break;

            case ItemSubType.Food:
                switch (ItemSubTypeIndex)
                {
                case 1:
                    _requireLevel = GameConfig.RequireCharacterLevel
                                    .CharacterConsumableSlot1;
                    break;

                case 2:
                    _requireLevel = GameConfig.RequireCharacterLevel
                                    .CharacterConsumableSlot2;
                    break;

                case 3:
                    _requireLevel = GameConfig.RequireCharacterLevel
                                    .CharacterConsumableSlot3;
                    break;

                case 4:
                    _requireLevel = GameConfig.RequireCharacterLevel
                                    .CharacterConsumableSlot4;
                    break;

                case 5:
                    _requireLevel = GameConfig.RequireCharacterLevel
                                    .CharacterConsumableSlot5;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            _messageForCat =
                $"{L10nManager.Localize($"ITEM_SUB_TYPE_{ItemSubType.ToString()}")}\n<sprite name=\"UI_icon_lock_01\"> LV.{_requireLevel}";

            gameObject.AddComponent <ObservablePointerEnterTrigger>()
            .OnPointerEnterAsObservable()
            .Subscribe(x =>
            {
                if (!ShowUnlockTooltip || !IsLock)
                {
                    return;
                }

                if (_cat)
                {
                    _cat.Hide();
                }

                _cat = Widget.Find <MessageCatManager>().Show(true, _messageForCat);
            })
            .AddTo(gameObject);

            gameObject.AddComponent <ObservablePointerExitTrigger>()
            .OnPointerExitAsObservable()
            .Subscribe(x =>
            {
                if (!IsLock || !_cat)
                {
                    return;
                }

                _cat.Hide();
                _cat = null;
            })
            .AddTo(gameObject);
        }