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" } } }); }
public void SetAttributes(Dictionary <string, string> attributesToSet) { ExampleManager.NetSend("setAttribute", new ExampleAttributeUpdateMessage() { entityId = state.id, attributesToSet = attributesToSet }); }
public override void Run() { ExampleManager manager = new ExampleManager(); if (DownloadAll is bool downloadAll && downloadAll) { manager.DownloadAllProjects(); }
//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 ValidateExampleWithoutGenerics_FailCondition1_Condition2Condition3DoWork_StillRun() { ExampleManager manager = new ExampleManager(); ExampleRequest request = new ExampleRequest() { SomeVariable = "A", SomeOtherVariable = "B", SomeOtherOtherVariable = "C" }; ExampleResponse response = manager.ValidateExampleWithoutGenerics(request); Assert.IsTrue(response.Condition1Ran); Assert.IsTrue(response.Condition2Ran); Assert.IsTrue(response.Condition3Ran); Assert.IsTrue(response.DoWorkRan); }
public void ValidateExampleWithGenerics_FailCondition3_Condition4Condition5DoWork2_DoNotRun() { ExampleManager manager = new ExampleManager(); ExampleRequest request = new ExampleRequest() { SomeVariable = "A", SomeOtherVariable = "B", SomeOtherOtherVariable = "C" }; ExampleResponse response = manager.ValidateExampleWithGenerics(request); Assert.IsTrue(response.Condition4Ran); Assert.IsFalse(response.Condition5Ran); Assert.IsFalse(response.Condition6Ran); Assert.IsFalse(response.DoWork2Ran); }
IEnumerator Co_InitiWithServer() { while (ExampleManager.Instance.IsInRoom == false) { yield return(0); } if (autoInitEntity && HasInit == false && !string.IsNullOrEmpty(prefabName)) { ExampleManager.CreateNetworkedEntity(prefabName, null, this); } else if (autoInitEntity && HasInit == false && string.IsNullOrEmpty(prefabName)) { LSLog.LogError("Prefab Name / Location Must be set"); } }
private void HandleInput() { if (Input.GetKeyDown(KeyCode.Escape)) { SetPause(!isPaused); } if (isPaused) { return; } groundedPlayer = _characterController.isGrounded; if (groundedPlayer && playerVelocity.y < 0) { playerVelocity.y = 0f; } Vector3 move = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); move = transform.TransformDirection(move); _characterController.Move(move * Time.deltaTime * playerSpeed); if (Input.GetButtonDown("Jump") && groundedPlayer) { playerVelocity.y += Mathf.Sqrt(jumpHeight * -3.0f * gravityValue); } playerVelocity.y += gravityValue * Time.deltaTime; _characterController.Move(playerVelocity * Time.deltaTime); if (Input.GetMouseButton(0)) { ExampleManager.RFC(state.id, "FireGunRFC", null); } lookCamera.isADS = Input.GetMouseButton(1); if (Input.GetKeyDown(KeyCode.R)) { Reload(); } }
IEnumerator WaitForConnect() { if (ExampleManager.Instance.CurrentUser != null && !IsMine) { yield break; } while (!ExampleManager.Instance.IsInRoom) { yield return(0); } LSLog.LogImportant("HAS JOINED ROOM - CREATING ENTITY"); ExampleManager.CreateNetworkedEntityWithTransform(new Vector3(0f, 0f, 0f), Quaternion.identity, new Dictionary <string, object>() { ["prefab"] = "VMEViewPrefab" }, this, (entity) => { LSLog.LogImportant($"Network Entity Ready {entity.id}"); }); }
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); } }
protected override void Update() { base.Update(); if (!HasInit || !IsMine) { return; } groundedPlayer = controller.isGrounded; if (groundedPlayer && playerVelocity.y < 0) { playerVelocity.y = 0f; } Vector3 move = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); controller.Move(move * Time.deltaTime * playerSpeed); if (move != Vector3.zero) { gameObject.transform.forward = move; } // Changes the height position of the player.. if (Input.GetButtonDown("Jump") && groundedPlayer) { playerVelocity.y += Mathf.Sqrt(jumpHeight * -3.0f * gravityValue); } playerVelocity.y += gravityValue * Time.deltaTime; controller.Move(playerVelocity * Time.deltaTime); if (Input.GetKeyDown(KeyCode.F)) { LSLog.Log("fire weapon key"); ExampleManager.RFC(state.id, "FireWeaponRFC", new object[] { new ExampleVector3Obj(transform.forward), "aWeapon" }); } }
private IEnumerator WaitForConnect() { if (ExampleManager.Instance.CurrentUser != null && !IsMine) { yield break; } lookCamera.gameObject.SetActive(true); while (!ExampleManager.Instance.IsInRoom) { yield return(0); } LSLog.LogImportant("HAS JOINED ROOM - CREATING ENTITY"); ExampleManager.CreateNetworkedEntityWithTransform(transform.position, Quaternion.identity, new Dictionary <string, object> { ["userName"] = ExampleManager.Instance.UserName }, this, entity => { userName = ExampleManager.Instance.UserName; userNameDisplay.text = userName; ExampleManager.Instance.CurrentNetworkedEntity = entity; }); }
public void RegisterTargetKill(string entityID, string targetID) { ExampleManager.CustomServerMethod("scoreTarget", new object[] { entityID, targetID }); }
public ExampleController() { _manager = new ExampleManager(Repository, UnitOfWork); }