private void SpawnItem(SpawnableItem spawnItem, Vector3 position) { Quaternion randomOrientation = Quaternion.Euler(0, 0, Random.Range(-45, 45)); currentSpawnIndex = (currentSpawnIndex + 1 >= spawnableItemsList.Count) ? 0 : (currentSpawnIndex + 1); List <Vector3> deltaSpawns = new List <Vector3>() { Vector3.zero, 2 * (Vector3.right + Vector3.up), 2 * (-Vector3.right + Vector3.up), -2 * (Vector3.right + Vector3.up), 2 * (Vector3.right - Vector3.up), -2 * Vector3.right, -2 * Vector3.up, 2 * Vector3.up, 2 * Vector3.right }; int currentIndex = 0; Vector3 deltaSpawn = deltaSpawns[currentIndex]; for (int i = 0; i < spawnItem.count; i++) { GameObject spawnedItem = Instantiate(spawnItem.prefab, position + deltaSpawn, randomOrientation, this.transform); if (spawnedItem.GetComponent <Collider2D>() != null) { allItemsColliders.Add(spawnedItem.GetComponent <Collider2D>()); } currentIndex++; deltaSpawn = deltaSpawns[currentIndex]; deltaSpawn += Random.Range(-0.1f, 0.1f) * Vector3.right + Random.Range(-0.2f, 0.2f) * Vector3.up; } }
public override void onSpawn() { Debug.Log("item Val: " + itemValue); Debug.Log("Spawning: " + int.Parse(itemQuantity.text) + " " + (Values)ItemValue + " " + ItemName); for (int i = 0; i < int.Parse(itemQuantity.text); i++) { spawnSpace += 0.25f; Vector3 worldSpawnLocation = new Vector3(2.4f - spawnSpace, 2.59f, 3.7f); Quaternion rotationValue = new Quaternion(0, 180f, 0, 0); var spawnObject = Instantiate(itemPrefabList[itemValue.value], worldSpawnLocation, rotationValue, workBenchSpawnedItems.transform); spawnObject.AddComponent <MeshRenderer>(); spawnObject.AddComponent <BoxCollider>(); spawnObject.GetComponent <BoxCollider>().isTrigger = true; spawnObject.GetComponent <BoxCollider>().size = new Vector3(0.025f, 0.025f, 0.025f); spawnObject.gameObject.AddComponent <ResistorSelect>(); spawnObject.tag = "Selectable"; SpawnableItem resistor = new SpawnableItem(ItemName, ItemValue); Globals.inventoryItems.Add(resistor); if (itemValue.value == 0) { spawnObject.GetComponent <ResistorSelect>().resistorLabel = 210; } else if (itemValue.value == 1) { spawnObject.GetComponent <ResistorSelect>().resistorLabel = 300; } else { spawnObject.GetComponent <ResistorSelect>().resistorLabel = 470; } } }
void freezeObject() { GameObject o; if (itemInHands != null) { o = itemInHands; } else { o = playerRaycast(playerRange); } Rigidbody rb = o.GetComponent <Rigidbody>(); SpawnableItem si = o.GetComponent <SpawnableItem>(); if (rb != null && si != null) { if (o == itemInHands) { itemInHands = null; } if (rb.isKinematic == false) { rb.isKinematic = true; } else { rb.isKinematic = false; } } }
public void SetNextSpawnItemType(ItemType item) { if (item == ItemType.APPLE) { selectedNextSpawnableItem = allSpawnableItems[0]; } else if (item == ItemType.BOUNCING_BALL) { selectedNextSpawnableItem = allSpawnableItems[1]; } else if (item == ItemType.BUBBLE) { selectedNextSpawnableItem = allSpawnableItems[2]; } else if (item == ItemType.ANVIL) { selectedNextSpawnableItem = allSpawnableItems[3]; } else if (item == ItemType.GLASS) { selectedNextSpawnableItem = allSpawnableItems[4]; } else if (item == ItemType.DUCK) { selectedNextSpawnableItem = allSpawnableItems[5]; } else if (item == ItemType.BLACK_HOLE) { selectedNextSpawnableItem = allSpawnableItems[6]; } }
public void RemoveItem() { isFree = true; slotPair = null; itemPlaced = null; ChangeHighlightColor(); }
// Start is called before the first frame update void Start() { currentSpawnIndex = 0; instance = this; currentVisibleSpawnEffectGo = null; allItemsColliders = new List <Collider2D>(); blackHole = null; selectedNextSpawnableItem = null; }
void Start() { if (permaSlot == true) { SpawnableItem wire = new SpawnableItem(Globals.AvailableItems.Wire, 0, true); itemPlaced = wire; isFree = false; ChangeHighlightColor(); } }
void deleteObject() { GameObject o = playerRaycast(playerRange); SpawnableItem sp = o.GetComponent <SpawnableItem>(); if (o != null && sp != null) { Debug.Log("deleted " + o.name); controller.freeResources(o); controller.updateStatus("deleted " + sp.name); Destroy(o); } }
public override void onSpawn() { Debug.Log("Spawning: " + int.Parse(itemQuantity.text) + " " + (Values)ItemValue + " " + ItemName); for (int i = 0; i < int.Parse(itemQuantity.text); i++) { spawnSpace += 0.05f; Vector3 worldSpawnLocation = new Vector3(2.4f - spawnSpace, 2.6f, 3.5f); Quaternion rotationValue = new Quaternion(0, 0, 0, 0); var spawnObject = Instantiate(itemPrefab, worldSpawnLocation, rotationValue, workBenchSpawnedItems.transform); spawnObject.GetComponent <WireSelect>().Colour = ItemValue; SpawnableItem wire = new SpawnableItem(ItemName, ItemValue); Globals.inventoryItems.Add(wire); } }
private ItemProgressionRaw GetItemProgressionRaw(SpawnableItem item, out ResearchProgression progressionItem, ItemQuality quality = ItemQuality.Normal, bool itemActive = false) { var category = ModManager.Instance.AvailableCategories.FirstOrDefault(c => I18n.GetByKey(c.Label).ToString().Equals(item.Category)); // if (itemActive) // { // _monitor.Log($"Current item - name: {item.Name}, ID: {item.ID}, category: {item.Category}", // LogLevel.Alert); // _monitor.Log($"Unique key: {Helpers.GetItemUniqueKey(item.Item)}", // LogLevel.Alert); // } var maxProgression = ModManager.Instance.ModMode switch { ModMode.Buy => 1, _ => category?.ResearchCount ?? 1 }; progressionItem = TryInitAndReturnProgressionItem(item.Item); var itemProgression = quality switch { ItemQuality.Silver => progressionItem.ResearchCountSilver, ItemQuality.Gold => progressionItem.ResearchCountGold, ItemQuality.Iridium => progressionItem.ResearchCountIridium, _ => progressionItem.ResearchCount }; itemProgression = (int)MathHelper.Clamp(itemProgression, 0, maxProgression); return(new ItemProgressionRaw { current = itemProgression, max = maxProgression }); }
private IEnumerator WaitAndSpawnItem(SpawnableItem spawnItem, Vector3 position, float waitDelay) { yield return(new WaitForSeconds(waitDelay)); SpawnItem(spawnItem, position); }
public override void onSpawn() { Debug.Log("Spawning: " + int.Parse(itemQuantity.text) + " " + (Values)ItemValue + " " + ItemName); for (int i = 0; i < int.Parse(itemQuantity.text); i++) { spawnSpace += 0.20f; Vector3 worldSpawnLocation = new Vector3(2.4f - spawnSpace, 2.67f, 3.9f); Quaternion rotationValue = new Quaternion(0, 0, 0, 0); var spawnObject = Instantiate(itemPrefab, worldSpawnLocation, rotationValue, workBenchSpawnedItems.transform); spawnObject.gameObject.AddComponent <CapacitorSelect>(); spawnObject.AddComponent <MeshRenderer>(); spawnObject.AddComponent <BoxCollider>(); spawnObject.GetComponent <BoxCollider>().isTrigger = true; spawnObject.GetComponent <BoxCollider>().size = new Vector3(0.025f, 0.025f, 0.025f); spawnObject.tag = "Selectable"; SpawnableItem capacitor = new SpawnableItem(ItemName, ItemValue); Globals.inventoryItems.Add(capacitor); float capacitorVal = 0; switch (itemValue.value) { case (0): capacitorVal = 0.0000001f; break; case (1): capacitorVal = 0.000001f; break; case (2): capacitorVal = 0.000004f; break; case (3): capacitorVal = 0.000005f; break; case (4): capacitorVal = 0.000009f; break; case (5): capacitorVal = 0.000012f; break; case (6): capacitorVal = 0.000015f; break; case (7): capacitorVal = 0.000019f; break; case (8): capacitorVal = 0.000020f; break; default: break; } spawnObject.GetComponent <CapacitorSelect>().CapacitorValue = capacitorVal; } }