Exemplo n.º 1
0
    private void UpdateMovement()
    {
        switch (moving_status)
        {
            case status.MOVE_LEFT:
                transform.position = new Vector2(transform.position.x - WALK_DIST, transform.position.y);
                direction = face_direction.LEFT;
                walk_remaining--;
                break;

            case status.MOVE_RIGHT:
                transform.position = new Vector2(transform.position.x + WALK_DIST, transform.position.y);
                direction = face_direction.RIGHT;
                walk_remaining--;
                break;

            case status.MOVE_DOWN:
                transform.position = new Vector2(transform.position.x, transform.position.y - WALK_DIST);
                direction = face_direction.DOWN;
                walk_remaining--;
                break;

            case status.MOVE_UP:
                transform.position = new Vector2(transform.position.x, transform.position.y + WALK_DIST);
                direction = face_direction.UP;
                walk_remaining--;
                break;

            default:
                break;
        }

        if (walk_remaining <= 0)
        {
            walk_remaining = 0;
            moving_status = status.IDLE;
            gameObject.transform.position = new Vector3(Mathf.Round(gameObject.transform.position.x),
                                            Mathf.Round(gameObject.transform.position.y),
                                            0f);
            SetMovement();
        }
    }
Exemplo n.º 2
0
 /**********************************/
 // Use this for initialization
 void Start()
 {
     walk_remaining = 0;
     moving_status = status.IDLE;
     direction = face_direction.DOWN;
 }