//绘制怪物信息
    void DrawFunNpcInfoList(ref Vector2 ScrollPos, Dictionary <int, FunNpcInfo> MonsterInfoList, int nChooseID, bool isChar = false)
    {
        StartSpace(1);
        float height           = 30;
        int   ScrollViewheight = m_OneShowNum * 30 + 20;

        if (ScrollViewheight > 280)
        {
            ScrollViewheight = 280;
        }
        GUILayout.BeginHorizontal();
        ScrollPos = EditorGUILayout.BeginScrollView(ScrollPos, false, false, GUILayout.Height(ScrollViewheight));
        GUILayout.BeginVertical();

        int        nCurIndex = m_ShowFunNpcIndex;
        List <int> tKeys     = new List <int>(MonsterInfoList.Keys);

        tKeys.Sort();
        int nStart = (nCurIndex - 1) * m_OneShowNum;
        int nEnd   = Mathf.Min(nCurIndex * m_OneShowNum, tKeys.Count);
        int nTotal = (int)Mathf.Ceil(tKeys.Count / (float)m_OneShowNum);

        for (int i = nStart; i < nEnd; i++)
        {
            FunNpcInfo info = null;
            int        id   = tKeys[i];
            MonsterInfoList.TryGetValue(id, out info);
            string Buttonshow = "名字:\t" + info.name + "\t" + "ID:\t" + info.id;
            if (id != nChooseID)
            {
                height = 30;
            }
            else
            {
                height     = 60;
                Buttonshow = "当  前  选  中\n\n" + Buttonshow;
            }
            GUIContent b = new GUIContent(Buttonshow);
            if (GUILayout.Button(b, GUILayout.Height(height)))
            {
                m_nChooseId = id;
            }
        }
        GUILayout.EndVertical();
        EditorGUILayout.EndScrollView();
        GUILayout.EndHorizontal();

        //EditorGUILayout.Space();
        nCurIndex         = EditorGUILayout.IntSlider(nCurIndex, 1, nTotal);
        m_ShowFunNpcIndex = nCurIndex;

        EndSpace();
    }
예제 #2
0
    public void InitFunNpcInfo(object[] funNpcInfo)
    {
        //m_FunNpcInfoList;
        string[] sIdInfo = funNpcInfo[0].ToString().Split(',');
        LuaTable tInfo   = (LuaTable)funNpcInfo[1];

        for (int i = 0; i < sIdInfo.Length; i++)
        {
            string   sId         = sIdInfo[i];
            int      npcId       = int.Parse(sId);
            LuaTable tFunNpcInfo = (LuaTable)tInfo[npcId];

            FunNpcInfo funnpc = new FunNpcInfo();
            if (tFunNpcInfo != null)
            {
                funnpc.setInfo(tFunNpcInfo["npcid"].ToString(), tFunNpcInfo["name"].ToString(), "1", tFunNpcInfo["npcresource"].ToString());
                m_FunNpcInfoList.Add(npcId, funnpc);
            }
        }
    }