// <summary> Set the topp layer to grass </summary> private void GenerateGrassLayer() { 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); noiseHeight = Mathf.Clamp(noiseHeight, 0, 500); Block b = new Block_Grass(new Vector3(i, noiseHeight, j)); worldBlocks[i, noiseHeight, 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_Grass(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 } } }