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
if (Input.GetKeyDown(KeyCode.LeftControl) && (isGrounded () || attached)) | |
{ | |
if (playerFlagPlaced == false || currentBlockType != 10) | |
{ | |
if(!checkFlagRange() && (checkResource() || currentBlockType == 10 || currentBlockType == 1)) | |
{ | |
int px = (int)(playerpos.x + 0.5f); | |
int py = Math.Max ((int)(playerpos.y), (int)WorldManager.minLevelHeight); | |
int pz = (int)(playerpos.z + 0.5f); |
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 placeBlock (float x, float z, float height, int type) | |
{ | |
// Coordinates for the region block - only horizontal elements. | |
Vector3 llbpos = new Vector3 (x, 0.0f, z); | |
LocalLevelBlock llb = findLevelBlock (llbpos); | |
int blockHeight = (int) (height - WorldManager.minLevelHeight); | |
if (llb != null) | |
{ | |
Vector3 regionpos = new Vector3 (x - llb.region.blockCoordX, z - llb.region.blockCoordY, blockHeight); |
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 struct brickClass | |
{ | |
/// stores the type of brick. | |
public int brickType; | |
/// Stores the current health of the brick. 0 would mean it is destroyed. | |
public int brickHealth; | |
/// Stores the connection id for the player that placed the brick. Is -1 if generated by the server. | |
public int playerConnectionId; | |
} |
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
for (int k = 0; k < MaxBlockHeight; k += 1) | |
{ | |
if (k < zc) | |
{ | |
int rand = (int) UnityEngine.Random.Range (0f, 100f); | |
if (rand <= 70) | |
{ | |
blockStructure [getIndex (i, j, k)].brickType = 1; | |
blockStructure [getIndex (i, j, k)].brickHealth = 1; | |
blockStructure [getIndex (i, j, k)].playerConnectionId = -1; |
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; |
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; | |
} |
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
// Checks to see if the flag can be removed by the player requesting the removal or not. | |
public bool removeFlag(int x, int y, int z, int connid) | |
{ | |
if ((x >= 0) && (x < blockSize) && | |
(y >= 0) && (y < blockSize) && | |
(z >= 0) && (z < MaxBlockHeight)) | |
{ | |
if (blockStructure [getIndex (x, y, z)].playerConnectionId == connid) | |
{ | |
return true; |
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 placeSingleBlock (GameObject block, Vector3 position, Transform parentObjectTransform) | |
{ | |
Vector3 blockpos; | |
if (block.tag == "Flag") | |
{ | |
blockpos = new Vector3 (position.x, position.z - 0.5f, position.y); | |
} | |
else | |
{ |
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) |
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 updateFlag(float x, float y, float z, int connid) | |
{ | |
int rx = ((int) x) % blockSize; | |
int ry = ((int) y) % blockSize; | |
int rz = ((int) z); | |
RegionBlock rb = getRegion (x, y); | |
if (rb != null) | |
{ | |
if (rb.removeFlag (rx, ry, rz + 1, connid)) |
OlderNewer