// Interfaces we care about public void OnGetMessage(string _Message) { _Message = StripMessage(_Message); // other player is jumping, need to maybe set it so that the playercontroller has a bool looking at this List <object> m = MessageParser.ParseMessage(_Message); string type = (string)m[0]; if (type == "jump") { bool jumping = (bool)m[1]; Vector3 pos = new Vector3((float)m[2], (float)m[3], (float)m[4]); if (jumping) { playerController.RunnerDoJump(pos); } else { playerController.RunnerStopJump(pos); } } if (type == "block") { Vector3 pos = new Vector3((float)m[1], (float)m[2], (float)m[3]); GameObject block = blockManager.GetFromPool(); block.transform.position = pos; block.GetComponent <Block>().bitmask = -1; // Force an update in AdjustBitmasks blockManager.AdjustBitmasks(block); } if (type == "pos") { // Update position, incl. latency compensation System.DateTime theirDT = (System.DateTime)m[1]; System.DateTime ourDT = System.DateTime.Now; System.TimeSpan difference = ourDT - theirDT; float secs = difference.Seconds + (difference.Milliseconds / 1000f); Vector3 pos = new Vector3((float)m[2], (float)m[3], (float)m[4]); Vector3 vel = new Vector3((float)m[5], (float)m[6]); playerController.velocity = vel; playerController.velocity.y += playerController.acceleration.y * secs; playerController.velocity.y = Mathf.Clamp(playerController.velocity.y, -PlayerController.TERMINAL_VELOCITY, PlayerController.TERMINAL_VELOCITY); playerController.transform.position = new Vector3(pos.x + playerController.velocity.x * secs, pos.y + playerController.velocity.y * secs, playerController.transform.position.z); blockManager.GenerateGround(); } if (type == "ded") { gameIsPlaying = false; score = (int)m[1]; blockManager.generateGroundAheadOfPlayer = false; playerController.gameObject.SetActive(false); scoreText.GetComponent <Text>().text = "Score: " + score.ToString(); } if (type == "pit") { int count = (int)m[1]; StartCoroutine(blockManager.DelayGroundSpawningForCount(count)); } if (type == "blocks") { for (int i = 1; i < m.Count; ++i) { Vector3 pos = (Vector3)m[i]; Debug.LogWarning("CREATING BLOCK " + pos); GameObject block = blockManager.GetFromPool(); block.transform.position = pos; block.GetComponent <Block>().bitmask = -1; // Force an update in AdjustBitmasks blockManager.AdjustBitmasks(block); } } if (type == "restart") { SceneManager.LoadScene(1); } }