Exemplo n.º 1
0
 void Start()
 {
     bottomLeft = new Vector2(transform.position.x - boardCols * tileSize / 2,
                              transform.position.y - boardRows * tileSize / 2);
     fillCounts = new int[boardRows];
     InitializeBoard();
     shapeSpawner.SetBoard(this);
     PlaceShape(shapeSpawner.GetNextShape()); //initial shape
 }
    // Update is called once per frame
    void Update()
    {
        if (isDemoMode)
        {
            nextShape = spawner.GetNextShape();
            if (nextShape)
            {
                targetRotation = nextShape.transform.rotation;
                angle          = Quaternion.Angle(transform.rotation, targetRotation);
                angle          = angle * (targetRotation.eulerAngles.z < transform.rotation.eulerAngles.z ? -1 : 1);
            }

            transform.RotateAround(Vector3.zero, Vector3.forward, angle * rotMatchSpeed * Time.deltaTime);
        }
        else
        {
            if (Input.GetMouseButton(0))
            {   // check for mouse/touch input in relation to middle of screen
                movement = (Input.mousePosition.x < Screen.width / 2 - touchThresholdFromCenter) ? -1
                    : (Input.mousePosition.x > Screen.width / 2 + touchThresholdFromCenter ? 1 : 0);
            }
            else
            {   // check for normal button input
                movement = Input.GetAxisRaw("Horizontal");
            }
            transform.RotateAround(Vector3.zero, Vector3.forward, Time.deltaTime * moveSpeed * -movement);
        }
    }