示例#1
0
    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();
        }
    }
示例#2
0
    // 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();
            }
        }
    }
示例#3
0
 public void ChangeSpeed(DataPlatformer data)
 {
     speed = data.x;
 }
示例#4
0
 public void ChangeJump(DataPlatformer data)
 {
     jumpForce = data.y;
 }
示例#5
0
 public void InstantiateEnemy(DataPlatformer data)
 {
     Instantiate(enemyPrefab, new Vector3(data.x, data.y, 0), Quaternion.identity);
 }