示例#1
0
    public void CheckNumInArea1()
    {
        ArrayList Nums = new ArrayList();

        foreach (Transform Num in Area1.GetComponentsInChildren <Transform>())
        {
            if (Num.tag == "CardNum")
            {
                Nums.Add(Num.GetComponent <Text>().text.ToString());
            }
        }
        string tmp = Nums[0].ToString();

        for (int i = 0; i < Nums.Count; i++)
        {
            if (Regex.Match(Nums[i].ToString(), @"\d").Success)
            {
                tmp = Nums[i].ToString();
                break;
            }
        }
        for (int i = 0; i < Nums.Count; i++)
        {
            if (Nums[i].ToString() != "" && (Nums[i].ToString() == tmp || Nums[i].ToString() == "☆"))
            {
                continue;
            }
            else
            {
                return;
            }
        }
        for (int i = 0; i < Nums.Count; i++)
        {
            if (Nums[i].ToString() == "☆")
            {
                continue;
            }
            else
            {
                tmp = Nums[i].ToString();
                break;
            }
        }
        AddScore(tmp);

        foreach (Transform Num in Area1.GetComponentsInChildren <Transform>())
        {
            if (Num.tag == "CardNum")
            {
                Num.GetComponentInChildren <Text>().text = "";
            }
        }
    }
示例#2
0
    public void CheckNumInSumArea(GameObject area)
    {
        ArrayList Nums = new ArrayList();
        int       sum  = 0;

        foreach (Transform Num in area.GetComponentsInChildren <Transform>())
        {
            if (Num.tag == "CardNum")
            {
                Nums.Add(Num.GetComponent <Text>().text.ToString());
            }
        }
        for (int i = 0; i < Nums.Count; i++)
        {
            if (Regex.Match(Nums[i].ToString(), @"\d").Success)
            {
                sum += (int)float.Parse(Nums[i].ToString());
            }
        }
        if (sum == 15)
        {
            AddScore("2");
            foreach (Transform Num in area.GetComponentsInChildren <Transform>())
            {
                if (Num.tag == "CardNum")
                {
                    Num.GetComponentInChildren <Text>().text = "";
                }
            }
        }

        else if (sum == 14)
        {
            AddScore("5");
            foreach (Transform Num in area.GetComponentsInChildren <Transform>())
            {
                if (Num.tag == "CardNum")
                {
                    Num.GetComponentInChildren <Text>().text = "";
                }
            }
        }
    }
示例#3
0
    public int CheckNumInLineArea(GameObject area, bool isShown)
    {
        ArrayList Nums = new ArrayList();
        int       max  = 0;
        int       last = -1;
        int       a    = 0;

        foreach (Transform Num in area.GetComponentsInChildren <Transform>())
        {
            if (Num.tag == "CardNum")
            {
                Nums.Add(Num.GetComponent <Text>().text.ToString());
            }
        }
        for (int i = 0; i < Nums.Count; i++)
        {
            if (Nums[i].ToString() == "☆")
            {
                if (Nums[i + 1].ToString() == "/")
                {
                    for (int j = i + 1; j < Nums.Count; j++)
                    {
                        Nums[j] = "";
                    }
                }
                else
                {
                    continue;
                }
            }
            else if (Regex.Match(Nums[i].ToString(), @"\d").Success)
            {
                if ((int)float.Parse(Nums[i].ToString()) == 6)
                {
                    last = i;
                    for (int j = i + 1; j < Nums.Count; j++)
                    {
                        Nums[j] = "/";
                    }
                    if (!isShown)
                    {
                        biscuit.SetActive(true);
                        if (area.name == "Area5")
                        {
                            isShown5 = true;
                        }
                        else if (area.name == "Area6")
                        {
                            isShown6 = true;
                        }
                        else if (area.name == "Area7")
                        {
                            isShown7 = true;
                        }
                    }
                    break;
                }
                else if ((int)float.Parse(Nums[i].ToString()) > max)
                {
                    max  = (int)float.Parse(Nums[i].ToString());
                    last = i;
                    continue;
                }
                else if ((int)float.Parse(Nums[i].ToString()) <= max && last != -1)
                {
                    for (int j = i + 1; j < Nums.Count; j++)
                    {
                        Nums[j] = "/";
                    }
                    last = -1;
                    break;
                }
            }
            else
            {
                last = i - 1;
                break;
            }
        }
        //Debug.Log("max"+max+"last"+last);
        foreach (Transform Num in area.GetComponentsInChildren <Transform>())
        {
            if (Num.tag == "CardNum")
            {
                Num.GetComponent <Text>().text = Nums[a].ToString();
                a += 1;
            }
        }
        return(last);
    }