Last active
October 6, 2017 06:44
-
-
Save AndrewWeston9/9fabc5c173522395b0ea3a6f6babf9a2 to your computer and use it in GitHub Desktop.
WorldManager.cs Snippet: Retrieving block health, updating block health, deleting a block.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int getBlockHealth (int x, int y, int z) | |
{ | |
if ((x >= 0) && (x < blockSize) && | |
(y >= 0) && (y < blockSize) && | |
(z >= 0) && (z < MaxBlockHeight)) | |
{ | |
return blockStructure[getIndex (x, y, z)].brickHealth; | |
} | |
return 0; | |
} | |
public void updateBlockHealth(int x, int y, int z, int amount) | |
{ | |
if ((x >= 0) && (x < blockSize) && | |
(y >= 0) && (y < blockSize) && | |
(z >= 0) && (z < MaxBlockHeight)) | |
{ | |
blockStructure[getIndex (x, y, z)].brickHealth = blockStructure[getIndex (x, y, z)].brickHealth + amount; | |
//Debug.LogError ("updating block health"); | |
} | |
} | |
public void deleteBlock(int x, int y, int z) | |
{ | |
if ((x >= 0) && (x < blockSize) && | |
(y >= 0) && (y < blockSize) && | |
(z >= 0) && (z < MaxBlockHeight)) | |
{ | |
blockStructure[getIndex (x, y, z)].brickType = 0; | |
blockStructure[getIndex (x, y, z)].brickHealth = 0; | |
blockStructure[getIndex (x, y, z)].playerConnectionId = 0; | |
} | |
updateTimeStamp (); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment