Skip to content

Instantly share code, notes, and snippets.

@AndrewWeston9
Last active October 6, 2017 06:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndrewWeston9/303ff64c6844bb47e1296229e6035257 to your computer and use it in GitHub Desktop.
Save AndrewWeston9/303ff64c6844bb47e1296229e6035257 to your computer and use it in GitHub Desktop.
WorldManager.cs Snippet: Setting the blocks health, type, and player connection id when placing a block.
public void setBlock (int x, int y, int z, int type, int connid)
{
if ((x >= 0) && (x < blockSize) &&
(y >= 0) && (y < blockSize) &&
(z >= 0) && (z < MaxBlockHeight))
{
blockStructure[getIndex (x, y, z)].brickType = type;
blockStructure[getIndex (x, y, z)].playerConnectionId = connid;
if (type == 1) {
blockStructure[getIndex (x, y, z)].brickHealth = 1;
}
if (type == 2) {
blockStructure[getIndex (x, y, z)].brickHealth = 5;
}
if (type == 3) {
blockStructure[getIndex (x, y, z)].brickHealth = 10;
}
if (type == 4) {
blockStructure[getIndex (x, y, z)].brickHealth = 25;
}
if (type == 5) {
blockStructure[getIndex (x, y, z)].brickHealth = 2;
}
if (type == 6) {
blockStructure[getIndex (x, y, z)].brickHealth = 5;
}
if (type == 7) {
blockStructure[getIndex (x, y, z)].brickHealth = 10;
}
if (type == 10) {
blockStructure[getIndex (x, y, z)].brickHealth = 9999;
}
// Debug.Log ("Setting " + x + " " + y + " " + z);
updateTimeStamp ();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment