/// <summary>
    /// 返回一个随机诗句
    /// </summary>
    static string GetRandomAnswer(List <string> contents)
    {
        int    random = RandomService.GetRand(0, contents.Count);
        string result = contents[random];

        s_outSentenceList.Add(result);
        contents.RemoveAt(random);

        return(result);
    }
 public static poemDataGenerate GetRandomPoem()
 {
     if (s_poemList.Count > 0)
     {
         int random = RandomService.GetRand(0, s_poemList.Count);
         return(s_poemList[random]);
     }
     else
     {
         return(null);
     }
 }
    void CreateCell()
    {
        for (int i = 0; i < m_length; i++)
        {
            for (int j = 0; j < m_weight; j++)
            {
                int        random = RandomService.GetRand(1, 13);
                GameObject go     = GameObjectManager.CreatGameObject(m_CellName + "_" + random);
                go.transform.SetParent(m_scenceParent.transform);

                go.transform.position = new Vector3(i * m_cellSpace, 0, j * m_cellSpace);
            }
        }
    }
Exemplo n.º 4
0
    static int GetRandomIndex(bool isReset)
    {
        if (isReset)
        {
            s_randomList.Clear();
            for (int i = 0; i < 4; i++)
            {
                s_randomList.Add(i);
            }
        }

        int random = RandomService.GetRand(0, s_randomList.Count);
        int result = s_randomList[random];

        s_randomList.RemoveAt(random);

        return(result);
    }
    void CreateBoundary()
    {
        for (int i = -1; i < m_length + 1; i++)
        {
            for (int j = -1; j < m_weight + 1; j++)
            {
                Debug.Log((i < 0 || i >= m_length || j < 0 || j >= m_weight) + " I:" + i + " J:" + j);

                if (i < 0 || i >= m_length || j < 0 || j >= m_weight)
                {
                    int        random = RandomService.GetRand(1, 6);
                    GameObject go     = GameObjectManager.CreatGameObject(m_BoundaryName + "_" + random);
                    go.transform.SetParent(m_scenceParent.transform);

                    go.transform.position = new Vector3(i * m_cellSpace, 0, j * m_cellSpace);
                }
            }
        }
    }
    static string GetRandomContent(Dictionary <int, List <string> > contents)
    {
        List <int> list = new List <int>(contents.Keys);

        int random = RandomService.GetRand(0, list.Count);
        int count  = 0;

        while (contents[list[random]].Count == 0)
        {
            random = RandomService.GetRand(0, list.Count);
            count++;

            if (count > 1000)
            {
                throw new Exception("GetRandomContent Time Out !");
            }
        }

        return(GetRandomAnswer(contents[list[random]]));
    }
    /// <summary>
    /// 返回一个有与目标相同字数的韵脚ID
    /// </summary>
    /// <returns></returns>
    static string GetSameContentLengthRhythmID(int length)
    {
        //先判断有没有返回结果
        s_RandomrhythmList.Clear();
        foreach (var item in s_library)
        {
            if (item.Value.ContainsKey(length))
            {
                s_RandomrhythmList.Add(item.Key);
            }
        }

        if (s_RandomrhythmList.Count == 0)
        {
            return(null);
        }

        //如果有可行的值,则直接返回
        int random = RandomService.GetRand(0, s_RandomrhythmList.Count);

        return(s_RandomrhythmList[random]);
    }
    /// <summary>
    /// 获取一个随机韵脚
    /// </summary>
    /// <returns></returns>
    static string GetRandomRhythm()
    {
        int random = RandomService.GetRand(0, RhythmLibrary.GetRhythmList().Count);

        return(RhythmLibrary.GetRhythmList()[random]);
    }