Esempio n. 1
0
    private IEnumerator Waiter(GamePieceLogic piece)
    {
        piece.ShowSprite();
        yield return(new WaitForSeconds(2));

        piece.ShowSprite();
        firstGameObject.ShowSprite();
        firstClickedNumber = null;
        firstGameObject    = null;
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        // Left mouse being clicked
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit2D hit = Physics2D.GetRayIntersection(Camera.main.ScreenPointToRay(Input.mousePosition));
            if (hit.collider != null)
            {
                var piece = hit.collider.GetComponent("GamePieceLogic") as GamePieceLogic;
                if (firstClickedNumber == null)
                {
                    firstClickedNumber = piece.imageNumber;
                    firstGameObject    = piece;
                    piece.ShowSprite();
                }
                else
                {
                    if (firstClickedNumber == piece.imageNumber)
                    {
                        Debug.Log("Match");
                        if (MemoryGameManager.instance.Player1Turn)
                        {
                            UIController.instance.Player1Matched();
                        }
                        else
                        {
                            UIController.instance.Player2Matched();
                        }
                        StartCoroutine(MatchWaiter(piece));
                    }
                    else
                    {
                        Debug.Log("No match");
                        StartCoroutine(Waiter(piece));
                        MemoryGameManager.instance.ShiftTurn();
                    }

                    //MemoryGameManager.instance.Player1Turn = !MemoryGameManager.instance.Player1Turn;
                    //if (MemoryGameManager.instance.Player1Turn)
                    //    Debug.Log("Player1 Turn");
                    //if (!MemoryGameManager.instance.Player1Turn)
                    //    Debug.Log("Player2 Turn");
                }
            }
        }
    }