Home>
I want to solve

Poker has many roles for the code below, but this time I want to know where the role of flash is conditional.
The code is omitted.

corresponding code
public class GameMaster: MonoBehaviour
{
    ・
    ・
    ・
    void Start ()
    {
        for (int i = 0;i<53;i ++)
        {«
            card_stockList.Add (i);
        }
        for (int i = 0;i<5;i ++)
        {
            field_selectedcard_pos [i] = field_Setcards_root.transform.GetChild (i) .GetComponent<RectTransform>(). localPosition;
        }
        for (int i = 0;i<20;i ++)
        {
            field_card_pos [i] = new Vector3 (-264 + 132 * (i% 5), 70-177 * (i/5), 0);
            int n = Random.Range (0, card_stockList.Count);
            field_card_num [i] = card_stockList [n];
            field_cards [i] = field_cards_root.transform.GetChild (i) .gameObject;
            field_cards [i] .GetComponent<Image>(). sprite = cards [card_stockList [n]];
            field_cards [i] .GetComponent<RectTransform>(). transform.localPosition = field_card_pos [i];
            card_stockList.RemoveAt (n);
        }
        FieldSet ();
        time_plus = time.transform.GetChild (0) .gameObject;
    }

    void FieldSet ()
    {
        for (int i = 0;i<20;i ++)
        {
            if (field_card_num [i] == 52)
            {
                field_joker = true;
                field_joker_pass = true;
            }
            else
            {
                straight_check [field_card_num [i]% 13] = true;
                flush_count [field_card_num [i]/13] ++;
                kinds_count [field_card_num [i]% 13] ++;
            }
        }
        straight.SetActive (false);
        flush.SetActive (false);
        three.SetActive (false);
        four.SetActive (false);
        five.SetActive (false);
        for (int c = 0;c<8;c ++)
        {
            if (straight_check [c] == true)
            {
                for (int i = 1;i<5;i ++)
                {
                    if (straight_check [c + i] == false)
                    {
                        if (! field_joker_pass)
                        {
                            if (field_joker)
                            {
                                field_joker_pass = true;
                            }
                            break;
                        }
                        else
                        {
                            field_joker_pass = false;
                        }
                    }
                    if (i == 4)
                    {
                        if (field_joker){
                            field_joker_pass = true;
                        }
                        straight.SetActive (true);
                        break;
                    }
                }
            }
            if (straight.activeSelf == true)
            {
                break;
            }
        }
        for (int c = 0;c<4;c ++)
        {
            if (field_joker)
            {
                flush_count [c] ++;
            }
            if (flush_count [c]>= 5)
            {
                flush.SetActive (true);
                break;
            }
        }
        for (int c = 0;c<13;c ++)
        {
            if (field_joker)
            {
                kinds_count [c] ++;
            }
            if (kinds_count [c]>= 5)
            {
                three.SetActive (true);
                four.SetActive (true);
                five.SetActive (true);
                break;
            }
            else if (kinds_count [c] == 4)
            {
                three.SetActive (true);
                four.SetActive (true);
            }
            else if (kinds_count [c] == 3)
            {
                three.SetActive (true);
            }
        }
        BonusSet ();
    }
    void BonusSet ()
    {
        int r_num = Random.Range (0, Bonus_numList.Count);
        int r_suit = Random.Range (0, Bonus_suitList.Count);
        string old_num = num.text;
        num.text = Bonus_numList [r_num];
        Bonus_numList.RemoveAt (r_num);
        Bonus_numList.Add (old_num);
        switch (num.text)
        {
            case "A":
                bonus_num = 0;
                break;
            case "J":
                bonus_num = 10;
                break;
            case "Q":
                bonus_num = 11;
                break;
            case "K":
                bonus_num = 12;
                break;
            default:
                bonus_num = int.Parse (num.text)-1;
                break;
        }
        string old_suit = suit.text;
        suit.text = Bonus_suitList [r_suit];Bonus_suitList.RemoveAt (r_suit);
        Bonus_suitList.Add (old_suit);
        switch (suit.text)
        {
            case "♣":
                suit.color = Color.green;
                bonus_suit = 0;
                break;
            case "♦":
                suit.color = Color.yellow;
                bonus_suit = 1;
                break;
            case "♥":
                suit.color = Color.red;
                bonus_suit = 2;
                break;
            case "♠":
                suit.color = Color.blue;
                bonus_suit = 3;
                break;
        }
    }
    public void CardSet (int i)
    {
        if (set_num<5)
        {
            field_cards [i] .GetComponent<RectTransform>(). transform.localPosition = field_selectedcard_pos [set_num];
            card_setList.Add (i);
            if (field_card_num [i]! = 52)
            {
                card_numList.Add (field_card_num [i]% 13);
                card_suitList.Add (field_card_num [i]/13);
                num_count [field_card_num [i]% 13] ++;
                suits_count [field_card_num [i]/13] ++;
            }
            else
            {
                card_numList.Add (100);
                card_suitList.Add (100);
                joker = true;
                joker_pass = true;
            }
            field_Setcards_root.transform.GetChild (set_num) .GetComponent<Image>(). raycastTarget = true;
            set_num ++;
            Yaku_hantei ();
            Debug.Log (yaku_rank);
        }
    }
    public void CardReturn (int i)
    {
        if (set_num>= 1)
        {
            field_cards [card_setList [i]]. GetComponent<RectTransform>(). transform.localPosition = field_card_pos [card_setList [i]];
            if (card_numList [i] == 100)
            {
                joker = false;
                joker_pass = false;
            }
            else
            {
                num_count [field_card_num [card_setList [i]]% 13]-;
                suits_count [field_card_num [card_setList [i]]/13]-;
            }
            card_setList.RemoveAt (i);
            card_numList.RemoveAt (i);
            card_suitList.RemoveAt (i);
            for (int d = i;d<card_setList.Count;d ++)
            {
                field_cards [card_setList [d]]. GetComponent<RectTransform>(). transform.Translate (-132,0,0, Space.Self);
            }
            set_num--;
            field_Setcards_root.transform.GetChild (set_num) .GetComponent<Image>(). raycastTarget = false;
            Yaku_hantei ();
            Debug.Log (yaku_rank);
        }
    }
    public void CardPush ()
    {for (int c = 0;c<set_num;c ++)
        {
            field_Setcards_root.transform.GetChild (c) .GetComponent<Image>(). raycastTarget = false;
        }
        set_num = 0;
        Vector3 deck_pos = deck.GetComponent<RectTransform>(). Transform.localPosition;
        foreach (int i in card_setList)
        {
            field_cards [i] .GetComponent<RectTransform>(). transform.localPosition = deck_pos;
            card_stockList.Add (field_card_num [i]);
            card_outList.Add (i);
        }
        card_setList.Clear ();
        card_numList.Clear ();
        card_suitList.Clear ();
        push.SetActive (false);
        if (joker)
        {
            field_joker = false;
            field_joker_pass = false;
            joker = false;
            joker_pass = false;
        }
        int bonus_sum = num_count [bonus_num] + suits_count [bonus_suit];
        if (bonus_sum>0) {
            if (yaku_rank>5)
            {
                bonus_sum * = yaku_rank;
            }
            secondtime + = bonus_sum;
            time.text = secondtime.ToString ();
            delta_time = 0;
            time_plus.SetActive (true);
            time_plus.GetComponent<Text>(). text = "+" + bonus_sum;
        }
        for (int i = 0;i<13;i ++)
        {
            straight_check [i] = false;
            num_count [i] = 0;
            kinds_count [i] = 0;
        }
        for (int i = 0;i<4;i ++)
        {
            flush_count [i] = 0;
            suits_count [i] = 0;
        }
        result_yaku [yaku_rank-1] ++;
        yaku.SetActive (true);
        yaku.GetComponent<Text>(). text = yaku_name_root.transform.GetChild (yaku_rank-1) .GetComponent<Text>(). text;
        delta_time = 0;
        BonusSet ();
    }
    public void CardPlus ()
    {
        foreach (int i in card_outList)
        {
            int n = Random.Range (0, card_stockList.Count);
            field_card_num [i] = card_stockList [n];
            field_cards [i] .GetComponent<Image>(). sprite = cards [card_stockList [n]];
            field_cards [i] .GetComponent<RectTransform>(). transform.localPosition = field_card_pos [i];
            card_stockList.RemoveAt (n);
        }
        card_outList.Clear ();
        FieldSet ();
    }
    void Yaku_hantei ()
    {
        yaku_rank = 0;
        push.SetActive (false);
        int max_sum = num_count.Max ();

     ・
     ・
     ・
}
  • Answer # 1

    Select flush and press F12. Jump to where it is defined. I don't have it because it's only part of the code, but I guess it's probably instantiated in the Unity inspector.

    Next, check the type of flush and its inheritance (probably GameObject), and check the setActive method. Then you should know where and what the object is.

    Unity Script Reference

    Poker judges hands in a complex way. For example, if it is a flash, there is a role called a straight flash at the top. Therefore, it is not always a flash if the flash conditions are met.

  • Answer # 2

    If you search the source with flush_count, you can see it.

    (Judgment is confusing and difficult to read)