Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        rb.MovePosition(rb.position + velocity * Time.deltaTime);
        if (gameObject.tag == "squareCustomer")
        {
            /* if (transform.position.x > 2.9 && transform.position.x < 3) {
             *      stop ();
             * } */
            if (transform.position.x < -9f)
            {
                Destroy(gameObject);
            }
        }
        else
        {
            /* if (transform.position.x < -2.9 && transform.position.x > -3) {
             *      stop ();
             * } */
            if (transform.position.x > 9f)
            {
                Destroy(gameObject);
            }
        }

        timeLeft -= Time.deltaTime;
        if (timeLeft < 0 && !once)
        {
            stop();
            once = true;
        }
        if (timeLeft < -5 && !once2)
        {
            if (velocity.x == 0f && velocity.y == 0f)
            {
                keepWalking();
                scoreMan.subtractPoints();
                once2 = true;
            }
        }

        //print(GameObject.FindGameObjectsWithTag("circleFood").Length);
    }