// <summary> Set all the blocks below water level to water </summary> private void GenerateWater() { 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); if (noiseHeight <= waterLevel) { for (int a = waterLevel; a > 0; a--) { if (worldBlocks[i, a, j] == null) // if it is an empty block beneath the level of 7, set it to water { worldBlocks[i, a, j] = new Block_Water(new Vector3(i, a, j)); } else // otherwise set it to stone so the bottom of lake is rock { if (a > waterLevel - 1) { worldBlocks[i, a, j] = new Block_Sand(new Vector3(i, a, j)); } } } } } } }
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); // what can i say exept delete this Block instance = new Block_Sand(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 } } }