Exemple #1
0
    public bool ShowAd(string zoneID = null, HandleShowResultDelegate handleFinished = null, bool excuse = false)
    {
        if (string.IsNullOrEmpty(zoneID))
        {
            zoneID = null;
        }
        if (Advertisement.IsReady(zoneID))
        {
            if (excuse)
            {
                UIChangeDelegate uiChange = delegate(UIData data)
                {
                    if (data.uiChangeType == UIChangeType.Pop)
                    {
                        ShowAdEx(zoneID, handleFinished);
                    }
                };

                UIController.Instance.PushHint("ShowAdExcuse", "致歉", null, false, uiChange, 5.5f);
            }
            else
            {
                ShowAdEx(zoneID, handleFinished);
            }
            return(true);
        }
        return(false);
    }
Exemple #2
0
    private GameObject PushRepeatableLayer(string name, string fileName, UIChangeDelegate callback = null, bool isFreePop = true)
    {
        if (uiDatas.GetObjectValue(name) != null)
        {
            Debug.LogWarning("QIPAWORLD:重复添加UI--" + name);
            return(null);
        }

        GameObject uiLoad = LoadObjManager.Instance.GetLoadObj <GameObject>("UIPrefabs/" + fileName);

        GameObject ui     = GameObject.Instantiate <GameObject>(uiLoad, GameObject.Find("Canvas").transform);
        UIData     uiData = ui.AddComponent <UIData>();

        uiData.uiName         = name;
        uiData.changeCallback = callback;
        uiDatas.SetObjectValue(name, ui);
        uiNameList.Add(name);
        uiData.SetFreePop(isFreePop);
        return(ui);
    }
Exemple #3
0
    /// <summary>
    /// 添加一个提示layer
    /// </summary>
    /// <value>name 名字.</value>
    /// <value>key 文本的key.</value>
    /// <value>value 可变化文本内所替换的内容.</value>
    /// <value>log 是否是调试信息.</value>
    /// <value>callback 操作UI时的回掉方法.</value>
    /// <value>outTime 自动关闭UI的时间,不传为手动关闭.</value>
    public GameObject PushHint(string name, string key = null, string[] value = null, bool log = false, UIChangeDelegate callback = null, float outTime = 0f, bool quickPop = false)
    {
        GameObject ui = PushRepeatableLayer(name, "hintLayer", callback);

        if (ui != null)
        {
            if (log)
            {
                ui.GetComponentInChildren <Text>().text = key;
            }
            else if (key != null)
            {
                var text = ui.GetComponentInChildren <Text>();
                text.text = LocalizationManager.Instance.GetLocalizedValue(key, value);
                var bg = ui.transform.Find("Bg");
                if (bg)
                {
                    var rectTransform = bg.GetComponent <RectTransform>();
                    rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, text.preferredHeight + 100);
                }
            }
            else if (value != null)
            {
                var    text  = ui.GetComponentInChildren <Text>();
                string sText = "";
                foreach (string v in value)
                {
                    sText = sText + LocalizationManager.Instance.GetLocalizedValue(v);
                }
                text.text = sText;
                var bg = ui.transform.Find("Bg");
                if (bg)
                {
                    var rectTransform = bg.GetComponent <RectTransform>();
                    rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, text.preferredHeight + 100);
                }
            }
            if (outTime != 0)
            {
                Timer.Instance.DelayInvoke(outTime, () => { Pop(name); });
            }
        }
        else
        {
            if (quickPop)
            {
                Pop(name);
            }
        }
        return(ui);
    }
Exemple #4
0
 public GameObject Push(string name, UIChangeDelegate callback = null, bool isFreePop = true)
 {
     return(PushRepeatableLayer(name, name, callback, isFreePop));
 }
Exemple #5
0
    public GameObject PushLoading(string name, string key = null, string[] value = null, UIChangeDelegate callback = null)
    {
        GameObject ui = PushRepeatableLayer(name, "Loading", callback);

        if (ui != null)
        {
            uiLoadingLayerDatas.SetStringValue(name, name);
            loadingLayerNum++;
            if (key != null)
            {
                ui.GetComponentInChildren <Text>().text = LocalizationManager.Instance.GetLocalizedValue(key, value);
            }
        }
        ui.GetComponent <UIData>().SetFreePop(false);

        return(ui);
    }
Exemple #6
0
    public GameObject PushListHint(string name, string key = null, string[] value = null, bool log = false, UIChangeDelegate callback = null)
    {
        GameObject ui = this.PushHint(name, key, value, log, callback);

        if (ui != null)
        {
            HintListCell hintListCell = ui.AddComponent <HintListCell>();
            hintListCell.Init(name, new Vector2(Screen.width / 2, 0), new Vector2(Screen.width / 2, Screen.height / 2), hintLayerLast);
            hintLayerLast = ui;
        }
        return(ui);
    }
Exemple #7
0
    /// <summary>
    /// 添加一个带确定按钮的提示layer
    /// </summary>
    /// <value>name 名字.</value>
    /// <value>items 传道具的type 和数量.</value>
    /// <value>key 文本的key.</value>
    /// <value>value 可变化文本内所替换的内容.</value>
    /// <value>callback 操作UI时的回掉方法.</value>
    public GameObject PushItemHint(string name, string[,] items, string key = null, string[] value = null, UIChangeDelegate callback = null, bool isLog = false)
    {
        GameObject ui = PushRepeatableLayer(name, "hintItemLayer", callback);

        if (ui != null)
        {
            float textHeight = 0;
            if (key != null)
            {
                var text = ui.GetComponentInChildren <Text>();
                var textOriginalHeight = text.preferredHeight;
                if (isLog)
                {
                    text.text = key;
                }
                else
                {
                    text.text = LocalizationManager.Instance.GetLocalizedValue(key, value);
                }
                textHeight = text.preferredHeight - textOriginalHeight;
            }

            var bg = ui.transform.Find("Bg");

            var        itemBase = bg.transform.Find("ItemBase").transform;
            GameObject uiLoad   = LoadObjManager.Instance.GetLoadObj <GameObject>("UIPrefabs/Icon");

            var             uiLoadRectTransform   = uiLoad.GetComponent <RectTransform>();
            var             itemBaseRectTransform = itemBase.GetComponent <RectTransform>();
            int             itemNum = items.GetLength(0);
            GridLayoutGroup itemBaseGridLayoutGroup = itemBase.GetComponent <GridLayoutGroup>();

            float itemBaseNowHieght = (float)(Math.Ceiling(itemNum / Math.Floor(itemBaseRectTransform.sizeDelta.x / (uiLoadRectTransform.sizeDelta.x + itemBaseGridLayoutGroup.spacing.x))) * (uiLoadRectTransform.sizeDelta.y + itemBaseGridLayoutGroup.spacing.y) + 10);
            float itemBaseHieght    = itemBaseNowHieght - itemBaseRectTransform.sizeDelta.y;
            itemBaseRectTransform.sizeDelta  = new Vector2(itemBaseRectTransform.sizeDelta.x, itemBaseNowHieght);
            itemBaseGridLayoutGroup.cellSize = uiLoadRectTransform.sizeDelta;

            for (int i = 0; i < items.GetLength(0); ++i)
            {
                GameObject button = GameObject.Instantiate <GameObject>(uiLoad, itemBase);
                button.GetComponent <Icon>().Reset(items[i, 0], null, items[i, 1]);
            }
            if (bg)
            {
                var rectTransform = bg.GetComponent <RectTransform>();
                rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, rectTransform.sizeDelta.y + textHeight + itemBaseHieght);
            }
        }
        return(ui);
    }
Exemple #8
0
    /// <summary>
    /// 添加一个带确定按钮的提示layer
    /// </summary>
    /// <value>name 名字.</value>
    /// <value>userActionCallBack 用户操作回掉.</value>
    /// <value>key 文本的key.</value>
    /// <value>value 可变化文本内所替换的内容.</value>
    /// <value>bkey1 第一个按钮的文字的key.</value>
    /// <value>bkey2 第二个按钮的文字的key.</value>
    /// <value>callback 操作UI时的回掉方法.</value>
    public GameObject PushSelectHint(string name, Action <SelectStatus> userActionCallBack, string key = null, string[] value = null, string bkey1 = null, string bkey2 = null, UIChangeDelegate callback = null, bool onClickPop = true)
    {
        GameObject ui = PushRepeatableLayer(name, "selectHintLayer", callback);

        if (ui != null)
        {
            var selectHint = ui.GetComponent <SelectHint>();
            ui.GetComponent <UIData>().SetOnClickPop(onClickPop);
            if (key != null)
            {
                selectHint.hintText.text = LocalizationManager.Instance.GetLocalizedValue(key, value);
                var bg = ui.transform.Find("Bg");
                if (bg)
                {
                    var rectTransform = bg.GetComponent <RectTransform>();
                    rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, selectHint.hintText.preferredHeight + 300);
                }
            }
            if (bkey1 == null)
            {
                bkey1 = "确定";
            }
            if (bkey2 == null)
            {
                bkey2 = "取消";
            }
            selectHint.button2Text.text = LocalizationManager.Instance.GetLocalizedValue(bkey2);
            selectHint.button1Text.text = LocalizationManager.Instance.GetLocalizedValue(bkey1);
            ui.GetComponent <SelectHint>().Init(name, userActionCallBack);
        }
        return(ui);
    }