コード例 #1
0
    private void Update()
    {
        getScreen(a);
        if (gameController.gameState == true)
        {
            // get input images
            _helloRequester.info = a + " " + gameController.gameScore + " " + gameController.gameState;
            _helloRequester.fonk();

            // acting bounded for bug
            if (a > 210)
            {
                gameController.finishGame(false);
            }


            switch (_helloRequester.message)
            {
            case "r":
                direction = Vector2.right;
                break;

            case "l":
                direction = Vector2.left;
                break;

            case "u":
                direction = Vector2.up;
                break;

            case "d":
                direction = Vector2.down;
                break;

            case "end":
                UnityEditor.EditorApplication.isPlaying = false;
                break;

            default:
                Debug.Log("cant access action");
                break;
            }

            File.Delete(a - 1 + ".png");// images remover
            a++;
        }

        rb2d.velocity = direction * speed;          // player'ın rigidbody'sine yöne göre speed kadar güç uygula
        if (rb2d.velocity.x == 0)                   // dönüşlerde daha rahat olması için x ve y eşik değeri
        {
            turn = 1;
        }
        if (rb2d.velocity.y == 0)
        {
            turn = 2;
        }
    }