コード例 #1
0
    private void Init_AddNum(GameObject data_obj, string name, int pos, int pool_size, float width_half)
    {
        GameObject   num_obj = data_obj.transform.FindChild(name).gameObject;
        PT_FFTextNum pt_num  = new PT_FFTextNum();

        pt_num.m_fWight_Half      = width_half;
        pt_num.max_UIOBJ_text_num = pool_size;
        pt_num.m_tfNumObj         = new Transform[pt_num.max_UIOBJ_text_num];

        for (int i = 0; i < pt_num.max_UIOBJ_text_num; ++i)
        {
            pt_num.m_tfNumObj[i] = GameObject.Instantiate <GameObject>(num_obj).transform;
            pt_num.m_tfNumObj[i].transform.SetParent(s_tfTempPool, false);
        }

        GameObject.Destroy(num_obj);

        s_ffTextNums[pos] = pt_num;
        pt_num            = null;
    }
コード例 #2
0
    public void Start(int num, PT_FFTextNum[] s_ffTextNums)
    {
        m_nCurNum = num;

        if (num <= 0)
        {
            return;
        }

        //Debug.Log("FlyText = " + num);
        //m_tfNumNode.SetParent(null, false);

        if (num > 999999)
        {
            num = 999999;
        }

        int[] n = { 0, 0, 0, 0, 0, 0 };
        n[0] = num / 100000; num = num - n[0] * 100000;
        n[1] = num / 10000; num = num - n[1] * 10000;
        n[2] = num / 1000; num = num - n[2] * 1000;
        n[3] = num / 100; num = num - n[3] * 100;
        n[4] = num / 10; num = num - n[4] * 10;
        n[5] = num;

        int   linkerpos     = -1;
        float right_pos     = 0f;
        bool  no_enough_num = false;

        for (int i = 0; i < 6; ++i)
        {
            if (linkerpos == -1 && n[i] == 0)
            {
                continue;
            }
            else
            {
                PT_FFTextNum fftn  = s_ffTextNums[n[i]];
                Transform    tfnum = fftn.PopOneSleepNum();
                if (tfnum != null)
                {
                    right_pos += fftn.m_fWight_Half;
                    tfnum.SetParent(m_tfNumNode, false);
                    tfnum.localPosition = new Vector3(right_pos, 0f, 0f);
                    right_pos          += fftn.m_fWight_Half;

                    tfnum.localRotation = Quaternion.identity;
                    tfnum.localScale    = Vector3.one;

                    ++linkerpos;

                    m_nLinkNumPos[linkerpos]  = n[i];
                    m_tfLinkNumObj[linkerpos] = tfnum;
                }
                else
                {
                    no_enough_num = true;
                    break;
                }
            }
        }

        if (no_enough_num)
        {
            //将数字移出去
            for (int i = 0; i < 6; ++i)
            {
                if (m_tfLinkNumObj[i] != null)
                {
                    m_tfLinkNumObj[i].localPosition = new Vector3(0f, 65535f, 0f);
                }
            }
        }
        else
        {
            for (int i = 0; i < 6; ++i)
            {
                float len_half = right_pos / 2f;
                if (m_tfLinkNumObj[i] != null)
                {
                    m_tfLinkNumObj[i].Translate(-len_half, 0f, 0f);
                }
            }
        }
    }