Exemple #1
0
        // ReSharper restore InconsistentNaming
        public PoolBossItem Clone()
        {
            var clone = new PoolBossItem {
                prefabTransform = prefabTransform,
                instancesToPreload = instancesToPreload,
                isExpanded = isExpanded,
                logMessages = logMessages,
                allowInstantiateMore = allowInstantiateMore,
                itemHardLimit = itemHardLimit,
                allowRecycle = allowRecycle
            };

            return clone;
        }
Exemple #2
0
        // ReSharper restore InconsistentNaming

        public PoolBossItem Clone()
        {
            var clone = new PoolBossItem {
                prefabTransform      = prefabTransform,
                instancesToPreload   = instancesToPreload,
                isExpanded           = isExpanded,
                logMessages          = logMessages,
                allowInstantiateMore = allowInstantiateMore,
                itemHardLimit        = itemHardLimit,
                allowRecycle         = allowRecycle,
                categoryName         = categoryName
            };

            return(clone);
        }
    private void AddPoolItem(Object o)
    {
        // ReSharper disable once PossibleNullReferenceException
        var go = (o as GameObject);
        if (go == null) {
            DTInspectorUtility.ShowAlert("You dragged an object which was not a Game Object. Not adding to Pool Boss.");
            return;
        }

        var newItem = new PoolBossItem { prefabTransform = go.transform };

        UndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _pool, "add Pool Boss Item");

        _pool.poolItems.Add(newItem);
    }
        // ReSharper disable once MemberCanBeMadeStatic.Local
        private void CreatePoolItemClones(PoolBossItem item, bool isDuringAwake) {
            if (!isDuringAwake) {
                Instance.poolItems.Add(item);
            }

            if (item.instancesToPreload <= 0) {
                return;
            }

            if (item.prefabTransform == null) {
                if (isDuringAwake) {
                    LevelSettings.LogIfNew("You have an item in Pool Boss with no prefab assigned in category: " + item.categoryName);
                } else {
                    LevelSettings.LogIfNew("You are attempting to add a Pool Boss Item with no prefab assigned.");
                }
                return;
            }

            var itemName = item.prefabTransform.name;
            if (PoolItemsByName.ContainsKey(itemName)) {
                LevelSettings.LogIfNew("You have more than one instance of '" + itemName + "' in Pool Boss. Skipping the second instance.");
                return;
            }

            var itemClones = new List<Transform>();

            for (var i = 0; i < item.instancesToPreload; i++) {
                var createdObjTransform = InstantiateForPool(item.prefabTransform, i + 1);
                itemClones.Add(createdObjTransform);
            }

            var instanceList = new PoolItemInstanceList(itemClones) {
                LogMessages = item.logMessages,
                AllowInstantiateMore = item.allowInstantiateMore,
                SourceTrans = item.prefabTransform,
                ItemHardLimit = item.itemHardLimit,
                AllowRecycle = item.allowRecycle
            };

            if (Instance._categories.Find(delegate(PoolBossCategory x) { return x.CatName == item.categoryName; }) == null) {
                Instance._categories.Add(new PoolBossCategory() {
                    CatName = item.categoryName,
                    IsExpanded = true,
                    IsEditing = false
                });
            }

            PoolItemsByName.Add(itemName, instanceList);
        }
        /// <summary>
        /// This method allows you to add a new Pool Item at runtime.
        /// </summary>
        /// <param name="itemTrans">The Transform of the item.</param>
        /// <param name="preloadInstances">The number of instances to preload.</param>
        /// <param name="canInstantiateMore">Can instantiate more or not</param>
        /// <param name="hardLimit">Item Hard Limit</param>
        /// <param name="logMsgs">Log messages during spawn and despawn.</param>
        /// <param name="catName">Category name</param>
        public static void CreateNewPoolItem(Transform itemTrans, int preloadInstances, bool canInstantiateMore, int hardLimit, bool logMsgs, string catName) {
            var newItem = new PoolBossItem() {
                prefabTransform = itemTrans,
                instancesToPreload = preloadInstances,
                allowInstantiateMore = canInstantiateMore,
                itemHardLimit = hardLimit,
                isExpanded = true,
                logMessages = logMsgs,
                categoryName = catName
            };

            if (string.IsNullOrEmpty(catName)) {
                newItem.categoryName = Instance._categories[0].CatName;
            }

            Instance.CreatePoolItemClones(newItem, false);
        }