public override void OnEnable() { base.OnEnable(); if (target == null) { return; } item = (ItemCollectionBase)target; //serializer = new SerializedObject(target); serializer = serializedObject; collectionName = serializer.FindProperty("collectionName"); restrictByWeight = serializer.FindProperty("restrictByWeight"); restrictMaxWeight = serializer.FindProperty("restrictMaxWeight"); itemButtonPrefab = serializer.FindProperty("itemButtonPrefab"); filters = serializer.FindProperty("filters"); useReferences = serializer.FindProperty("_useReferences"); ignoreItemLayoutSizes = serializer.FindProperty("ignoreItemLayoutSizes"); canContainCurrencies = serializer.FindProperty("canContainCurrencies"); canDropFromCollection = serializer.FindProperty("canDropFromCollection"); canUseItemsFromReference = serializer.FindProperty("canUseItemsFromReference"); canUseFromCollection = serializer.FindProperty("canUseFromCollection"); canDragInCollection = serializer.FindProperty("canDragInCollection"); canPutItemsInCollection = serializer.FindProperty("canPutItemsInCollection"); canStackItemsInCollection = serializer.FindProperty("canStackItemsInCollection"); canUnstackItemsInCollection = serializer.FindProperty("canUnstackItemsInCollection"); manuallyDefineCollection = serializer.FindProperty("manuallyDefineCollection"); container = serializer.FindProperty("container"); }
private void OnUnstackedItemPly(ItemCollectionBase fromCollection, uint startSlot, ItemCollectionBase toCollection, uint endSlot, uint amount) { if (eventHandler != null) { eventHandler.CollectionOnUnstackedItem(startSlot, endSlot, amount); } }
private void OnSwappedItemsPly(ItemCollectionBase fromCollection, uint fromSlot, ItemCollectionBase toCollection, uint toSlot) { if (eventHandler != null) { eventHandler.CharacterOnSwappedItems(fromCollection, fromSlot, toCollection, toSlot); } }
public void Reset() { startIndex = -1; startItemCollection = null; endIndex = -1; endItemCollection = null; }
public void SelectFirstSlotOfCollection(ItemCollectionBase collection) { if (collection.items.Length == 0) { Debug.LogWarning("Collection has no items, can't select first item."); return; } collection[0].Select(); }
public void CharacterOnSwappedItems(ItemCollectionBase fromCollection, uint fromSlot, ItemCollectionBase toCollection, uint toSlot) { if (onSwappedItemsEvents.Count > 0) { RunEvents(onSwappedItemsEvents, new plyEventArg("fromCollection", fromCollection), new plyEventArg("fromSlot", (int)fromSlot), new plyEventArg("toCollection", toCollection), new plyEventArg("toSlot", (int)toSlot)); } }
public void GiveRewards(Quest quest) { var col = ItemCollectionBase.FindByName(collectionName); if (col == null) { DevdogLogger.LogWarning("Collection with name " + collectionName + " not found."); return; } col.AddSlots(extraSlots); }
public void ClearCollectionAndMoveItemsToInventories(ItemCollectionBase collection) { if (collection.useReferences == false) { var items = collection.Select(o => o.item).Where(o => o != null).ToArray(); collection.Clear(); foreach (var item in items) { InventoryManager.AddItem(item); } } }
public virtual void Awake() { collection = GetComponent <ItemCollectionBase>(); if (collection.useReferences) { StartCoroutine(WaitAndLoad()); } else { collection.LoadEasySave2(fileName, additionalFields); } }
protected virtual void Awake() { window = GetComponent <UIWindow>(); collection = GetComponent <ItemCollectionBase>(); collection.OnAddedItem += (items, amount, fromCollection) => CollectionChanged(); collection.OnRemovedItem += (item, id, slot, amount) => CollectionChanged(); collection.OnUsedItem += (item, id, slot, amount) => CollectionChanged(); if (window != null) { window.OnShow += Repaint; } }
public void TriggerAddCurrencyToCollection(ItemCollectionBase collection) { InventoryManager.instance.intValDialog.ShowDialog(transform, "Amount", "", 1, 9999, value => { // Yes callback if (InventoryManager.CanRemoveCurrency(currencyID, (float)value, allowCurrencyConversions)) { InventoryManager.RemoveCurrency(currencyID, value); toCollection.AddCurrency(currencyID, value); } }, value => { // No callback } ); }
public override void OnEnable() { base.OnEnable(); item = (ItemCollectionBase)target; //serializer = new SerializedObject(target); serializer = serializedObject; collectionName = serializer.FindProperty("collectionName"); restrictByWeight = serializer.FindProperty("restrictByWeight"); restrictMaxWeight = serializer.FindProperty("restrictMaxWeight"); itemButtonPrefab = serializer.FindProperty("itemButtonPrefab"); items = serializer.FindProperty("_items"); filters = serializer.FindProperty("filters"); useReferences = serializer.FindProperty("useReferences"); canContainCurrencies = serializer.FindProperty("canContainCurrencies"); canDropFromCollection = serializer.FindProperty("canDropFromCollection"); canUseItemsFromReference = serializer.FindProperty("canUseItemsFromReference"); canUseFromCollection = serializer.FindProperty("canUseFromCollection"); canDragInCollection = serializer.FindProperty("canDragInCollection"); canPutItemsInCollection = serializer.FindProperty("canPutItemsInCollection"); canStackItemsInCollection = serializer.FindProperty("canStackItemsInCollection"); canUnstackItemsInCollection = serializer.FindProperty("canUnstackItemsInCollection"); manuallyDefineCollection = serializer.FindProperty("manuallyDefineCollection"); container = serializer.FindProperty("container"); itemManager = Editor.FindObjectOfType<ItemManager>(); if (itemManager == null) Debug.LogError("No item manager found in scene, cannot edit item."); manualItemsList = new UnityEditorInternal.ReorderableList(serializer, items, true, true, true, true); manualItemsList.drawHeaderCallback += rect => { EditorGUI.LabelField(rect, "Select items"); }; manualItemsList.drawElementCallback += (rect, index, active, focused) => { rect.height = 16; rect.y += 2; EditorGUI.PropertyField(rect, items.GetArrayElementAtIndex(index)); }; }
public void Awake() { // Create instance objects. for (int i = 0; i < items.Length; i++) { if (items[i] != null) { items[i] = GameObject.Instantiate <InventoryItemBase>(items[i]); items[i].transform.SetParent(transform); items[i].gameObject.SetActive(false); } } // The triggerHandler component, that is always there because of RequireComponent var trigger = GetComponent <Trigger>(); // The collection we want to place the items into. _collection = trigger.window.window.GetComponent <ItemCollectionBase>(); }
public override bool Equip(InventoryEquippableField equipSlot, ItemCollectionBase equipToCollection) { bool equipped = base.Equip(equipSlot, equipToCollection); if (equipped == false) { return(false); } if (actor.actorClass.currLevel < requiredLevel) { InventoryManager.instance.lang.itemCannotBeUsedLevelToLow.Show(name, description, requiredLevel); return(false); } SetPlyGameValues(); return(true); }
public void Awake() { OnEquipped += to => { tempCollection = itemCollection; //bool added = eventHandler.AddItem.Try(new object[] { itemType }); bool added = ufpsInventory.TryGiveItem(itemType, 0); if (added) { var bankType = itemType as vp_UnitBankType; if (bankType != null) { SetAmmo(bankType); tempCollection.OnAddedItem += AddedItemCollection; tempCollection.OnRemovedItem += RemovedItemCollection; } } eventHandler.Register(this); // Enable UFPS events }; OnUnEquipped += () => { //eventHandler.RemoveItem.Try(new object[] { itemType }); ufpsInventory.TryRemoveItem(itemType, 0); var bankType = itemType as vp_UnitBankType; if (bankType != null) { tempCollection.OnAddedItem -= AddedItemCollection; tempCollection.OnRemovedItem -= RemovedItemCollection; } tempCollection = itemCollection; eventHandler.Unregister(this); // Disable UFPS events }; }
public TodoItemViewModel(ItemCollectionBase itemCollection, TodoItem current, ObservableCollection <TodoItem> items = null, string title = null) { this.ItemCollection = itemCollection; this.Items = items ?? itemCollection.Items; this.Current = current; this.Title = title ?? itemCollection.Title; this.TitleCandidate = this.Title; this.DescriptionCandidate = ItemCollection != null ? ItemCollection.Description : string.Empty; this.ProjectWithInbox = DataService.ProjectWithInbox; this.Contexts = DataService.Contexts; LoadMedia(); this.PropertyChanged += (sender, e) => { if (e.PropertyName == "Current") { LoadMedia(); } }; }
protected void Reset() { collection = GetComponent <ItemCollectionBase>(); }
private void OnSwappedItemsPly(ItemCollectionBase fromCollection, uint fromSlot, ItemCollectionBase toCollection, uint toSlot) { if (eventHandler != null) eventHandler.CharacterOnSwappedItems(fromCollection, fromSlot, toCollection, toSlot); }
public override void TriggerUnstack(ItemCollectionBase toCollection, int toIndex = -1) { // base.TriggerUnstack(toCollection, toIndex); }
private void OnUnstackedItemPly(ItemCollectionBase fromCollection, uint startSlot, ItemCollectionBase toCollection, uint endSlot, uint amount) { if (eventHandler != null) eventHandler.CollectionOnUnstackedItem(startSlot, endSlot, amount); }
public InventoryCollectionLookup(ItemCollectionBase collection, int priority) { this.collection = collection; this.priority = priority; }
public override void OnReset() { items = null; collection = null; }
public void RemoveItemsForPlugin(PluginIdentity identity) { _menuIndex.RemoveItemsForPlugin(identity); ItemCollectionBase.RemoveItems(Items, identity); }
public override void OnReset() { item = null; amount = 1; collection = null; }
public override void OnEnable() { base.OnEnable(); item = (ItemCollectionBase)target; //serializer = new SerializedObject(target); serializer = serializedObject; collectionName = serializer.FindProperty("collectionName"); restrictByWeight = serializer.FindProperty("restrictByWeight"); restrictMaxWeight = serializer.FindProperty("restrictMaxWeight"); itemButtonPrefab = serializer.FindProperty("itemButtonPrefab"); items = serializer.FindProperty("_items"); useReferences = serializer.FindProperty("useReferences"); canDropFromCollection = serializer.FindProperty("canDropFromCollection"); canUseFromCollection = serializer.FindProperty("canUseFromCollection"); canDragInCollection = serializer.FindProperty("canDragInCollection"); canPutItemsInCollection = serializer.FindProperty("canPutItemsInCollection"); canStackItemsInCollection = serializer.FindProperty("canStackItemsInCollection"); manuallyDefineCollection = serializer.FindProperty("manuallyDefineCollection"); container = serializer.FindProperty("container"); onlyAllowTypes = serializer.FindProperty("_onlyAllowTypes"); itemManager = Editor.FindObjectOfType <ItemManager>(); if (itemManager == null) { Debug.LogError("No item manager found in scene, cannot edit item."); } manualItemsList = new ReorderableList(serializer, items, true, true, true, true); manualItemsList.drawHeaderCallback += rect => { EditorGUI.LabelField(rect, "Select items"); }; manualItemsList.drawElementCallback += (rect, index, active, focused) => { rect.height = 16; rect.y += 2; EditorGUI.PropertyField(rect, items.GetArrayElementAtIndex(index)); }; onlyAllowTypesList = new ReorderableList(serializer, onlyAllowTypes, false, true, true, true); onlyAllowTypesList.drawHeaderCallback += rect => { EditorGUI.LabelField(rect, "Restrict by type, leave empty to allow all types"); }; onlyAllowTypesList.drawElementCallback += (rect, index, active, focused) => { rect.height = 16; rect.y += 2; var r = rect; r.width -= 60; EditorGUI.LabelField(r, (item.onlyAllowTypes[index] != null) ? item.onlyAllowTypes[index].FullName : "(NOT SET)"); var r2 = rect; r2.width = 60; r2.height = 14; r2.x += r.width; if (GUI.Button(r2, "Set")) { var typePicker = InventoryItemTypePicker.Get(); typePicker.Show(InventoryEditorUtil.GetItemDatabase(true, false)); typePicker.OnPickObject += type => { item._onlyAllowTypes[index] = type.AssemblyQualifiedName; GUI.changed = true; // To save.. EditorUtility.SetDirty(target); serializer.ApplyModifiedProperties(); Repaint(); }; } }; }
public override void OnEnable() { base.OnEnable(); item = (ItemCollectionBase)target; //serializer = new SerializedObject(target); serializer = serializedObject; collectionName = serializer.FindProperty("collectionName"); restrictByWeight = serializer.FindProperty("restrictByWeight"); restrictMaxWeight = serializer.FindProperty("restrictMaxWeight"); itemButtonPrefab = serializer.FindProperty("itemButtonPrefab"); items = serializer.FindProperty("_items"); useReferences = serializer.FindProperty("useReferences"); canDropFromCollection = serializer.FindProperty("canDropFromCollection"); canUseFromCollection = serializer.FindProperty("canUseFromCollection"); canDragInCollection = serializer.FindProperty("canDragInCollection"); canPutItemsInCollection = serializer.FindProperty("canPutItemsInCollection"); canStackItemsInCollection = serializer.FindProperty("canStackItemsInCollection"); manuallyDefineCollection = serializer.FindProperty("manuallyDefineCollection"); container = serializer.FindProperty("container"); onlyAllowTypes = serializer.FindProperty("_onlyAllowTypes"); itemManager = Editor.FindObjectOfType<ItemManager>(); if (itemManager == null) Debug.LogError("No item manager found in scene, cannot edit item."); manualItemsList = new ReorderableList(serializer, items, true, true, true, true); manualItemsList.drawHeaderCallback += rect => { EditorGUI.LabelField(rect, "Select items"); }; manualItemsList.drawElementCallback += (rect, index, active, focused) => { rect.height = 16; rect.y += 2; EditorGUI.PropertyField(rect, items.GetArrayElementAtIndex(index)); }; onlyAllowTypesList = new ReorderableList(serializer, onlyAllowTypes, false, true, true, true); onlyAllowTypesList.drawHeaderCallback += rect => { EditorGUI.LabelField(rect, "Restrict by type, leave empty to allow all types"); }; onlyAllowTypesList.drawElementCallback += (rect, index, active, focused) => { rect.height = 16; rect.y += 2; var r = rect; r.width -= 60; EditorGUI.LabelField(r, (item.onlyAllowTypes[index] != null) ? item.onlyAllowTypes[index].FullName : "(NOT SET)"); var r2 = rect; r2.width = 60; r2.height = 14; r2.x += r.width; if (GUI.Button(r2, "Set")) { var typePicker = InventoryItemTypePicker.Get(); typePicker.Show(InventoryEditorUtil.GetItemDatabase(true, false)); typePicker.OnPickObject += type => { item._onlyAllowTypes[index] = type.AssemblyQualifiedName; GUI.changed = true; // To save.. EditorUtility.SetDirty(target); serializer.ApplyModifiedProperties(); Repaint(); }; } }; }
public void SelectFirstWrapperOfCollection(ItemCollectionBase collection) { if (collection.items.Length == 0) { Debug.LogWarning("Collection has no items, can't select first item."); return; } collection[0].Select(); }
public object SerializeCollection(ItemCollectionBase collection) { // Easy save 2 handles all this for us.. return(new ItemCollectionSerializationModel(collection)); }