public ItemFactory() { m_Random = new Random(); m_HelmetGenerator = new HelmetGenerator(m_Random, new FileLog(@"C:\Users\leeok\Desktop\logs\helmetgenerator.txt")); m_ChestplateGenerator = new ChestplateGenerator(m_Random, new FileLog(@"C:\Users\leeok\Desktop\logs\chestgenerator.txt")); m_PlatelegsGenerator = new PlatelegsGenerator(m_Random, new FileLog(@"C:\Users\leeok\Desktop\logs\legsgenerator.txt")); m_WeaponGenerator = new WeaponGenerator(m_Random, new FileLog(@"C:\Users\leeok\Desktop\logs\weapongenerator.txt")); }
public override void Awake() { base.Awake(); generator = new BasicItemGenerator(); generator.SetItems(ItemManager.database.items); var itemsTemp = generator.Generate(minAmount.Value, maxAmount.Value); items.objectReferences = itemsTemp; }
public override void Awake() { base.Awake(); generator = new BasicItemGenerator(); #if UNITY_EDITOR var m = Editor.FindObjectOfType<ItemManager>(); generator.SetItems(m.items); #else generator.SetItems(ItemManager.instance.items); #endif generator.Generate(minAmount.Value, maxAmount.Value); }
public override void Awake() { base.Awake(); generator = new BasicItemGenerator(); #if UNITY_EDITOR var m = Editor.FindObjectOfType <ItemManager>(); generator.SetItems(m.items); #else generator.SetItems(ItemManager.instance.items); #endif generator.Generate(minAmount.Value, maxAmount.Value); }
public override BlockReturn Run(BlockReturn param) { generator = new BasicItemGenerator(); #if UNITY_EDITOR var m = Editor.FindObjectOfType <ItemManager>(); generator.SetItems(m.items); #else generator.SetItems(ItemManager.instance.items); #endif this.items = generator.Generate(minAmount.value, maxAmount.value); return(BlockReturn.OK); }
protected virtual InventoryItemBase[] GenerateItems() { canGenerateItems = false; generator = new FilterGroupsItemGenerator(filterGroups); generator.SetItems(ItemManager.database.items); var items = generator.Generate(minAmountTotal, maxAmountTotal, true); // Create instances is required to get stack size to work (Can't change stacksize on prefab) foreach (var item in items) { item.transform.SetParent(transform); item.gameObject.SetActive(false); } return(items); }
public virtual void CreateGenerator() { var generator = new BasicItemGenerator(); generator.SetItems(ItemManager.instance.items, 1.0f); generator.onlyOfType = new List <System.Type>(vendorUI.onlyAllowTypes); //generator.maxBuyPrice = 50; //generator.onlyOfType.Add(typeof(ConsumableInventoryItem)); //generator.onlyOfType.Add(typeof(UnusableInventoryItem)); itemGenerator = generator; if (generateItems) { forSale = itemGenerator.Generate(generateItemsCount); } }
protected void Awake() { container = GetComponent <IInventoryItemContainer>(); generator = new FilterGroupsItemGenerator(filterGroups); generator.SetItems(ItemManager.database.items); if (generateAtGameStart) { container.items = generator.Generate(minAmountTotal, maxAmountTotal, true); // Create instances is required to get stack size to work (Can't change stacksize on prefab) foreach (var item in container.items) { item.transform.SetParent(transform); } } }
public override void Generate(ISystemContainer systemContainer, GeneratedBranch generatedBranch, IEntity branch, IRandom random, IProgress <string> progress) { progress.Report("Generating random items"); var power = BasePower; var itemList = GetItemList(systemContainer, branch); IItemGenerator itemGenerator = GetItemGenerator(systemContainer, itemList); foreach (var map in generatedBranch.Maps) { FillMap(map, systemContainer, power, itemList, random, itemGenerator); power += PowerIncrement; } }
public async Task FillRepositoryAsync(IItemGenerator generator) { Logger.Trace("FillRepository start"); List <Item> items = generator.GenerateItems().Cast <Item>().ToList(); using (var context = ContextFactory.CreateDbContext()) { if (context.Database.IsSqlServer()) { await context.BulkInsertAsync(items, new BulkConfig { BulkCopyTimeout = 600 }); Logger.Trace($"FillRepository: {items.Count} items has been inserted into DB"); } else { context.Items.AddRange(items); await context.SaveChangesAsync(); } } }
public virtual void CreateGenerator() { var generator = new BasicItemGenerator(); generator.SetItems(ItemManager.instance.items, 1.0f); generator.onlyOfType = new List<System.Type>(InventoryManager.instance.vendor.onlyAllowTypes); //generator.maxBuyPrice = 50; //generator.onlyOfType.Add(typeof(ConsumableInventoryItem)); //generator.onlyOfType.Add(typeof(UnusableInventoryItem)); itemGenerator = generator; if (generateItems) { var t = itemGenerator.Generate(minAmount, maxAmount); items = new InventoryItemBase[t.Length]; for (int i = 0; i < items.Length; i++) { items[i] = GameObject.Instantiate<InventoryItemBase>(t[i]); items[i].gameObject.SetActive(false); items[i].transform.SetParent(transform); } } }
public virtual void CreateGenerator() { var generator = new BasicItemGenerator(); generator.SetItems(ItemManager.instance.items, 1.0f); generator.onlyOfType = new List <System.Type>(InventoryManager.instance.vendor.onlyAllowTypes); //generator.maxBuyPrice = 50; //generator.onlyOfType.Add(typeof(ConsumableInventoryItem)); //generator.onlyOfType.Add(typeof(UnusableInventoryItem)); itemGenerator = generator; if (generateItems) { var t = itemGenerator.Generate(minAmount, maxAmount); items = new InventoryItemBase[t.Length]; for (int i = 0; i < items.Length; i++) { items[i] = GameObject.Instantiate <InventoryItemBase>(t[i]); items[i].gameObject.SetActive(false); items[i].transform.SetParent(transform); } } }
public override void OnAwake() { base.OnAwake(); generator = new BasicItemGenerator(); }
private void SpawnItem(IMap map, ISystemContainer systemContainer, int power, List <IEntity> itemList, IRandom random, IItemGenerator itemGenerator) { int retries = 25; MapCoordinate emptyLocation = null; IEntity item = null; for (int i = 0; i < retries; i++) { emptyLocation = map.GetQuickEmptyPosition(systemContainer.PositionSystem, random); if (emptyLocation != null) { break; } } if (emptyLocation == null) { return; } for (int i = 0; i < retries; i++) { var itemLevel = random.Between(0, power + 2); item = itemGenerator.GenerateItem(itemList, itemLevel, random); if (item != null) { break; } } if (item == null) { return; } systemContainer.PositionSystem.SetPosition(item, emptyLocation); }
private void FillMap(IMap map, ISystemContainer systemContainer, int power, List <IEntity> itemList, IRandom random, IItemGenerator itemGenerator) { var mapSize = map.Cells.Count; var numberOfItems = (int)Math.Ceiling(Density * mapSize); for (int i = 0; i < numberOfItems; i++) { SpawnItem(map, systemContainer, power, itemList, random, itemGenerator); } }
public void ItemClicked(IItemGenerator slotResourceBuilding, Item itemData) { throw new NotImplementedException(); }
public void DragItem(IItemGenerator slotResourceBuilding, Item itemData, Vector2 pos) { }
public void DragItemEnd(IItemGenerator slotResourceBuilding, Item itemData, Vector2 pos) { _dragging = false; _elapsedSinceLastDragFinished = 0; // Valid resource generator? Recipe recipeData; bool clear = true; SlotRecipesBuilding buildingSlot = FindRecipeBuildingSlotForItemAtPosition(pos, itemData, out recipeData); if (buildingSlot != null) { if (buildingSlot.MissingRecipe) { clear = buildingSlot.SetActiveRecipe(recipeData, itemData); } else { buildingSlot.AddRequirement(itemData); } if (clear) { slotResourceBuilding.ClearContents(); } else { slotResourceBuilding.ResetSlot(); } return; } foreach (var slot in ActiveClientRequestSlots) { if (!slot.Active) { continue; } if (!slot.ContainsPosition(pos)) { continue; } if (slot.IsRequestedItem(itemData)) { slot.GiveItem(itemData.ItemID); slotResourceBuilding.ClearContents(); } } foreach (var wasteland in ActiveDisposalFacilities) { if (wasteland.OverlapsPoint(pos)) { slotResourceBuilding.ClearContents(); return; } } // Otherwise: slotResourceBuilding.ResetSlot(); }
public void DragItemStart(IItemGenerator slotResourceBuilding, Item itemData, Vector2 pos) { _dragging = true; _elapsedSinceLastDragFinished = -1; }
public virtual void CreateGenerator() { var generator = new BasicItemGenerator(); generator.SetItems(ItemManager.instance.items, 1.0f); generator.onlyOfType = new List<System.Type>(vendorUI.onlyAllowTypes); //generator.maxBuyPrice = 50; //generator.onlyOfType.Add(typeof(ConsumableInventoryItem)); //generator.onlyOfType.Add(typeof(UnusableInventoryItem)); itemGenerator = generator; if(generateItems) forSale = itemGenerator.Generate(generateItemsCount); }