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
/// The message sent when the player is updating the level. | |
class BlockAddMessage : MessageBase | |
{ | |
public float px; | |
public float pz; | |
public float height; | |
public int blocktype; | |
} |
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
case LevelMsgType.EmoteSingleSender: | |
/// Receiving a single emote from a player. | |
{ | |
SendEmoteMessageAndClientID m = netMsg.ReadMessage<SendEmoteMessageAndClientID> (); | |
sendAllClientEmote(m.netId, m.emoteType); | |
Debug.Log ("Emote Received from Client."); | |
} | |
break; | |
case LevelMsgType.ResourceUpdate: |
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
//Send all clients an emote | |
void sendAllClientEmote(NetworkInstanceId netId, int emote) | |
{ | |
foreach(KeyValuePair<int, ClientDetails> entry in playerMonitoring) | |
{ | |
SendEmoteMessageAndClientID m = new SendEmoteMessageAndClientID (); | |
m.emoteType = emote; | |
m.netId = netId; | |
NetworkServer.SendToClient (entry.Key, LevelMsgType.EmoteSingleSender, m); | |
} |
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
/// Resource brick generator. | |
/// Randomly generates resources and adds them to the brickstructure[]. | |
public void resourceBrickGenerator() | |
{ | |
for (int i = 0; i < 100; i++) | |
{ | |
Vector3 pos = new Vector3 ((int) UnityEngine.Random.Range (0f, 100.0f) + 0.5f, Math.Max ((int) (UnityEngine.Random.Range (0f, 12.0f)), (int) WorldManager.minLevelHeight), (int) UnityEngine.Random.Range (0f, 100.0f) + 0.5f); | |
int blockHeight = (int) (pos.y - WorldManager.minLevelHeight); | |
levelStructure.setBlock(pos.x + 0.5f, pos.z + 0.5f, blockHeight, 5, -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
/// Receiving a single emote from a player. | |
public const short EmoteSingleReceiver = MsgType.Highest + 5; | |
/// Send emote and playerID of emote sender to each client. | |
public const short EmoteSingleSender = MsgType.Highest + 6; | |
/// Send Resource update from client to server. | |
public const short ResourceUpdate = MsgType.Highest + 7; | |
/// Send Send and receive a player flag request. |
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)) |
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 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
// 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 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; | |
} |