Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        scrollRect = piecePanel.GetComponent <ScrollRect> ();
        float scrollPanelLength = PiecesScrollRect.getListLength_x();

        scrollPanel.sizeDelta = new Vector2(scrollPanelLength, scrollPanel.sizeDelta.y);
        anchoredPos           = scrollPanel.anchoredPosition;
    }
Ejemplo n.º 2
0
    public void OnDrop(PointerEventData eventData)
    {
        if (DragHandler.itemBeingDragged != null)
        {
            ph = DragHandler.itemBeingDragged.GetComponent <PieceHandle> ();
        }

        if (ph == null)
        {
            return;
        }
        string itemName = ph.name;
        int    itemID   = ph.id;
        string slotName = gameObject.name;

        bool isMatch = false;

        if (itemName [itemName.Length - 1] == slotName [slotName.Length - 1])
        {
            audioControll.playAnsResult(true);

            isMatch = true;
        }
        else
        {
            audioControll.playBounce();

            sc.WrongGuess();
            return;
        }

        if (!item && isMatch)
        {
            PiecesScrollRect.RemoveFromList(itemID);

            DragHandler.itemBeingDragged.transform.SetParent(transform);
            DragHandler.itemBeingDragged.transform.localPosition = new Vector3(0, 0, 0);
            Delay(0.1f);
            sc.CorrectGuess();
            sc.CheckGameEnd();
        }
    }
Ejemplo n.º 3
0
    public void ResizeBoundary()
    {
        scrollRect = piecePanel.GetComponent <ScrollRect> ();
        float scrollPanelLength = PiecesScrollRect.getListLength_x();

        scrollPanel.sizeDelta = new Vector2(scrollPanelLength, scrollPanel.sizeDelta.y);

        if (scrollPanel.anchoredPosition.x > scrollPanel.sizeDelta.x / 2)
        {
            scrollPanel.anchoredPosition = new Vector2(scrollPanel.sizeDelta.x / 2, scrollPanel.anchoredPosition.y);
        }

        float rightBoundaryLimitX = -(scrollPanel.sizeDelta.x - piecePanel.sizeDelta.x) / 2;

        if (scrollPanel.localPosition.x < rightBoundaryLimitX)         //(2000 - 800)/2
        {
            scrollPanel.localPosition = new Vector2(rightBoundaryLimitX, scrollPanel.localPosition.y);
        }

        if (PiecesScrollRect.pieceList.Count == 1)
        {
            scrollPanel.localPosition = Vector2.zero;
        }
    }