예제 #1
0
    public void RefreshUIByType(UIWndType type)
    {
        if (uiDict == null)
        {
            uiDict = new Dictionary <UIWndType, BaseWnd>();
        }

        if (!uiDict.ContainsKey(type))
        {
            GameObject instanceWnd = GameObject.Instantiate(Resources.Load(uiPathDict[type]), CanvasTransform) as GameObject;
            uiDict.Add(type, instanceWnd.GetComponent <BaseWnd>());
        }
        uiDict[type].RefreshUI();
    }
예제 #2
0
    /// <summary>
    /// 解析UIWndTypeJson
    /// </summary>
    private void ParseUIWndTypeJson()
    {
        uiPathDict = new Dictionary <UIWndType, string>();
        TextAsset textAsset = Resources.Load <TextAsset>("UIWnd");
        JsonData  jsonData  = JsonMapper.ToObject(textAsset.text);

        foreach (JsonData item in jsonData)
        {
            string    typeName = item["wndType"].ToString();
            UIWndType wndType  = (UIWndType)System.Enum.Parse(typeof(UIWndType), typeName);
            string    path     = item["path"].ToString();
            uiPathDict.Add(wndType, path);
        }
    }
예제 #3
0
    public void PushWnd(UIWndType type)
    {
        if (wndStack == null)
        {
            wndStack = new Stack <BaseWnd>();
        }

        BaseWnd newWnd = GetWnd(type);

        //Debug.Log(uiDict.Count);
        if (type == UIWndType.Battle)
        {
            GameManager.instance.GetBattle();
        }
        newWnd.Init();
        newWnd.OnShow();
        wndStack.Push(newWnd);
    }
예제 #4
0
    public BaseWnd GetWnd(UIWndType type)
    {
        if (uiDict == null)
        {
            uiDict = new Dictionary <UIWndType, BaseWnd>();
        }

        BaseWnd wnd;

        uiDict.TryGetValue(type, out wnd);

        if (wnd == null)
        {
            GameObject instanceWnd = GameObject.Instantiate(Resources.Load(uiPathDict[type]), CanvasTransform) as GameObject;
            uiDict.Add(type, instanceWnd.GetComponent <BaseWnd>());
        }

        return(uiDict[type]);
    }