Last active
October 6, 2017 06:43
-
-
Save AndrewWeston9/3a682f177bd3e72eb629904970c9519f to your computer and use it in GitHub Desktop.
WorldManager.cs Snippet: Update Resource block levels by passing location and amount to adjust by.
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
/// Update a change of resource in the level structure. | |
public void updateResource(float x, float y, float z, int amount) | |
{ | |
int rx = ((int) x) % blockSize; | |
int ry = ((int) y) % blockSize; | |
int rz = ((int) z); | |
RegionBlock rb = getRegion (x, y); | |
if (rb != null) | |
{ | |
rb.updateBlockHealth (rx, ry, rz, amount); | |
int blockHealth = rb.getBlockHealth (rx, ry, rz); | |
//Debug.LogError ("Health of block: " + blockHealth.ToString ()); | |
if (blockHealth < 1) | |
{ | |
rb.deleteBlock(rx, ry, rz); | |
refreshMesh (); | |
} | |
} | |
refreshMesh (); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment