// <summary> Fill columns up with stone to a perlin value </summary> private void GenerateStoneLayer() { for (int i = 0; i < initialWorldSize; i++) { for (int j = 0; j < initialWorldSize; j++) { int noiseHeight = noise.getNoise(i - minX, j - minZ, maxY - minY - 2); for (int k = 0; k < Mathf.Clamp(noiseHeight, 0, 500); k++) { Block b = new Block_Stone(new Vector3(i, k, j)); worldBlocks[i, k, j] = b; } } } }
public override void m_break(int amount) { if (breakable) { m_hardness -= 1; if (m_hardness <= 0) { Main mainscrpt = GameObject.FindObjectOfType <Main>(); mainscrpt.wg.worldBlocks[(int)index.x, (int)index.y, (int)index.z] = null; // unlocate yourself from worldblocks m_hide(); Main mainclass = GameObject.FindObjectOfType <Main>(); mainclass.wg.Draw(mainclass.transform.position); // black magic fuckery Block instance = new Block_Stone(Vector3.zero); // get type of child class and make an instance InventoryItem_Block item = new InventoryItem_Block(instance); // create a new inventory item of type "block" and set its refference to the type of this class(the derived class type) Inventory.AddItem(item); // add dthe inventory item to inventory } } }