private void receivePlayersUpdate(NetIncomingMessage im) { int count = im.ReadInt32(); for (int i = 0; i < count; i++) { BeingNetworkState state = BeingNetworkState.readState(im); if (gameref.players.ContainsKey(state.guid)) { Being player = gameref.players[state.guid]; if (!player.isLocal) { player.body.LinearVelocity = state.velocity; Vector2 difference = state.position - player.body.Position; player.body.Position = player.body.Position + (difference * .1f); player.isFacingLeft = state.isFacingLeft; player.CurrentHealth = state.currentHP; player.stunDuration = state.stunDuration; player.body.Tag = state.tag; if (state.depth != player.getDepth()) { player.timeOfLastDepthChange = Environment.TickCount; player.setDepth(state.depth); player.isMovingUp = state.isMovingUp; } } } } }
private void receiveEnemiesUpdate(NetIncomingMessage im) { int count = im.ReadInt32(); for (int i = 0; i < count; i++) { BeingNetworkState state = BeingNetworkState.readState(im); if (gameref.spawnManager.enemies.ContainsKey(state.guid)) { Enemy enemy = gameref.spawnManager.enemies[state.guid]; enemy.body.LinearVelocity = state.velocity; Vector2 difference = state.position - enemy.body.Position; enemy.body.Position = enemy.body.Position + (difference * .1f); enemy.isFacingLeft = state.isFacingLeft; enemy.CurrentHealth = state.currentHP; if (state.depth != enemy.getDepth()) { enemy.timeOfLastDepthChange = Environment.TickCount; enemy.setDepth(state.depth); } } } }