public VoxelObject SpawnVoxelObject(Swordfish.Position _position) { VoxelComponent component = Instantiate(voxelObjectPrefab, _position.toVector3(), Quaternion.identity).GetComponent <VoxelComponent>(); component.setName("voxelObject" + voxelMaster.voxelObjects.Count); component.setSize(2); component.setStatic(false); component.Initialize(VoxelObjectType.GENERIC); return(component.voxelObject); }
public VoxelObject SpawnAsteroid(Swordfish.Position _position) { VoxelComponent component = Instantiate(voxelObjectPrefab, _position.toVector3(), Quaternion.identity).GetComponent <VoxelComponent>(); component.setName("asteroid" + voxelMaster.voxelObjects.Count); component.setSize(4); component.setStatic(true); component.Initialize(VoxelObjectType.ASTEROID); return(component.voxelObject); }
public Item DropItemNaturally(Swordfish.Position _position, Item _item, int _count = 1) { Vector3 offset = new Vector3(UnityEngine.Random.value - 0.5f, UnityEngine.Random.value - 0.5f, UnityEngine.Random.value - 0.5f) * 0.5f; GameObject temp = (GameObject)Instantiate(droppedItemPrefab, _position.toVector3() + offset, Quaternion.identity); DroppedItem dropped = temp.GetComponent <DroppedItem>(); Item item = _item.copy(); item.setAmount(_count); dropped.setItem(item); return(item); }