public void SetAttributes(Dictionary <string, string> attributesToSet) { ExampleManager.NetSend("setAttribute", new ExampleAttributeUpdateMessage() { entityId = state.id, attributesToSet = attributesToSet }); }
public void GotNewTargetLineUp(ShootingGalleryNewTargetLineUpMessage targetLineUp) { if (targetLineUp == null || targetLineUp.targets == null) { LSLog.LogError("No targets came in"); return; } targetCount = targetLineUp.targets.Length; newTargets = new List <ShootingGalleryTargetModel>(); for (int i = 0; i < targetLineUp.targets.Length; ++i) { if (!trackedTargets.Contains(targetLineUp.targets[i].uid)) { newTargets.Add(targetLineUp.targets[i]); trackedTargets.Add(targetLineUp.targets[i].uid); } } SpawnTargets(newTargets); string userID = ExampleManager.Instance.CurrentUser.id; ExampleManager.NetSend("setAttribute", new ExampleAttributeUpdateMessage { userId = userID, attributesToSet = new Dictionary <string, string> { { "readyState", "ready" } } }); }
//Take Serializes changes in the tranform and pass those changes to the server protected virtual void UpdateStateFromView() { previousState = state.Clone(); //Copy Transform to State (round position to fix floating point issues with state compare) state.xPos = (float)System.Math.Round((decimal)transform.localPosition.x, 4); state.yPos = (float)System.Math.Round((decimal)transform.localPosition.y, 4); state.zPos = (float)System.Math.Round((decimal)transform.localPosition.z, 4); state.xRot = transform.localRotation.x; state.yRot = transform.localRotation.y; state.zRot = transform.localRotation.z; state.wRot = transform.localRotation.w; state.xScale = transform.localScale.x; state.yScale = transform.localScale.y; state.zScale = transform.localScale.z; state.xVel = localPositionDelta.x; state.yVel = localPositionDelta.y; state.zVel = localPositionDelta.z; ////No need to update again if last sent state == current view modified state if (localUpdatedState != null) { //TODO: Uses reflection so might be slow, replace with defined compare to improve speed List <ExamplePropertyCompareResult> changesLocal = Compare(localUpdatedState, state); if (changesLocal.Count == 0 || (changesLocal.Count == 1 && changesLocal[0].Name == "timestamp")) { return; } } //TODO: Uses reflection so might be slow, replace with defined compare to improve speed List <ExamplePropertyCompareResult> changes = Compare(previousState, state); //Transform has been update locally, push changes if (changes.Count > 0) { //Create Change Set Array for NetSend object[] changeSet = new object[(changes.Count * 2) + 1]; changeSet[0] = state.id; int saveIndex = 1; for (int i = 0; i < changes.Count; i++) { changeSet[saveIndex] = changes[i].Name; changeSet[saveIndex + 1] = changes[i].NewValue; saveIndex += 2; } localUpdatedState = state.Clone(); ExampleManager.NetSend("entityUpdate", changeSet); } }
public void PlayerReadyToPlay() { uiController.UpdatePlayerReadiness(false); ExampleManager.NetSend("setAttribute", new ExampleAttributeUpdateMessage { userId = ExampleManager.Instance.CurrentUser.id, attributesToSet = new Dictionary <string, string> { { "readyState", "ready" } } }); PlayerController player = GetPlayerView(ExampleManager.Instance.CurrentNetworkedEntity.id); if (player != null) { player.SetPause(false); player.UpdateReadyState(true); } }