Beispiel #1
0
 public GameObject SpawnUI(UINames uiName)
 {
     if (m_UIMap.ContainsKey(uiName))
     {
         return(m_UIMap[uiName].gameObject);
     }
     else
     {
         string uiPath = UIPath.Instance.GetUIPath(uiName);
         if (string.IsNullOrEmpty(uiPath))
         {
             Debug.LogError("没有定义名为【" + uiName.ToString() + "】的UI路径");
             return(null);
         }
         else
         {
             GameObject ui = Resources.Load <GameObject>(uiPath);
             if (null == ui)
             {
                 Debug.LogError("您要实例化名为【" + uiName.ToString() + "】的UI失败,请检查路径【" + uiPath + "】是否正确");
                 return(null);
             }
             ui = GameObject.Instantiate(ui);
             return(ui);
         }
     }
 }
Beispiel #2
0
    public void OpenUI(UINames uiName, bool closeAll = false)
    {
        if (!inited)
        {
            return;
        }
        if (closeAll)
        {
            CloseAllUI();
        }
        GameObject ui = UIPool.Instance.SpawnUI(uiName);

        ui.SetActive(true);
        UIBase uiBase = ui.GetComponent <UIBase>();

        uiBase.selfName = uiName;
        ui.transform.SetParent(m_uiParent);
        ui.transform.localScale    = Vector3.one;
        ui.transform.localPosition = Vector3.zero;
        RectTransform rectTrans = ui.GetComponent <RectTransform>();

        rectTrans.offsetMax = Vector2.zero;
        rectTrans.offsetMin = Vector2.zero;
        ui.transform.SetAsLastSibling();
        m_AllOpenUI.Add(uiName, uiBase);

        //发送UI打开事件
        Notification notify = new Notification(OPEN_UI);

        notify["uiName"] = uiName;
        notify.Send();
    }
Beispiel #3
0
    public override void OnEnter()
    {
        UINames openUIName = (UINames)Enum.Parse(typeof(UINames), toOpenUIName);

        if (UIManager.Instance.IsOpen(openUIName))
        {
            return;
        }
        UIManager.Instance.OpenUI(openUIName, closeAll);
        base.OnEnter();
    }
Beispiel #4
0
    public string GetUIPath(UINames UIName)
    {
        string path = "";

        switch (UIName)
        {
        case UINames.ChatUI:
            path = "Prefabs/UI/ChatUI";
            break;
        }
        return(path);
    }
 public static void TimedPatch_Begin(ref WuxiaBattleManager __instance, BattleStateMachine bsm)
 {
     bTimed = initiactiveBattle.Value;   // 总开关
     BM     = __instance;
     FSM    = bsm;
     TimedValue.Clear();
     TimedActives.Clear();
     TimedWaiting.Clear();
     TimedNext.Clear();
     UIWuxiaUnits.Clear();
     UIUnitIndex.Clear();
     UIPortraits.Clear();
     UINameBgs.Clear();
     UINames.Clear();
 }
Beispiel #6
0
 public void CloseUI(UINames uiName)
 {
     if (!inited)
     {
         return;
     }
     if (m_AllOpenUI.ContainsKey(uiName))
     {
         UIPool.Instance.DespawnUI(uiName);
         m_AllOpenUI.Remove(uiName);
         //发送UI关闭事件
         Notification notify = new Notification(CLOSE_UI);
         notify["uiName"] = uiName;
         notify.Send();
     }
 }
Beispiel #7
0
    public string GetUIPath(UINames UIName)
    {
        string path = "";

        switch (UIName)
        {
        case UINames.Canvas:
            return("Prefabs/UI/Canvas");

        case UINames.GameUI:
            return("Prefabs/UI/GameUI");

        case UINames.StartGameUI:
            return("Prefabs/UI/StartGameUI");
        }
        return(path);
    }
Beispiel #8
0
    public void DespawnUI(UINames uiNames, float destroyTime = 10.0f)
    {
        TimeUtil timeUtil = Singleton.GetInstance("TimeUtil") as TimeUtil;
        UIBase   ui       = UIManager.Instance.GetUI(uiNames);

        timeUtil.AddTimeCountDown(destroyTime, () => {
            if (null == ui || null == ui.gameObject || ui.gameObject.activeSelf)
            {
                return;
            }
            m_UIMap.Remove(ui.selfName);
            GameObject.Destroy(ui.gameObject);
        });
        ui.gameObject.SetActive(false);
        if (!m_UIMap.ContainsKey(ui.selfName))
        {
            m_UIMap.Add(ui.selfName, ui);
        }
    }
Beispiel #9
0
    public string GetUIPath(UINames UIName)
    {
        string path = "";

        switch (UIName)
        {
        case UINames.Snake_Room_SelectUI:
            path = "Prefabs/UI/Room";
            break;

        case UINames.RockerUI:
            path = "Prefabs/UI/Rocker";
            break;

        case UINames.LoginUI:
            path = "Prefabs/UI/LoginUI";
            break;

        case UINames.Draw2DPanelUI:
            path = "Prefabs/UI/2DDrawPanel";
            break;
        }
        return(path);
    }
Beispiel #10
0
 public UIBase GetUI(UINames uiName)
 {
     return(m_AllOpenUI[uiName]);
 }
Beispiel #11
0
 public bool IsOpen(UINames uiName)
 {
     return(m_AllOpenUI.ContainsKey(uiName));
 }
Beispiel #12
0
 public void DetroyUI(UINames uiName)
 {
     UIPool.Instance.DespawnUI(uiName, 0);
 }
Beispiel #13
0
    //public void enableCreateAcctUI() {
    //	enableUI(UINames.CREATEACCT);
    //}

    //public void enableLoginUI() {
    //	enableUI(UINames.LOGIN);
    //}

    public void enableUI(UINames name)
    {
        disableAll();
        panels[(int)name].SetActive(true);
        gameState = name;
    }
Beispiel #14
0
 public void RemoveUI(UINames uiName)
 {
     m_UIMap.Remove(uiName);
 }