Last active
October 6, 2017 06:44
-
-
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.
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 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