public void OnSendClick() { inputText = AnswerQuestionPanel.Instance.GetInputText(); int res; if (int.TryParse(inputText, out res)) { DataPlatformer data = new DataPlatformer { cardType = NetworkController.Instance.GameType, type = changeType, x = changeType == "jump" ? 0 : res, y = changeType == "jump" ? res : 0 }; NetworkController.Instance.SendWebSocketMessage(3, JsonUtility.ToJson(data)); if (changeType == "speed") { speed = res; } else { jumpForce = res; } //ENVIO AnswerQuestionPanel.Instance.HidePanel(); } }
// Update is called once per frame void Update() { rb.velocity = new Vector2(Input.GetAxis("Horizontal") * speed, rb.velocity.y); if (canJump && Input.GetKeyDown(KeyCode.Space)) { canJump = false; rb.AddForce(new Vector2(0, jumpForce)); } else if (!canJump && canChangeScale && rb.velocity.y < 0) { rb.gravityScale = gravityScaleFalling; } timer += Time.deltaTime; if (timer > timeToWait) { timer = -800; NewDestiny(); } if (chooseSite) { if (Input.GetMouseButtonDown(0)) { Vector3 aux = Camera.main.ScreenToWorldPoint(Input.mousePosition); DataPlatformer data = new DataPlatformer { cardType = NetworkController.Instance.GameType, type = changeType, x = (int)aux.x, y = (int)aux.y }; aux.z = 0; NetworkController.Instance.SendWebSocketMessage(3, JsonUtility.ToJson(data)); Instantiate(changeType == "platform" ? platformPrefab : enemyPrefab, aux, Quaternion.identity); chooseSite = false; AnswerQuestionPanel.Instance.HideTooltip(); AnswerQuestionPanel.Instance.HidePanel(); } } }
public void ChangeSpeed(DataPlatformer data) { speed = data.x; }
public void ChangeJump(DataPlatformer data) { jumpForce = data.y; }
public void InstantiateEnemy(DataPlatformer data) { Instantiate(enemyPrefab, new Vector3(data.x, data.y, 0), Quaternion.identity); }