public void ObjectPoolInit() { bullet_FourWay_Pool = gameObject.AddComponent<ItemPool>(); bullet_FourWay_Pool.CreateItemPool(bullet_FourWay_Prefab, fourWayNum); bullet_Parabola_Pool = gameObject.AddComponent<ItemPool>(); bullet_Parabola_Pool.CreateItemPool(bullet_Parabola_Prefab, parabolaNum); }
private static void PrintItem(ItemPool.Item item) { FieldInfo[] fields = item.GetType().GetFields(); // Gets all of fields of the current item bool isFirstField = true; foreach (var field in fields) { if (field.GetValue(item) == null) { GameConsole.currentLog.Append("empty \n"); return; } var type = field.GetValue(item).GetType(); if (type == typeof(ItemPool.ClassAbleToWearItem[])) //If the type of the current field is an array of classes able to wear an item we need to print them separately { //Prints the classes able to wear the item GameConsole.currentLog.Append("For: "); object array = field.GetValue(item); IEnumerable enumerable = array as IEnumerable; if (enumerable != null) { foreach (object element in enumerable) { GameConsole.currentLog.Append(element.ToString() + " "); } } GameConsole.currentLog.Append("| "); } else { // Print item field info if (isFirstField) { GameConsole.currentLog.Append("| " + field.GetValue(item).ToString() + " |"); isFirstField = false; } else if (field.GetValue(item).ToString() != "0") { GameConsole.currentLog.Append(field.Name + ": " + field.GetValue(item).ToString() + " | "); } } } GameConsole.currentLog.Append("\n"); }
private static void AddValueToItem(ItemPool.Item currentItem, StreamReader stream, int i, FieldInfo field) { int valueAsInt; float valueAsFloat; string value = stream.ReadLine(); if (int.TryParse(value, out valueAsInt)) { field.SetValue(currentItem, int.Parse(value)); } else if (float.TryParse(value, out valueAsFloat)) { field.SetValue(currentItem, float.Parse(value)); } else if (field.GetValue(currentItem).GetType() == typeof(ItemPool.Slot)) { ItemPool.Slot slot; if (Enum.TryParse(value, true, out slot)) { field.SetValue(currentItem, slot); } } else { field.SetValue(currentItem, value); } }
public void setItemPool(ItemPool itemPool) { this.itemPoolReference = itemPool; }
/// <summary> /// Clear the List between Rounds /// </summary> /// <returns></returns> private bool ClearLists() { ItemPool.Clear(); MonsterList.Clear(); return(true); }
public static List <ItemData> GetPool(ItemPool pool) { return(byPool.TryGetValue(pool.Id, out var b) ? b : new List <ItemData>()); }
public PoolDropsComponent(ItemPool pool, float chance, int min, int max) { Add(new PoolDrop(pool, chance, min, max)); }