Beispiel #1
0
    void FirstCardPlacement(DominoCard dominoCard, DominoDirection dominoDirection, Vector3 localPosition,
                            Vector2 addTorightMost, Vector2 addToLefttMost, bool AddLast, int TheLastLeftNum, int TheLastRightNum, float RightY = 0, float LeftY = 0)
    {
        dominoCard.transform.localScale = Vector3.one;
        dominoCard.ownership            = GameRole.Board;
        dominoCard.transform.SetParent(GameBoard);
        RectTransform domRect = dominoCard.GetComponent <RectTransform>();

        dominoCard.DominoDirection = dominoDirection;
        domRect.localPosition      = localPosition;
        rightMost += addTorightMost;
        leftMost  += addToLefttMost;
        if (AddLast)
        {
            linkedDominoes.AddLast(dominoCard);
        }
        else
        {
            linkedDominoes.AddFirst(dominoCard);
        }
        LastLeftNum  = TheLastLeftNum;
        LastRightNum = TheLastRightNum;
        if (RightY != 0)
        {
            rightMost.y = RightY;
        }
        if (LeftY != 0)
        {
            leftMost.y = LeftY;
        }
    }
Beispiel #2
0
    public void OnDrop(PointerEventData eventData)
    {
        DominoCard d = eventData.pointerDrag.GetComponent <DominoCard>();

        Debug.Log(GameManager_S.Instance.LastLeftNum + " / " + GameManager_S.Instance.LastRightNum
                  + " / " + d.Value1 + " / " + d.Value2);

        if (GameManager_S.Instance.linkedDominoes.Count > 0)
        {
            if ((d.Value1 == GameManager_S.Instance.LastLeftNum && d.Value2 == GameManager_S.Instance.LastRightNum) ||
                (d.Value1 == GameManager_S.Instance.LastRightNum && d.Value2 == GameManager_S.Instance.LastLeftNum))
            {
                DominoCard L = GameManager_S.Instance.linkedDominoes.First.Value;
                DominoCard R = GameManager_S.Instance.linkedDominoes.Last.Value;
                Debug.Log("fits both sides");

                if (Vector2.Distance(L.transform.position, eventData.position) <
                    Vector2.Distance(R.transform.position, eventData.position))
                {
                    GameManager_S.Instance.SettleTheCardInTheBoard(d.spriteIndex, false);
                }
                else
                {
                    GameManager_S.Instance.SettleTheCardInTheBoard(d.spriteIndex, true);
                }
            }
            else if ((d.Value1 == GameManager_S.Instance.LastLeftNum || d.Value1 == GameManager_S.Instance.LastRightNum) ||
                     (d.Value2 == GameManager_S.Instance.LastRightNum || d.Value2 == GameManager_S.Instance.LastLeftNum))
            {
                Debug.Log("one side only");
                if ((GameManager_S.Instance.LastRightNum == d.Value1) || (GameManager_S.Instance.LastRightNum == d.Value2))
                {
                    GameManager_S.Instance.SettleTheCardInTheBoard(d.spriteIndex, true);
                }
                if ((GameManager_S.Instance.LastLeftNum == d.Value1) ||
                    (GameManager_S.Instance.LastLeftNum == d.Value2))
                {
                    GameManager_S.Instance.SettleTheCardInTheBoard(d.spriteIndex, false);
                }
            }
            else
            {
                Debug.Log("does not match");
            }
        }
        else
        {
            GameManager_S.Instance.SettleTheCardInTheBoard(d.spriteIndex, true);
        }

        //Draggable d = eventData.pointerDrag.GetComponent<Draggable>();
        //if(d != null) {
        //	d.parentToReturnTo = this.transform;
        //}
    }
Beispiel #3
0
    private void Start()
    {
        screenBound = new Vector2((GameBoard.rect.width / 2) - (PublicStuf.dominoHeight * 1.5f), (GameBoard.rect.height / 2) - (PublicStuf.dominoHeight * 1.5f));
        int SpriteIndex = 0;

        for (int i = 6; i >= 0; i--)
        {
            for (int ii = i; ii >= 0; ii--)
            {
                DominoCard temp =// Instantiate(card);
                                  Instantiate(card, new Vector3(i, 2 - ii, 0), Quaternion.identity);

                temp.Value1 = i;
                temp.Value2 = ii;
                temp.ValuesArrange();
                temp.spriteIndex = SpriteIndex;

                temp.IsObservableByAll = true;

                dominoes.Add(temp);

                SpriteIndex++;
            }
        }
        NewGame();

        SettleTheCardInTheBoard(16, false);
        SettleTheCardInTheBoard(20, false);
        SettleTheCardInTheBoard(19, false);
        SettleTheCardInTheBoard(15, false);

        SettleTheCardInTheBoard(14, false);
        SettleTheCardInTheBoard(18, false);
        SettleTheCardInTheBoard(3, false);
        SettleTheCardInTheBoard(0, false);

        SettleTheCardInTheBoard(1, false);
        SettleTheCardInTheBoard(7, false);
        SettleTheCardInTheBoard(9, false);
        SettleTheCardInTheBoard(21, false);
        SettleTheCardInTheBoard(27, false);

        SettleTheCardInTheBoard(17, true);


        SettleTheCardInTheBoard(24, true);
        SettleTheCardInTheBoard(23, true);
    }