public override T GetSlotBehaviour <T> () { if (CurrentSlot != null && CurrentSlot.Behaviours != null) { for (int i = 0; i < CurrentSlot.Behaviours.Length; i++) { ItemSlotBehaviour behaviour = CurrentSlot.Behaviours[i]; if (behaviour.GetType() == typeof(T)) { return((T)behaviour); } } } if (Behaviours != null) { for (int i = 0; i < Behaviours.Length; i++) { ItemSlotBehaviour behaviour = Behaviours[i]; if (behaviour.GetType() == typeof(T)) { return((T)behaviour); } } } return(null); }
public virtual T GetSlotBehaviour<T> () where T : ItemSlotBehaviour { for (int i = 0; i < Behaviours.Length; i++) { ItemSlotBehaviour behaviour = Behaviours[i]; if (behaviour.GetType () == typeof (T)) { return (T)behaviour; } } return null; }
public ItemSlot GenerateSlot(RPGCharacter character) { ItemSlotBehaviour[] slotBehaviour = new ItemSlotBehaviour[] { new Slot_EquippableSlot() }; ItemCondition[] slotCondition = new ItemCondition[] { new EquipmentTypeCondition(AllowedItems) }; ItemStorageSlot storageSlot = new ItemStorageSlot(character, slotBehaviour, slotCondition); storageSlot.SlotDecoration = SlotIcon; return(storageSlot); }
public ItemSelectSlot(bool _avoidEmptySlots = false, ItemSlotBehaviour[] behaviours = null, ItemCondition[] conditions = null, params ItemSlot[] originalSlot) : base(originalSlot[1].Owner, behaviours, conditions) { avoidEmptySlots = _avoidEmptySlots; OriginalSlot = originalSlot; foreach (ItemSlot slot in OriginalSlot) { if (slot == null) { continue; } slot.onAfterChanged += () => { if (Behaviours != null) { for (int i = 0; i < Behaviours.Length; i++) { ItemSlotBehaviour behaviour = Behaviours[i]; behaviour.OnEnterSlot(this); if (Enabled) { behaviour.OnSlotEnable(this); } } } if (onAfterChanged != null) { onAfterChanged(); } }; slot.onBeforeChanged += () => { if (Behaviours != null) { for (int i = 0; i < Behaviours.Length; i++) { ItemSlotBehaviour behaviour = Behaviours[i]; behaviour.OnExitSlot(this); if (Enabled) { behaviour.OnSlotDisable(this); } } } if (onBeforeChanged != null) { onBeforeChanged(); } }; //slot.onQuantityChanged += () => onQuantityChanged (); } if (Behaviours != null) { for (int i = 0; i < Behaviours.Length; i++) { ItemSlotBehaviour behaviour = Behaviours[i]; behaviour.OnEnterSlot(this); if (Enabled) { behaviour.OnSlotEnable(this); } } } currentSlot = OriginalSlot[currentSlotID]; }