コード例 #1
0
    protected void CheckSelectedPairs()
    {
        // get the prefab gameobject respectively from player's selection
        GameObject oneCardPrefab     = thisSelectionList[0];
        GameObject anotherCardPrefab = thisSelectionList[1];

        // get the card front of the prefab gameobject of each
        GameObject oneCardFront     = oneCardPrefab.transform.GetChild(1).gameObject;
        GameObject anotherCardFront = anotherCardPrefab.transform.GetChild(1).gameObject;

        // get the sprite of the card front
        Sprite oneSprite     = oneCardFront.GetComponent <SpriteRenderer>().sprite;
        Sprite anotherSprite = anotherCardFront.GetComponent <SpriteRenderer>().sprite;


        // if having same card front patterns
        if (oneSprite == anotherSprite)
        {
            // start humiliation
            thisUiManager.StartPlayerHumiliation();

            // and do according extra things based on the special tiles
            string theCardCategory = oneCardPrefab.tag;

            switch (theCardCategory)
            {
            case "Normal":
            {
                HurtPlayer();
            }
            break;

            case "Flower":
            {
                HurtPlayerByDouble();
            }
            break;

            case "Bird":
            {
                HurtPlayer();
                // npc gets to have one more turn
                //print("one more turn for Npc\n");
                thisOneMoreRoundAllowed = true;
                thisUiManager.StartInGameLine("Bird", this.gameObject);
            }
            break;

            case "Moon":
            {
                OnHeal();
            }
            break;

            case "Wind":
            {
                HurtPlayer();
                // set lerping to true before card server checks the card
                // in case the wind is the last pair and the isLerping needs to be closed
                thisIsNowLerpingToShuffle = true;
                thisCardServer.ShuffleClickableCards();
                thisUiManager.StartInGameLine("Wind", this.gameObject);
            }
            break;
            }
        }
        else
        {
            CardScript oneCardScript     = oneCardPrefab.GetComponent <CardScript>();
            CardScript anotherCardScript = anotherCardPrefab.GetComponent <CardScript>();

            oneCardScript.StartFlipBackCoroutine();
            anotherCardScript.StartFlipBackCoroutine();

            oneCardScript.StopFlipCoroutine();
            anotherCardScript.StopFlipCoroutine();
        }
    }