Beispiel #1
0
    void AddComboAttackNum(string num)
    {
        //for (int i = 0; i < num.Length; ++i)
        //{
        //    int index = i;
        //    AssetCacheMgr.GetUIInstance("ComboAttackNum.prefab", (prefab, guid, gameObject) =>
        //        {
        //            GameObject go = (GameObject)gameObject;
        //            go.transform.parent = m_goComboAttackNumList.transform;
        //            go.transform.localScale = new Vector3(40, 52, 1);
        //            go.transform.localPosition = new Vector3(m_listComboAttackNum.Count * go.transform.localScale.x, 0, 0);
        //            go.transform.localEulerAngles = Vector3.zero;
        //            UISprite sp = go.GetComponentsInChildren<UISprite>(true)[0];
        //            sp.spriteName = "bj-" + num[index];
        //            m_listComboAttackNum.Add(sp);
        //        });
        //}

        //Mogo.Util.LoggerHelper.Debug("AddComboAttack " + num);

        if (num.Length > m_listComboAttackNum.Count)
        {
            for (int i = 0; i < m_listComboAttackNum.Count; ++i)
            {
                m_listComboAttackNum[i].spriteName = string.Concat("bj-", num[i]);

                if (m_listComboAttackNum[i].gameObject.activeSelf == false)
                {
                    m_listComboAttackNum[i].gameObject.SetActive(true);
                }
            }

            for (int i = 0; i < num.Length - m_listComboAttackNum.Count; ++i)
            {
                int index = i;
                AssetCacheMgr.GetUIInstance("ComboAttackNum.prefab", (prefab, guid, gameObject) =>
                {
                    GameObject go                 = (GameObject)gameObject;
                    go.transform.parent           = m_goComboAttackNumList.transform;
                    go.transform.localScale       = new Vector3(40, 52, 1);
                    go.transform.localPosition    = new Vector3(m_listComboAttackNum.Count * go.transform.localScale.x, 0, 0);
                    go.transform.localEulerAngles = Vector3.zero;
                    UISprite sp = go.GetComponentsInChildren <UISprite>(true)[0];
                    //Mogo.Util.LoggerHelper.Debug("Adding sprite " + num[num.Length-index-1]);
                    sp.spriteName = string.Concat("bj-", num[num.Length - index - 1]);
                    m_listComboAttackNum.Add(sp);
                });
            }
        }
        else
        {
            for (int i = 0; i < m_listComboAttackNum.Count; ++i)
            {
                if (i < num.Length)
                {
                    m_listComboAttackNum[i].spriteName = string.Concat("bj-", num[i]);

                    if (m_listComboAttackNum[i].gameObject.activeSelf == false)
                    {
                        m_listComboAttackNum[i].gameObject.SetActive(true);
                    }
                }
                else
                {
                    if (m_listComboAttackNum[i].gameObject.activeSelf == true)
                    {
                        m_listComboAttackNum[i].gameObject.SetActive(false);
                    }
                }
            }
        }
    }
    public void AttachFXToTimeLimitActivityInfoUI(Transform tranFxPos, Action <GameObject> action)
    {
        if (m_infoGridListMogoListImproved.SourceCamera == null)
        {
            m_infoGridListMogoListImproved.SourceCamera = GameObject.Find("Camera").GetComponentsInChildren <Camera>(true)[0];
        }

        if (m_infoGridListMogoListImproved.ObjCamera == null)
        {
            Debug.LogError("m_infoGridListMogoListImproved.ObjCamera is null");
            return;
        }

        INSTANCE_COUNT++;
        MogoGlobleUIManager.Instance.ShowWaitingTip(true);

        if (m_gridTimeLimitActivityListCamera == null)
        {
            m_gridTimeLimitActivityListCamera = m_infoGridListMogoListImproved.ObjCamera.GetComponentsInChildren <Camera>(true)[0];
        }

        if (m_gridTimeLimitActivityListCameraFX == null)
        {
            GameObject goTimeLimitActivityInfoCameraFx = new GameObject();
            goTimeLimitActivityInfoCameraFx.name                    = "TimeLimitActivityInfoCameraFx";
            goTimeLimitActivityInfoCameraFx.transform.parent        = m_infoGridListMogoListImproved.ObjCamera.transform;
            goTimeLimitActivityInfoCameraFx.transform.localPosition = new Vector3(0, 0, 0);
            goTimeLimitActivityInfoCameraFx.transform.localScale    = new Vector3(1, 1, 1);

            // �����������
            m_gridTimeLimitActivityListCameraFX                  = goTimeLimitActivityInfoCameraFx.AddComponent <Camera>();
            m_gridTimeLimitActivityListCameraFX.clearFlags       = CameraClearFlags.Depth;
            m_gridTimeLimitActivityListCameraFX.cullingMask      = 1 << 0;
            m_gridTimeLimitActivityListCameraFX.orthographic     = true;
            m_gridTimeLimitActivityListCameraFX.orthographicSize = m_gridTimeLimitActivityListCamera.orthographicSize;
            m_gridTimeLimitActivityListCameraFX.nearClipPlane    = -50;
            m_gridTimeLimitActivityListCameraFX.farClipPlane     = 50;
            m_gridTimeLimitActivityListCameraFX.depth            = 30;
            m_gridTimeLimitActivityListCameraFX.rect             = m_gridTimeLimitActivityListCamera.rect;
        }

        Vector3 pos = m_gridTimeLimitActivityListCamera.WorldToScreenPoint(tranFxPos.position);

        pos = m_gridTimeLimitActivityListCameraFX.ScreenToWorldPoint(pos);

        AssetCacheMgr.GetUIInstance("fx_ui_skill_yes.prefab", (prefab, id, go) =>
        {
            GameObject goFx               = null;
            goFx                          = (GameObject)go;
            goFx.name                     = "TimeLimitActivityInfoFinishedFx";
            goFx.transform.parent         = m_goTimeLimitActivityInfoGridListFx.transform;
            goFx.transform.position       = pos;
            goFx.transform.localPosition += new Vector3(3, -120, 0);
            goFx.transform.localScale     = new Vector3(1f, 1f, 1f);

            INSTANCE_COUNT--;
            if (INSTANCE_COUNT <= 0)
            {
                MogoGlobleUIManager.Instance.ShowWaitingTip(false);
            }

            if (action != null)
            {
                action(goFx);
            }
        });
    }
    void Awake()
    {
        m_instance    = this;
        m_myTransform = transform;
        FillFullNameData(m_myTransform);

        Initialize();

        m_transStrenthenDialogIconList = m_myTransform.Find(m_widgetToFullName["StrenthenDialogIconList"]);

        m_dragCamera = m_myTransform.Find(m_widgetToFullName["StrenthenDialogIconListCamera"]).GetComponentsInChildren <Camera>(true)[0];
        m_dragCamera.GetComponentsInChildren <UIViewport>(true)[0].sourceCamera = GameObject.Find("Camera").GetComponentsInChildren <Camera>(true)[0];
        m_dragCamera.GetComponentsInChildren <UIViewport>(true)[0].topLeft      = GameObject.Find("EquipmentUIIconListBGTopLeft").transform;
        m_dragCamera.GetComponentsInChildren <UIViewport>(true)[0].bottomRight  = GameObject.Find("EquipmentUIIconListBGBottomRight").transform;

        m_dragableCamera            = m_dragCamera.GetComponentsInChildren <MyDragableCamera>(true)[0];
        m_dragableCamera.LeftArrow  = FindTransform("StrenthenDialogIconListArrowU").gameObject;
        m_dragableCamera.RightArrow = FindTransform("StrenthenDialogIconListArrowD").gameObject;

        m_bcStrenthUIBoxCollider = FindTransform("StrenthUIBoxCollider").GetComponentsInChildren <BoxCollider>(true)[0];

        //m_goStrenthenDialogStarRewardStarLevel = m_myTransform.FindChild(m_widgetToFullName["StrenthenDialogStarRewardStarLevel"]).gameObject;
        //m_goStarLevelListPosBegin = m_myTransform.FindChild(m_widgetToFullName["StarLevelListPosBegin"]).gameObject;
        //m_StrenthenStarLevelInfo = m_goStrenthenDialogStarRewardStarLevel.AddComponent<StrenthenStarLevelInfo>();
        //if (m_StrenthenStarLevelInfo != null)
        //    m_StrenthenStarLevelInfo.CreateStarLevelInfo(m_goStrenthenDialogStarRewardStarLevel.transform, m_goStarLevelListPosBegin.transform.localPosition);

        m_lblBaseEquipType  = m_myTransform.Find(m_widgetToFullName["BaseAttributeEquipTypeText"]).GetComponentsInChildren <UILabel>(true)[0];
        m_lblStarLevel      = m_myTransform.Find(m_widgetToFullName["StarLevelText"]).GetComponentsInChildren <UILabel>(true)[0];
        m_lblBaseAttribute  = m_myTransform.Find(m_widgetToFullName["BaseAttributeText"]).GetComponentsInChildren <UILabel>(true)[0];
        m_lblAfterAttribute = m_myTransform.Find(m_widgetToFullName["AfterAttributeText"]).GetComponentsInChildren <UILabel>(true)[0];
        m_lblEquipmentLevel = m_myTransform.Find(m_widgetToFullName["StrenthenDialogLevelNum"]).GetComponentsInChildren <UILabel>(true)[0];

        for (int i = 0; i < 10; i++)
        {
            m_arrStrenthLevelBG[i] = m_myTransform.Find(m_widgetToFullName["StrenthenDialogLevelBG" + i]).gameObject;
            m_arrStrenthLevelBG[i].transform.localPosition = new Vector3(
                m_arrStrenthLevelBG[0].transform.localPosition.x + 53 * i,
                m_arrStrenthLevelBG[i].transform.localPosition.y,
                m_arrStrenthLevelBG[i].transform.localPosition.z);

            UIFilledSprite fs = m_myTransform.Find(m_widgetToFullName["StrenthenDialogLevelFG" + i]).GetComponentsInChildren <UIFilledSprite>(true)[0];
            m_fsEquipmentExpList[i] = fs;
            m_fsEquipmentExpList[i].transform.localPosition = new Vector3(
                m_fsEquipmentExpList[0].transform.localPosition.x + 53 * i,
                m_fsEquipmentExpList[i].transform.localPosition.y,
                m_fsEquipmentExpList[i].transform.localPosition.z);
        }
        m_ssEquipmentImage = m_myTransform.Find(m_widgetToFullName["StrenthenDialogImgFG"]).GetComponentsInChildren <UISlicedSprite>(true)[0];

        m_lblBaseReward0Title         = FindTransform("LevelReward0BaseTitle").GetComponentsInChildren <UILabel>(true)[0];
        m_lblBaseReward1Title         = FindTransform("LevelReward1BaseTitle").GetComponentsInChildren <UILabel>(true)[0];
        m_lblBaseReward2Title         = FindTransform("LevelReward2BaseTitle").GetComponentsInChildren <UILabel>(true)[0];
        m_lblBaseReward0Num           = FindTransform("LevelReward0BaseNum").GetComponentsInChildren <UILabel>(true)[0];
        m_lblBaseReward1Num           = FindTransform("LevelReward1BaseNum").GetComponentsInChildren <UILabel>(true)[0];
        m_lblBaseReward2Num           = FindTransform("LevelReward2BaseNum").GetComponentsInChildren <UILabel>(true)[0];
        m_lblBaseReward0TextAnimation = FindTransform("LevelReward0BaseTextAnimation").GetComponentsInChildren <UILabel>(true)[0];
        m_lblBaseReward1TextAnimation = FindTransform("LevelReward1BaseTextAnimation").GetComponentsInChildren <UILabel>(true)[0];
        m_lblBaseReward2TextAnimation = FindTransform("LevelReward2BaseTextAnimation").GetComponentsInChildren <UILabel>(true)[0];

        m_goLevelRewardAfter = FindTransform("GOLevelRewardAfter").gameObject;
        m_lblAfterReward0    = m_myTransform.Find(m_widgetToFullName["LevelReward0AfterText"]).GetComponentsInChildren <UILabel>(true)[0];
        m_lblAfterReward1    = m_myTransform.Find(m_widgetToFullName["LevelReward1AfterText"]).GetComponentsInChildren <UILabel>(true)[0];
        m_lblAfterReward2    = m_myTransform.Find(m_widgetToFullName["LevelReward2AfterText"]).GetComponentsInChildren <UILabel>(true)[0];

        // ǿ����ť
        m_goStrenthenDialogStrenth     = FindTransform("StrenthenDialogStrenth").gameObject;
        m_spStrenthenDialogStrenthBGUp = FindTransform("StrenthenDialogStrenthBGUp").GetComponentsInChildren <UISprite>(true)[0];

        m_lblNeedGold    = m_myTransform.Find(m_widgetToFullName["StrenthenDialogCostGold"]).GetComponentsInChildren <UILabel>(true)[0];
        m_lblCurrentGold = m_myTransform.Find(m_widgetToFullName["StrenthUICrrentGoldNum"]).GetComponentsInChildren <UILabel>(true)[0];
        m_lblNeedLevel   = m_myTransform.Find(m_widgetToFullName["StrenthenDialogNeedLevelText"]).GetComponentsInChildren <UILabel>(true)[0];
        m_lblCost        = m_myTransform.Find(m_widgetToFullName["StrenthenDialogCostText"]).GetComponentsInChildren <UILabel>(true)[0];

        // ǿ����Ҫ�IJ���
        m_lblNeedMaterial1    = FindTransform("StrenthenDialogCostMaterial1").GetComponentsInChildren <UILabel>(true)[0];
        m_lblNeedMaterial2    = FindTransform("StrenthenDialogCostMaterial2").GetComponentsInChildren <UILabel>(true)[0];
        m_spNeedMaterialIcon1 = FindTransform("StrenthenDialogCostMaterial1Icon").GetComponentsInChildren <UISprite>(true)[0];
        m_spNeedMaterialIcon2 = FindTransform("StrenthenDialogCostMaterial2Icon").GetComponentsInChildren <UISprite>(true)[0];
        m_goNeedMaterial2     = FindTransform("GOStrenthenDialogCostMaterial2").gameObject;

        // ǿ����Ҫ�IJ��ϲ���,��ʾ��ָ����ť
        m_goGOMaterialObtainTip              = m_myTransform.Find(m_widgetToFullName["GOMaterialObtainTip"]).gameObject;
        m_goStrenthenDialogMaterialTip       = m_myTransform.Find(m_widgetToFullName["StrenthenDialogMaterialTip"]).gameObject;
        m_spStrenthenDialogMaterialTipBGUp   = m_myTransform.Find(m_widgetToFullName["StrenthenDialogMaterialTipBGUp"]).GetComponentsInChildren <UISprite>(true)[0];
        m_spStrenthenDialogMaterialTipBGDown = m_myTransform.Find(m_widgetToFullName["StrenthenDialogMaterialTipBGDown"]).GetComponentsInChildren <UISprite>(true)[0];

        for (int i = 0; i < ICONGRIDNUM; ++i)
        {
            //obj = (GameObject)Instantiate(Resources.Load("GUI/StrenthenDialogIconGrid"));
            //obj.transform.parent = m_transStrenthenDialogIconList ;
            //obj.transform.localPosition = new Vector3(0,-ICONGRIDSPACE * i, 0);
            //obj.transform.localScale = new Vector3(0.0008f, 0.0008f, 0.0008f);
            //obj.GetComponentsInChildren<MyDragCamera>(true)[0].RelatedCamera = m_dragCamera;
            //obj.name = "EquipmentGrid"+i.ToString();
            //var s = m_transStrenthenDialogIconList.GetComponentsInChildren<MogoSingleButtonList>(true)[0] as MogoSingleButtonList;
            //s.SingleButtonList.Add(obj.GetComponentsInChildren<MogoSingleButton>(true)[0]);
            //obj.AddComponent<StrenthenEquipmentGrid>().id = i;
            //m_listEquipmentGrid.Add(obj);

            int index = i;
            AssetCacheMgr.GetUIInstance("StrenthenDialogIconGrid.prefab", (prefab, guid, go) =>
            {
                GameObject obj              = (GameObject)go;
                obj.transform.parent        = m_transStrenthenDialogIconList;
                obj.transform.localPosition = new Vector3(0, ICONGRIDSPACE * index, 0);
                obj.transform.localScale    = new Vector3(0.0008f, 0.0008f, 1);
                obj.GetComponentsInChildren <MyDragCamera>(true)[0].RelatedCamera = m_dragCamera;
                obj.name = "EquipmentGrid" + index.ToString();
                var s    = m_transStrenthenDialogIconList.GetComponentsInChildren <MogoSingleButtonList>(true)[0] as MogoSingleButtonList;
                s.SingleButtonList.Add(obj.GetComponentsInChildren <MogoSingleButton>(true)[0]);
                obj.AddComponent <StrenthenEquipmentGrid>().id = index;

                Transform tranStarLevel = obj.transform.Find("StrenthenDialogIconGridStarLevelList");
                StrenthenStarLevelInfo strenthenStarLevelInfo = tranStarLevel.gameObject.AddComponent <StrenthenStarLevelInfo>();
                if (strenthenStarLevelInfo != null)
                {
                    strenthenStarLevelInfo.CreateStarLevelInfo(tranStarLevel, new Vector3(0, 0, 0));
                }

                m_listEquipmentGrid.Add(obj);

                ShowEquipmentUpSign(index, false);

                if (m_listEquipmentGrid.Count == ICONGRIDNUM)
                {
                    EquipmentUIViewManager.Instance.IsCanClick = true;
                    EventDispatcher.TriggerEvent(BodyEnhanceManager.ON_SHOW);

                    if (MogoUIManager.Instance.StrenthUILoaded != null)
                    {
                        MogoUIManager.Instance.StrenthUILoaded();
                    }

                    // ������ʽ��Ҫ����(��ҳ����Ҫ����)
                    if (!m_dragableCamera.IsMovePage)
                    {
                        m_dragableCamera.FPageHeight = ICONGRIDSPACE * ICON_GRID_ONE_PAGE;
                        m_dragableCamera.MAXY        = ICON_OFFSET_Y;
                        if (m_listEquipmentGrid.Count > ICON_GRID_ONE_PAGE)
                        {
                            m_dragableCamera.MINY = (m_listEquipmentGrid.Count - ICON_GRID_ONE_PAGE) * ICONGRIDSPACE + ICON_OFFSET_Y;
                        }
                        else
                        {
                            m_dragableCamera.MINY = m_dragableCamera.MAXY;
                        }
                    }

                    MogoGlobleUIManager.Instance.ShowWaitingTip(false);
                }

                if (index == 0)
                {
                    StrenthTabDown(index);
                }
                else
                {
                    StrenthTabUp(index);
                }
            });
        }
    }
Beispiel #4
0
    public void FillItemGridData(List <PassRewardGridData> data, Action cb)
    {
        ClearRewardItemList();

        if (m_mbOK == null)
        {
            OKAct = cb;
        }
        else
        {
            if (cb != null)
            {
                m_mbOK.clickHandler = cb;
            }
        }

        for (int i = 0; i < data.Count; ++i)
        {
            int index = i;

            AssetCacheMgr.GetUIInstance("InstanceRewardItem.prefab", (prefab, guid, go) =>
            {
                GameObject obj              = (GameObject)go;
                obj.transform.parent        = m_instanceRewardItemList;
                obj.transform.localPosition = new Vector3(REWARDITEMSPACE * index, 0, 0);
                obj.transform.localScale    = new Vector3(0.0008f, 0.0008f, 1);

                UISprite spIcon = obj.transform.Find("InstanceRewardItemFG").GetComponentsInChildren <UISprite>(true)[0];
                UISprite spBG   = obj.transform.Find("InstanceRewardItemBG").GetComponentsInChildren <UISprite>(true)[0];
                UILabel lblNum  = obj.transform.Find("InstanceRewardItemCount").GetComponentsInChildren <UILabel>(true)[0];
                UILabel lblName = obj.transform.Find("InstanceRewardItemText").GetComponentsInChildren <UILabel>(true)[0];
                InventoryManager.SetIcon(data[index].id, spIcon, 0, null, spBG);

                if (lblNum != null)
                {
                    lblNum.text  = "";
                    lblName.text = data[index].iconName;
                    lblNum.text  = string.Concat("x", data[index].num);
                }

                Debug.Log("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ " + spIcon.spriteName);
                m_listItem.Add(obj);

                if (index == data.Count - 1)
                {
                    if (m_camItemList == null)
                    {
                        Debug.Log("m_camItemList is null");
                        m_camItemList = FindTransform("InstancePassRewardItemListCamera").GetComponentsInChildren <Camera>(true)[0];
                        m_camItemList.GetComponentsInChildren <UIViewport>(true)[0].sourceCamera = GameObject.Find("MogoMainUI").transform.Find("Camera").GetComponentsInChildren <Camera>(true)[0];
                    }

                    if (m_listItem.Count <= 5)
                    {
                        if (m_camItemList != null)
                        {
                            m_camItemList.transform.localPosition = m_vec3StartPos[index];
                        }
                        else
                        {
                            Debug.LogError("m_camItemList is null");
                        }
                    }
                    else
                    {
                        if (m_camItemList != null)
                        {
                            m_camItemList.transform.localPosition = m_vec3StartPos[4];
                        }
                        else
                        {
                            Debug.LogError("m_camItemList is null");
                        }
                    }

                    if (IsWin)
                    {
                        PlayVictoryAnimation();
                    }
                }
            });
        }
    }
    /// <summary>
    /// 添加一条聊天信息
    /// </summary>
    /// <param name="text">聊天信息显示的内容</param>
    /// <param name="channel">聊天信息放至的频道</param>
    /// <param name="userId">发送玩家的ID</param>
    /// <param name="channelIcon">聊天信息发送的频道,用于显示频道图标</param>
    /// <param name="LvAndNameString">聊天信息的人名,用于计算下划线的长度</param>
    /// <param name="underLineColor">人名下划线颜色</param>
    /// <param name="lineOffsetX">人名下划线偏移,自己向别的玩家的私聊信息需处理</param>
    public void AddChatUIDialogText(string text, ChannelId channel, ulong userId,
                                    ChannelId channelIcon, string LvAndNameString = "", string underLineColor = "13FFD5", int lineOffsetX = 60)
    {
        string name = "WorldChannelDialogLabelList";

        int    m_iLineNum  = 0;
        int    m_iSpaceNum = 0;
        Camera relatedCam  = m_camWorldChannelCamera;


        AssetCacheMgr.GetUIInstance("ChatUIDialogLabel.prefab", (prefab, id, go) =>
        {
            GameObject obj = (GameObject)go;


            UILabel lblChatUIDialogLabelText     = obj.transform.Find("ChatUIDialogLabelText").GetComponentsInChildren <UILabel>(true)[0];
            lblChatUIDialogLabelText.effectStyle = UILabel.Effect.Outline;

            UISprite spChatUIDialogLabelChannel = obj.transform.Find("ChatUIDialogLabelChannel").GetComponentsInChildren <UISprite>(true)[0];
            SetChatUIDialogLabelChannel(channelIcon, spChatUIDialogLabelChannel);

            // 设置下划线
            UILabel lblChatUIDialogLabelUnderLine = obj.transform.Find("ChatUIDialogLabelUnderLine").GetComponentsInChildren <UILabel>(true)[0];
            float totalUnderline = m_inputText.label.font.CalculatePrintedSize(LvAndNameString, true, UIFont.SymbolStyle.None).x;
            float oneUnderLine   = m_inputText.label.font.CalculatePrintedSize("_", true, UIFont.SymbolStyle.None).x;
            int underLineCount   = (int)(totalUnderline / oneUnderLine);

            lblChatUIDialogLabelUnderLine.text = "";
            for (int i = 0; i < underLineCount; i++)
            {
                lblChatUIDialogLabelUnderLine.text += "_";
            }

            // 设置下划线颜色
            lblChatUIDialogLabelUnderLine.text = string.Concat("[", underLineColor, "]", lblChatUIDialogLabelUnderLine.text, "[-]");

            switch (channel)
            {
            case ChannelId.WORLD:
                name        = "WorldChannelDialogLabelList";
                m_iLineNum  = m_iLineNumWorld;
                m_iSpaceNum = m_iSpaceNumWorld;
                relatedCam  = m_camWorldChannelCamera;
                lblChatUIDialogLabelText.effectColor = new Color32(32, 19, 14, 255);
                break;

            case ChannelId.UNION:
                name        = "TongChannelDialogLabelList";
                m_iLineNum  = m_iLineNumTong;
                m_iSpaceNum = m_iSpaceNumTong;
                relatedCam  = m_camTongChannelCamera;
                lblChatUIDialogLabelText.effectColor = new Color32(0, 0, 0, 255);
                break;

            case ChannelId.PERSONAL:
                name        = "PrivateChannelDialogLabelList";
                m_iLineNum  = m_iLineNumPrivate;
                m_iSpaceNum = m_iSpaceNumPrivate;
                relatedCam  = m_camPrivateChannelCamera;
                lblChatUIDialogLabelText.effectColor = new Color32(13, 0, 16, 255);
                lblChatUIDialogLabelUnderLine.transform.localPosition = new Vector3(lineOffsetX,
                                                                                    lblChatUIDialogLabelUnderLine.transform.localPosition.y,
                                                                                    lblChatUIDialogLabelUnderLine.transform.localPosition.z);
                break;

            case ChannelId.SYSTEM:
                name        = "WorldChannelDialogLabelList";
                m_iLineNum  = m_iLineNumWorld;
                m_iSpaceNum = m_iSpaceNumWorld;
                relatedCam  = m_camWorldChannelCamera;
                lblChatUIDialogLabelText.effectColor = new Color32(0, 0, 0, 255);
                break;
            }

            obj.SetActive(true);
            obj.transform.parent            = m_myTransform.Find(m_widgetToFullName[name]);
            obj.transform.parent.localScale = new Vector3(0.0008f, 0.0008f, 1);
            obj.transform.localPosition     = Vector3.zero;
            obj.transform.localScale        = new Vector3(1, 1, 1);
            obj.transform.GetComponentsInChildren <MyDragCamera>(true)[0].RelatedCamera = relatedCam;

            string strTmp = text;

            for (int i = 0; i < text.Length; ++i)
            {
                if (text[i] == '<' && text.Substring(i).Length >= 6 && text.Substring(i, 6) == "<info=")
                {
                    int tmp = i + 7;

                    while (tmp < text.Length)
                    {
                        if (text[tmp] == '>')
                        {
                            float length = m_inputText.label.font.CalculatePrintedSize(text.Substring(0, i), true, UIFont.SymbolStyle.None).x;

                            string originString = text.Substring(i, tmp - i + 1);
                            text = text.ReplaceFirst(originString, TranslateInputText(originString));
                            AddChatUIEquipmentLabel(TranslateInputText(originString),
                                                    obj.transform.Find("ChatUIDialogLabelSLList"), (g) =>
                            {
                                float width = m_inputText.label.font.size * length;
                                int row     = (int)((width + m_fOffect) / LINEWIDTH);

                                float labelWidth = m_inputText.label.font.CalculatePrintedSize(TranslateInputText(originString),
                                                                                               true, UIFont.SymbolStyle.None).x *m_inputText.label.font.size;

                                if ((width + m_fOffect) + labelWidth > LINEWIDTH * (row + 1))
                                {
                                    m_iAddSpaceNum = (int)((LINEWIDTH * (row + 1) - (width + m_fOffect)) /
                                                           (m_inputText.label.font.CalculatePrintedSize(" ",
                                                                                                        true, UIFont.SymbolStyle.None).x *m_inputText.label.font.size));


                                    //m_fOffect += m_inputText.label.font.CalculatePrintedSize("   ", true, UIFont.SymbolStyle.None).x *
                                    //    m_inputText.label.font.size;

                                    for (int j = 0; j < m_iAddSpaceNum; ++j)
                                    {
                                        text = text.Insert(i + j, " ");
                                    }

                                    width += (m_iAddSpaceNum * m_inputText.label.font.CalculatePrintedSize(" ",
                                                                                                           true, UIFont.SymbolStyle.None).x *m_inputText.label.font.size);

                                    m_fOffect += (LINEWIDTH * (row + 1) - (width + m_fOffect));

                                    width += m_fOffect;
                                }
                                else
                                {
                                    //width = width + m_fOffect - m_iAddSpaceNum * (m_inputText.label.font.CalculatePrintedSize(" ", true, UIFont.SymbolStyle.None).x *
                                    //  m_inputText.label.font.size);
                                    width += m_fOffect;
                                }
                                //else
                                //{
                                //   width += m_fOffect;
                                //}

                                //g.transform.localPosition = new Vector3(obj.transform.localPosition.x +
                                // width % 750,
                                //     obj.transform.localPosition.y - (int)(width / 750) *
                                // 35, obj.transform.localPosition.z);

                                //g.transform.localPosition = new Vector3(obj.transform.localPosition.x +
                                //m_inputText.label.font.size * length % 750,
                                //    obj.transform.localPosition.y - (int)(m_inputText.label.font.size * length / 750) *
                                //m_inputText.label.font.size, obj.transform.localPosition.z);

                                //g.transform.GetComponentsInChildren<ChatUIEquipmentGrid>(true)[0].LogicText = originString;


                                //g.transform.localPosition = new Vector3(obj.transform.localPosition.x +
                                //     width % LINEWIDTH,
                                //    obj.transform.localPosition.y - (int)(width / LINEWIDTH) * m_inputText.label.font.size, obj.transform.localPosition.z);//这里改成0 - ...

                                g.transform.localPosition = new Vector3(obj.transform.localPosition.x +
                                                                        width % LINEWIDTH,
                                                                        0 - (int)(width / LINEWIDTH) * m_inputText.label.font.size, obj.transform.localPosition.z);

                                g.transform.GetComponentsInChildren <ChatUIEquipmentGrid>(true)[0].LogicText = originString;
                            });
                            break;
                        }

                        ++tmp;
                    }
                }
                else if (text[i] == '<' && text.Substring(i).Length >= 6 && text.Substring(i, 6) == "<face=")
                {
                    int tmp = i + 7;

                    while (tmp < text.Length)
                    {
                        if (text[tmp] == '>')
                        {
                            float length = m_inputText.label.font.CalculatePrintedSize(text.Substring(0, i), true, UIFont.SymbolStyle.None).x;

                            string originString = text.Substring(i, tmp - i + 1);
                            text = text.ReplaceFirst(originString, /*TranslateInputText(originString)*/ " ");
                            AddChatUIFaceLabel(TranslateInputText(originString),
                                               obj.transform.Find("ChatUIDialogLabelSLList"), (g) =>
                            {
                                float width = m_inputText.label.font.size * length;
                                int row     = (int)((width + m_fOffect) / LINEWIDTH);

                                if ((width + m_fOffect) + FONTSIZE > LINEWIDTH * (row + 1))
                                {
                                    m_fOffect += (LINEWIDTH * (row + 1) - (width + m_fOffect));
                                    width      = width + m_fOffect;
                                }
                                else
                                {
                                    width += m_fOffect;
                                }

                                g.transform.localPosition = new Vector3(obj.transform.localPosition.x +
                                                                        width % LINEWIDTH,
                                                                        obj.transform.localPosition.y - (int)(width / LINEWIDTH) *
                                                                        FONTSIZE, obj.transform.localPosition.z);
                            });
                            break;
                        }

                        ++tmp;
                    }
                }
                else
                {
                    float length = m_inputText.label.font.CalculatePrintedSize(text.Substring(0, i), true, UIFont.SymbolStyle.None).x;

                    float width      = m_inputText.label.font.size * length;
                    int row          = (int)((width + m_fOffect) / LINEWIDTH);
                    float labelWidth = m_inputText.label.font.CalculatePrintedSize(text[i].ToString(),
                                                                                   true, UIFont.SymbolStyle.None).x *m_inputText.label.font.size;

                    if ((width + m_fOffect) + labelWidth > LINEWIDTH * (row + 1))
                    {
                        // m_iAddSpaceNum = (int)((LINEWIDTH * (row + 1) - (width + m_fOffect)) /
                        //(m_inputText.label.font.CalculatePrintedSize(" ",
                        //         true, UIFont.SymbolStyle.None).x * m_inputText.label.font.size));
                        m_fOffect += (LINEWIDTH * (row + 1) - (width + m_fOffect));
                        //width += m_fOffect;
                    }
                    //else
                    //{
                    //    width += m_fOffect;
                    //}*/
                }
            }

            lblChatUIDialogLabelText.text            = text;
            lblChatUIDialogLabelText.supportEncoding = true;

            obj.transform.localPosition = new Vector3(0, 0 - FONTSIZE * m_iLineNum - FONTSPACE * m_iSpaceNum, 0);


            obj.transform.GetComponentsInChildren <BoxCollider>(true)[0].size =
                new Vector3(obj.transform.GetComponentsInChildren <BoxCollider>(true)[0].size.x,
                            obj.transform.GetComponentsInChildren <BoxCollider>(true)[0].size.y *
                            ((int)(m_inputText.label.font.CalculatePrintedSize(text, true, UIFont.SymbolStyle.None).x *FONTSIZE / LINEWIDTH) + 1),
                            obj.transform.GetComponentsInChildren <BoxCollider>(true)[0].size.z);

            obj.transform.GetComponentsInChildren <BoxCollider>(true)[0].center =
                new Vector3(obj.transform.GetComponentsInChildren <BoxCollider>(true)[0].center.x,
                            obj.transform.GetComponentsInChildren <BoxCollider>(true)[0].center.y -
                            ((int)(m_inputText.label.font.CalculatePrintedSize(text, true, UIFont.SymbolStyle.None).x *FONTSIZE / LINEWIDTH)) * 0.5f * FONTSIZE,
                            obj.transform.GetComponentsInChildren <BoxCollider>(true)[0].center.z);

            obj.GetComponentsInChildren <CommunityUIDialogLabel>(true)[0].ID = userId;

            m_iLineNum += ((int)(m_inputText.label.font.CalculatePrintedSize(text, true, UIFont.SymbolStyle.None).x *FONTSIZE / LINEWIDTH) + 1);


            relatedCam.GetComponentsInChildren <MyDragableCamera>(true)[0].MINY = -192 - (FONTSIZE * m_iLineNum + m_iSpaceNum * FONTSPACE) + 406;

            CommunityLabelInfo info = new CommunityLabelInfo();
            info.height             = FONTSIZE * ((int)(m_inputText.label.font.CalculatePrintedSize(text, true, UIFont.SymbolStyle.None).x *FONTSIZE / LINEWIDTH) + 1);
            info.go = obj;

            m_queueChatData.Enqueue(info);

            if (m_queueChatData.Count > 50)
            {
                CommunityLabelInfo infoTmp = m_queueChatData.Dequeue();
                AssetCacheMgr.ReleaseInstance(infoTmp.go);
                //Debug.LogError(infoTmp.height);
                relatedCam.GetComponentsInChildren <MyDragableCamera>(true)[0].MAXY -= (infoTmp.height + FONTSPACE);
            }

            m_iSpaceNum++;

            //if (text.Length > 7 && (text[0] == '[' && text[7] == ']'))
            //{
            //    obj.transform.GetComponentsInChildren<BoxCollider>(true)[0].size =
            //   new Vector3((text.Length - 8 - 2) * 22 + 14, 22, 0);

            //    obj.transform.GetComponentsInChildren<BoxCollider>(true)[0].center =
            //      new Vector3(obj.transform.GetComponentsInChildren<BoxCollider>(true)[0].size.x * 0.5f, 0f, 0f);

            //    m_lblInputText.text += text.Substring(8);


            //}
            //else
            //{
            //    obj.transform.GetComponentsInChildren<BoxCollider>(true)[0].size =
            //  new Vector3((text.Length - 2) * 22 + 14, 22, 0);

            //    m_lblInputText.text += text;
            //}

            switch (channel)
            {
            case ChannelId.WORLD:
            case ChannelId.SYSTEM:
                m_iLineNumWorld  = m_iLineNum;
                m_iSpaceNumWorld = m_iSpaceNum;
                break;

            case ChannelId.UNION:
                m_iLineNumTong  = m_iLineNum;
                m_iSpaceNumTong = m_iSpaceNum;
                break;

            case ChannelId.PERSONAL:
                m_iLineNumPrivate  = m_iLineNum;
                m_iSpaceNumPrivate = m_iSpaceNum;
                break;
            }

            if ((m_iLineNum * FONTSIZE + m_iSpaceNum * FONTSPACE) > 428)
            {
                float offect = ((int)(m_inputText.label.font.CalculatePrintedSize(text, true, UIFont.SymbolStyle.None).x *FONTSIZE / LINEWIDTH) + 1) * FONTSIZE + FONTSPACE;
                relatedCam.transform.localPosition = new Vector3(relatedCam.transform.localPosition.x,
                                                                 relatedCam.transform.localPosition.y - offect, relatedCam.transform.localPosition.z);
            }

            m_listChatUIDialogText.Add(obj);
        });


        m_fOffect      = 0;
        m_iAddSpaceNum = 0;
    }
    public void RefreshFXGrid(System.Collections.Generic.List <EquipFXUIGridData> list)
    {
        for (int i = 0; i < m_listFXGrid.Count; ++i)
        {
            AssetCacheMgr.ReleaseInstance(m_listFXGrid[i]);
        }

        m_listFXGrid.Clear();
        m_listCanActiveFXID.Clear();
        GetTransform("EquipFXUIDialogFXGridList").GetComponentsInChildren <MogoSingleButtonList>(true)[0].SingleButtonList.Clear();
        GetTransform("EquipFXUIDialogFXGridListCam").localPosition = new Vector3(0, -200f, 0);

        bool isNextShowAsQuestionMark = false;

        for (int i = 0; i < list.Count; ++i)
        {
            int index = i;

            AssetCacheMgr.GetUIInstance("EquipFXUIDialogFXGrid.prefab", (name, id, go) =>
            {
                GameObject gameObj = (GameObject)go;

                gameObj.name       = string.Concat("EquipFXUIDialogFXGrid", index);
                EquipFXUIGrid grid = gameObj.AddComponent <EquipFXUIGrid>();
                grid.SetGotText(list[index].gridText);
                grid.SetIconFG(list[index].gridIcon);

                if (!isNextShowAsQuestionMark)
                {
                    grid.SetNotGetText(list[index].gridText);
                }
                else
                {
                    grid.SetNotGetText("???");
                }

                if (list[index].gridProgressSize > 1f)
                {
                    grid.SetPrgressSize(1);
                }
                else
                {
                    grid.SetPrgressSize(list[index].gridProgressSize);
                }
                grid.SetProgressText(list[index].gridProgressText);
                grid.ID = index;
                grid.SetActiveBtnUpHandler(OnActiveBtnUp);
                grid.GetComponentsInChildren <MFUIButtonHandler>(true)[0].ID           = index;
                grid.GetComponentsInChildren <MFUIButtonHandler>(true)[0].ClickHandler = OnFXGridUp;

                if (list[index].isActive)
                {
                    grid.ShowActiveBtn(false);
                    grid.ShowGotText(true);
                    grid.ShowNotGetText(false);
                    //grid.SetActiveBtnText(LanguageData.GetContent(7532));
                    grid.ShowProgress(false);
                    grid.ShowGetSign(true);
                }
                else
                {
                    if (list[index].gridProgressSize >= 1f)
                    {
                        grid.ShowActiveBtn(true);
                        grid.ShowGotText(false);
                        grid.ShowNotGetText(true);
                        grid.SetActiveBtnText(LanguageData.GetContent(7532));
                        grid.ShowProgress(true);
                        grid.ShowGetSign(false);
                        m_listCanActiveFXID.Add(index);
                    }
                    else
                    {
                        grid.ShowActiveBtn(true);
                        grid.ShowProgress(true);
                        grid.ShowGotText(false);
                        grid.ShowNotGetText(true);
                        grid.ShowGetSign(false);

                        grid.SetActiveBtnText(LanguageData.GetContent(7533));
                    }

                    isNextShowAsQuestionMark = true;
                }

                gameObj.GetComponentsInChildren <MyDragCamera>(true)[0].RelatedCamera =
                    GetTransform("EquipFXUIDialogFXGridListCam").GetComponentsInChildren <Camera>(true)[0];

                GetTransform("EquipFXUIDialogFXGridList").GetComponentsInChildren <MogoSingleButtonList>(true)[0].SingleButtonList.Add(
                    gameObj.GetComponentsInChildren <MogoSingleButton>(true)[0]);

                MFUIUtils.AttachWidget(gameObj.transform, GetTransform("EquipFXUIDialogFXGridList"));
                gameObj.transform.localPosition = new Vector3(0, -135f * index, 0);
                gameObj.transform.localScale    = Vector3.one;

                if (list.Count > 4)
                {
                    GetTransform("EquipFXUIDialogFXGridListCam").GetComponentsInChildren <MyDragableCamera>(true)[0].MINY =
                        -200f - 135f * (list.Count - 4);
                }
                else
                {
                    GetTransform("EquipFXUIDialogFXGridListCam").GetComponentsInChildren <MyDragableCamera>(true)[0].MINY = -200f;
                }

                m_listFXGrid.Add(gameObj);
            });
        }
    }
    public void SetGridLayout(Action callback)
    {
        if (m_listChallengeUIGrid.Count == GRIDNUM)
        {
            if (callback != null)
            {
                callback();
            }
            EventDispatcher.TriggerEvent(DoorOfBurySystem.ON_CHALLENGE_SHOW);
            EventDispatcher.TriggerEvent(Events.CampaignEvent.GetCampaignLastTime, 1);
            EventDispatcher.TriggerEvent(Events.OccupyTowerEvent.GetOccupyTowerStatePoint);
            ChallengeUILogicManager.Instance.RefreshUI((int)ChallengeGridID.OgreMustDie);
            ChallengeUILogicManager.Instance.CollectChallengeUIGridMessage();
        }
        else
        {
            m_gridListMyDragableCamera.DestroyMovePagePosList(); // 删除翻页位置
            m_gridListMyDragableCamera.DestroyDOTPageList();     // 删除页点

            for (int i = 0; i < GRIDNUM; i++)
            {
                int index = i;

                INSTANCE_COUNT++;
                MogoGlobleUIManager.Instance.ShowWaitingTip(true);

                AssetCacheMgr.GetUIInstance("ChallengeGrid.prefab", (prefab, guid, go) =>
                {
                    GameObject temp = (GameObject)go;
                    temp.AddComponent <ChallengeUIGrid>();
                    temp.transform.parent        = m_tranChallengeGridList;
                    temp.transform.localPosition = new Vector3(index * ITEMSPACE + OFFSET_X, 0, 0);
                    temp.transform.localScale    = new Vector3(1, 1, 1);
                    temp.name = string.Concat("ChallengeGrid", index);
                    temp.GetComponentsInChildren <MyDragCamera>(true)[0].RelatedCamera = m_gridListCamera;

                    ChallengeUIGrid gridUI = temp.GetComponentInChildren <ChallengeUIGrid>();
                    gridUI.id = index + 1;
                    if (index < GRIDNUM)
                    {
                        gridUI.SetImg(gridImgName[index]);
                    }

                    m_listChallengeUIGrid.Add(gridUI);

                    m_gridListMyDragableCamera.MINX = OFFSET_X;
                    m_gridListMyDragableCamera.MAXX = (m_listChallengeUIGrid.Count - GRID_COUNT_ONE_PAGE) * ITEMSPACE;

                    // 创建翻页位置
                    if (index % GRID_COUNT_ONE_PAGE == 0)
                    {
                        GameObject trans                 = new GameObject();
                        trans.transform.parent           = m_gridListCamera.transform;
                        trans.transform.localPosition    = new Vector3(index / GRID_COUNT_ONE_PAGE * ITEMSPACE * GRID_COUNT_ONE_PAGE, 0, 0);
                        trans.transform.localEulerAngles = Vector3.zero;
                        trans.transform.localScale       = new Vector3(1, 1, 1);
                        trans.name = "GridListPosHorizon" + index / GRID_COUNT_ONE_PAGE;
                        m_gridListMyDragableCamera.transformList.Add(trans.transform);
                        m_gridListMyDragableCamera.SetCurrentPage(m_gridListMyDragableCamera.GetCurrentPage());

                        // 创建页数点
                        ++m_iDotPageNum;
                        int num = m_iDotPageNum;
                        AssetCacheMgr.GetUIInstance("ChooseServerPage.prefab", (prefabPage, idPage, goPage) =>
                        {
                            GameObject objPage = (GameObject)goPage;

                            objPage.transform.parent        = m_goChallengeUIPageDOTList.transform;
                            objPage.transform.localPosition = new Vector3((num - 1) * 40, 0, 0);
                            objPage.transform.localScale    = Vector3.one;
                            objPage.name = "ActivityGridPage" + num;
                            m_gridListMyDragableCamera.ListPageDown.Add(objPage.GetComponentsInChildren <UISprite>(true)[1].gameObject);
                            m_goChallengeUIPageDOTList.transform.localPosition = new Vector3(-20 * (num - 1), m_goChallengeUIPageDOTList.transform.localPosition.y, 0);

                            // 选择当前页
                            if (num - 1 == m_gridListMyDragableCamera.GetCurrentPage())
                            {
                                objPage.GetComponentsInChildren <UISprite>(true)[1].gameObject.SetActive(true);
                            }
                            else
                            {
                                objPage.GetComponentsInChildren <UISprite>(true)[1].gameObject.SetActive(false);
                            }
                            m_gridListMyDragableCamera.GODOTPageList = m_goChallengeUIPageDOTList;
                            m_gridListMyDragableCamera.SetCurrentPage(m_gridListMyDragableCamera.GetCurrentPage());
                        });
                    }

                    INSTANCE_COUNT--;
                    if (INSTANCE_COUNT <= 0)
                    {
                        MogoGlobleUIManager.Instance.ShowWaitingTip(false);
                    }

                    if (m_listChallengeUIGrid.Count == GRIDNUM)
                    {
                        if (callback != null)
                        {
                            callback();
                        }

                        EventDispatcher.TriggerEvent(DoorOfBurySystem.ON_CHALLENGE_SHOW);
                        ChallengeUILogicManager.Instance.InitializeData();

                        EventDispatcher.TriggerEvent(Events.CampaignEvent.GetCampaignLastTime, 1);
                        EventDispatcher.TriggerEvent(Events.OccupyTowerEvent.GetOccupyTowerStatePoint);

                        ChallengeUILogicManager.Instance.RefreshUI((int)ChallengeGridID.OgreMustDie);
                        ChallengeUILogicManager.Instance.CollectChallengeUIGridMessage();
                    }
                });
            }
        }
    }
Beispiel #8
0
    public void SetGridLayout <T>(int NewCount, Transform parentTrans, Action loaded) where T : Component
    {
        if (width == 0)
        {
            width = ColSize * UnitWidth + (ColSize - 1) * XMargin;
        }
        if (height == 0)
        {
            height = RowSize * UnitHeight + (RowSize - 1) * YMargin;
        }
        int PageSize = ColSize * RowSize;

        MaxPageIndex = (byte)(Math.Ceiling((double)NewCount / PageSize) - 1);
        int curGridCount = DataGUIDList.Count;

        if (curGridCount < NewCount)
        {
            for (int index = curGridCount; index < NewCount; index++)
            {
                var uniqueID   = index;
                var curPage    = index / PageSize;
                var curIndex   = index % PageSize;
                var curRow     = curIndex / ColSize;
                var curCol     = curIndex % ColSize;
                var startPoint = new Vector2();

                startPoint = getStartPoint(curPage);
                zeroPoint  = Vector2.zero;
                var size        = IsHorizontal ? ColSize : RowSize;
                var lastPageNum = NewCount % PageSize == 0 ? PageSize : NewCount % PageSize;
                var cmr         = (NewCount / PageSize - 1)
                                  + (lastPageNum >= size ? 1 : lastPageNum % size / (float)size);
                if (IsHorizontal)
                {
                    lastPoint = new Vector2(width * IsOpposite * cmr, 0);
                }
                else
                {
                    lastPoint = new Vector2(0, -height * IsOpposite * cmr);
                }

                AssetCacheMgr.GetUIInstance(PrefabName + ".prefab", (prefab, id, go) =>
                {
                    GameObject obj              = (GameObject)go;
                    obj.transform.parent        = parentTrans;
                    obj.transform.localPosition = new Vector3(startPoint.x
                                                              + (curCol * (XMargin + UnitWidth) + UnitWidth / 2) * IsOpposite
                                                              ,
                                                              startPoint.y
                                                              - (curRow * (YMargin + UnitHeight) + UnitHeight / 2) * IsOpposite
                                                              , 0.0f);
                    obj.transform.localScale = new Vector3(1, 1, 1);
                    if (!IsOneButton)
                    {
                        var btnList = obj.transform.GetComponentsInChildren <MogoButton>(true);
                        foreach (var single in btnList)
                        {
                            single.pressHandler += PressHandler;
                            single.dragHandler  += DragHandler;
                        }
                    }
                    DataGUIDList.Push(go);

                    UnityEngine.Component unit = obj.AddComponent <T>();

                    /****手机系统上无法用该方式添加控件
                     * if (!unit)
                     * {
                     *  var type = Type.GetType(PrefabName);
                     *  if (type != null)
                     *      unit = obj.AddComponent(type);
                     * }
                     * if (unit == null)
                     *  LoggerHelper.Error("SetGridLayout unit is null: " + PrefabName);
                     ****/

                    DataList.Add(uniqueID, unit);

                    if (DataList.Count == NewCount)
                    {
                        if (loaded != null)
                        {
                            loaded();
                        }
                    }
                });
            }
        }
        else
        {
            for (int i = 0; i < curGridCount - NewCount; i++)
            {
                DataList.RemoveAt(curGridCount - 1 - i);
                AssetCacheMgr.ReleaseInstance(DataGUIDList.Pop());
            }
            if (loaded != null)
            {
                loaded();
            }
        }
    }
Beispiel #9
0
    public void AddLoginRewardGrid(LoginRewardGridData ld, int theID = -1)
    {
        if (IsFirstLoadRewardGrid)
        {
            AssetCacheMgr.GetUIInstance("LoginRewardGrid.prefab", (prefab, id, go) =>
            {
                GameObject obj     = (GameObject)go;
                LoginRewardGrid lg = obj.AddComponent <LoginRewardGrid>();
                obj.name           = "LoginRewardGrid" + m_listLoginRewardGridGameObject.Count;

                if (theID == -1)
                {
                    lg.Id = m_listLoginRewardGridGameObject.Count;
                }
                else
                {
                    lg.Id = theID;
                }

                obj.transform.parent        = m_goLoginRewardGridList.transform;
                obj.transform.localPosition = new Vector3((theID - 1) * 1150, 0, 0);
                obj.transform.localScale    = new Vector3(1, 1, 1);

                GameObject trans                 = new GameObject();
                trans.transform.parent           = m_goLoginRewardGridList.transform;
                trans.transform.localPosition    = new Vector3(GridIndex * 1150, 0, 0);
                trans.transform.localEulerAngles = Vector3.zero;
                trans.transform.localScale       = new Vector3(1, 1, 1);
                m_dragableCameraLoginRewardGridList.transformList.Add(trans.transform);

                m_listLoginRewardGrid.Add(lg);
                m_listLoginRewardGridGameObject.Add(obj);
                if (m_listLoginRewardGridGameObject.Count == LoginMessageGridCount)
                {
                    MogoGlobleUIManager.Instance.ShowWaitingTip(false);
                    ShowLoginRewardGrid();
                }

                obj.GetComponentsInChildren <MyDragCamera>(true)[0].RelatedCamera = m_camLoginRewardGridList;

                for (int i = 0; i < 6; ++i)
                {
                    obj.transform.FindChild("LoginRewardGridLeft/LoginRewardGridLeftItemList/LoginRewardGridLeftItem" + i).GetComponentsInChildren <MyDragCamera>(true)[0].RelatedCamera = m_camLoginRewardGridList;
                }

                GridIndex++;


                lg.LeftGetSign          = ld.LeftGetSignImgName;
                lg.RightGetSign         = ld.RightGetSignImgName;
                lg.NewServerRightText   = ld.NewServerRightText;
                lg.OldServerCostSign    = ld.OldServerCostSignImgName;
                lg.OldServerCostText    = ld.OldServerCostText;
                lg.OldServerItemCD      = ld.OldServerItemCD;
                lg.OldServerItemFG      = ld.OldServerItemFGImgName;
                lg.OldServerItemName    = ld.OldServerItemName;
                lg.OldServerItemNum     = ld.OldServerItemNum;
                lg.OldServerRightText   = ld.OldServerRightText;
                lg.ListLeftItem         = ld.ListLeftItem;
                lg.ListRightItemID      = ld.ListLeftItemID;
                lg.IsOldServer          = ld.IsOldServer;
                lg.OldServerItemFGImgID = ld.OldServerItemFGImgID;

                EventDispatcher.TriggerEvent <int>("LoadLoginRewardGirdDone", lg.Id);
            });
        }
        else
        {
            //Debug.LogError("Not First");
            SetGridInfo(theID, ld);
        }
    }
    public void ShowEquipInfoDetail
        (List<string> attrs, List<string> jewels, string level, string vocation)
    {
        float gap = 0;
        foreach (GameObject go in gos)
        {
            AssetCacheMgr.ReleaseInstance(go);
        }
        gos.Clear();

        Transform root = m_myTransform.FindChild(m_widgetToFullName["PackageEquipInfoDetailList"]);
        //加载+排版

        int i = 0;
        //属性
        for (i = 0; i < attrs.Count; i++)
        {
            var index = i;
            AssetCacheMgr.GetUIInstance("PackageEquipInfoAttr.prefab",
            (prefab, guid, gameObject) =>
            {
                //PackageEquipInfoDiamonHole0Text
                GameObject go = gameObject as GameObject;
                UILabel lable = go.transform.FindChild("PackageEquipInfoDiamonHole0Text").GetComponent<UILabel>();
                lable.text = attrs[index];

                Vector3 scale = go.transform.localScale;
                Vector3 position = go.transform.localPosition;
                Vector3 angle = go.transform.localEulerAngles;
                go.transform.parent = root;
                go.transform.localScale = scale;
                go.transform.localEulerAngles = angle;
                go.transform.localPosition = new Vector3(position.x, position.y - index * GAP, position.z);
                gos.Add(go);
            }
            );
        }
        gap -= i * GAP - 30;

        //宝石
        for (i = 0; i < jewels.Count; i++)
        {
            var index = i;
            AssetCacheMgr.GetUIInstance("PackageEquipInfoDiamon.prefab",
            (prefab, guid, gameObject) =>
            {
                //PackageEquipInfoDiamonHole0Text
                GameObject go = gameObject as GameObject;
                UILabel lable = go.transform.FindChild("PackageEquipInfoDiamonHole12Text").GetComponent<UILabel>();
                lable.text = jewels[index];

                Vector3 scale = go.transform.localScale;
                Vector3 position = go.transform.localPosition;
                Vector3 angle = go.transform.localEulerAngles;
                go.transform.parent = root;
                go.transform.localScale = scale;
                go.transform.localEulerAngles = angle;
                go.transform.localPosition = new Vector3(position.x, gap + position.y - index * GAP, position.z);
                gos.Add(go);
            }
            );
        }
        gap -= i * GAP + 30;

        //需求等级等
        Transform detail3 = m_myTransform.FindChild(m_widgetToFullName["PackageEquipInfoDetail3"]);
        detail3.localPosition = new Vector3(detail3.localPosition.x, gap, detail3.localPosition.z);
        m_equipDetailNeedJob.GetComponent<UILabel>().text = vocation;
        m_equipDetailNeedLevel.GetComponent<UILabel>().text = level;

        gap -= 200;
        gap = -gap;

        m_equipTipCamera.height = gap - 500;
        //show
        ShowPackageDetailInfo(true);
    }
    void Awake()
    {
        m_instance = this;
        m_myTransform = transform;
        FillFullNameData(m_myTransform);      
        Initialize();
        
        m_transPackageItemList = m_myTransform.FindChild(m_widgetToFullName["DecomposePackageItemList"]);
        m_dragCamera = m_myTransform.FindChild(m_widgetToFullName["DecomposePackageItemListCamera"]).GetComponentsInChildren<Camera>(true)[0];
        m_dragIconCamera = m_myTransform.FindChild(m_widgetToFullName["DecomposeDialogIconListCamera"]).GetComponentsInChildren<Camera>(true)[0];

        m_dragCamera.GetComponentsInChildren<UIViewport>(true)[0].sourceCamera = GameObject.Find("Camera").GetComponentsInChildren<Camera>(true)[0];
        m_dragIconCamera.GetComponentsInChildren<UIViewport>(true)[0].sourceCamera = GameObject.Find("Camera").GetComponentsInChildren<Camera>(true)[0];
        m_dragIconCamera.GetComponentsInChildren<UIViewport>(true)[0].topLeft = GameObject.Find("EquipmentUIIconListBGTopLeft").transform;
        m_dragIconCamera.GetComponentsInChildren<UIViewport>(true)[0].bottomRight = GameObject.Find("EquipmentUIIconListBGBottomRight").transform;

        m_transDecomposeDialogIconList = m_myTransform.FindChild(m_widgetToFullName["DecomposeDialogIconList"]);

        m_equipDetailName = m_myTransform.FindChild(m_widgetToFullName["PackageEquipInfoNameText"]).GetComponentsInChildren<UILabel>(true)[0];
        m_equipDetailNeedLevel = m_myTransform.FindChild(m_widgetToFullName["PackageEquipInfoDetailNeedLevelNum"]).GetComponentsInChildren<UILabel>(true)[0];
        //m_equipDetailGrowLevel = m_myTransform.FindChild(m_widgetToFullName["PackageEquipInfoDetailGrowLevelNum"]).GetComponentsInChildren<UILabel>(true)[0];
        m_equipDetailNeedJob = m_myTransform.FindChild(m_widgetToFullName["PackageEquipInfoDetailNeedJobType"]).GetComponentsInChildren<UILabel>(true)[0];
        m_equipDetailExtra = m_myTransform.FindChild(m_widgetToFullName["PackageEquipInfoDetailExtraText"]).GetComponentsInChildren<UILabel>(true)[0];
        m_equipDetailImageFG = m_myTransform.FindChild(m_widgetToFullName["PackageEquipInfoDetailImageFG"]).GetComponentsInChildren<UISlicedSprite>(true)[0];
        m_equipDetailImageBG = m_myTransform.FindChild(m_widgetToFullName["PackageEquipInfoDetailImageBG"]).GetComponentsInChildren<UISlicedSprite>(true)[0];
        m_equipDetailImageUsed = m_myTransform.FindChild(m_widgetToFullName["PackageEquipInfoDetailImageUsed"]).GetComponentsInChildren<UISlicedSprite>(true)[0];
        m_equipTipCamera = m_myTransform.FindChild(m_widgetToFullName["PackageEquipInfoDetailBG"]).GetComponentsInChildren<SimpleDragCamera>(true)[0];

        m_goGODecomposeChooseEquip = m_myTransform.FindChild(m_widgetToFullName["GODecomposeChooseEquip"]).gameObject;

        m_texGril = m_myTransform.FindChild(m_widgetToFullName["DecomposeLeftGirl"]).GetComponentsInChildren<UITexture>(true)[0];
        m_goGODecomposeJewlTip = m_myTransform.FindChild(m_widgetToFullName["GODecomposeJewlTip"]).gameObject;

        // ChineseData
        m_myTransform.FindChild(m_widgetToFullName["DecomposeChooseEquipTitle"]).GetComponentsInChildren<UILabel>(true)[0].text
            = LanguageData.GetContent(46000);
        m_myTransform.FindChild(m_widgetToFullName["DecomposeChooseEquipAllText"]).GetComponentsInChildren<UILabel>(true)[0].text
            = LanguageData.GetContent(46002);
        m_myTransform.FindChild(m_widgetToFullName["DecomposeChooseEquipWasteText"]).GetComponentsInChildren<UILabel>(true)[0].text
            = LanguageData.GetContent(46001);
        m_myTransform.FindChild(m_widgetToFullName["DecomposeJewlTipText"]).GetComponentsInChildren<UILabel>(true)[0].text
            = LanguageData.GetContent(1087);

        for (int i = 0; i < PACKAGEITEMNUM; ++i)
        {
            int index = i;
            AssetCacheMgr.GetUIInstance("DecomposeDialogPackageGrid.prefab", (prefab, guid, go) =>
            {
                GameObject obj = (GameObject)go;
                obj.transform.parent = m_transPackageItemList;
                obj.transform.localPosition = new Vector3(PACKAGEITEMSPACE * ((index % 5) + index / 10 * 5), -PACKAGEITEMSPACE * ((index / 5) % 2), 0);
                obj.transform.localScale = new Vector3(0.0008f, 0.0008f, 1);
                obj.name = "DecomposeGrid" + index.ToString();
                obj.GetComponentsInChildren<MyDragCamera>(true)[0].RelatedCamera = m_dragCamera;

                obj.AddComponent<DecomposeUIEquipmentGrid>().id = index;

                m_listPackageGrid.Add(obj);

                obj = obj.transform.FindChild("DecomposeDialogPackageGridCheckBG").gameObject;
                obj.name = "DecomposeDialogPackageGridCheckBG" + index.ToString();
                obj.AddComponent<DecomposeUIEquipmentCheckGrid>().id = index;
                m_listPackageCheckGridBG.Add(obj);

                obj = obj.transform.parent.FindChild("DecomposeDialogPackageGridCheckFG").gameObject;
                obj.SetActive(false);
                m_listPackageCheckGridFG.Add(obj);

                obj = obj.transform.parent.FindChild("DecomposeDialogPackageGridLock").gameObject;
                m_listPackageLock.Add(obj);

                UISlicedSprite ss = obj.transform.parent.FindChild("DecomposeDialogPackageGridFG").GetComponentsInChildren<UISlicedSprite>(true)[0];
                UISlicedSprite ssbg = obj.transform.parent.FindChild("DecomposeDialogPackageGridBG").GetComponentsInChildren<UISlicedSprite>(true)[0];

                m_listPackageGridFG.Add(ss);
                m_listPackageGridBG.Add(ssbg);

                if (m_listPackageGrid.Count == PACKAGEITEMNUM)
                {
                    EventDispatcher.TriggerEvent(DecomposeManager.ON_DECOMPOSE_SHOW);

                    if (MogoUIManager.Instance.DecomposeUILoaded != null)
                    {
                        MogoUIManager.Instance.DecomposeUILoaded();
                    }

                    MogoGlobleUIManager.Instance.ShowWaitingTip(false);
                }
            });
        }

        for (int i = 0; i < ICONGRIDNUM; ++i)
        {
            int index = i;
            AssetCacheMgr.GetUIInstance("DecomposeDialogIconGrid.prefab", (prefab, guid, go) =>
            {
                GameObject obj = (GameObject)go;
                obj.transform.parent = m_transDecomposeDialogIconList;
                obj.transform.localPosition = new Vector3(0, -ICONGRIDSPACE * index, 0);
                obj.transform.localScale = new Vector3(0.0008f, 0.0008f, 1);
                obj.GetComponentsInChildren<MyDragCamera>(true)[0].RelatedCamera = m_dragIconCamera;
                obj.name = "EquipmentGrid" + index.ToString();
                // var s = m_transDecomposeDialogIconList.GetComponentsInChildren<MogoSingleButtonList>(true)[0] as MogoSingleButtonList;
                //s.SingleButtonList.Add(obj.GetComponentsInChildren<MogoSingleButton>(true)[0]);

                obj.GetComponentsInChildren<UILabel>(true)[0].text = BodyName.names[index];
                obj.AddComponent<DecomposeUIEquipmentGrid>().id = index;

                m_listEquipmentGrid.Add(obj);
            });
        }
    }
Beispiel #12
0
    public IEnumerator ShowNotice(List <Notice> list)
    {
        while (isShow || m_contentLabel == null)
        {
            Mogo.Util.LoggerHelper.Debug("m_contentLabel is Loading!");
            yield return(null);
        }
        isShow = true;
        Reset();

        int titleGap = 30 + 10;//字体高度+gap

        int count1 = 0;
        int count2 = 0;
        int gap    = 0;

        for (int i = 0; i < list.Count; i++)
        {
            var index = i;

            //遍历titleList,把挂到MogoNoticeTitles
            AssetCacheMgr.GetUIInstance(TITLE_PREFAB, (str, id, obj) =>
            {
                GameObject go = obj as GameObject;
                go.AddComponent <NoticeTitle>().index = count1;
                UILabel label = go.transform.FindChild("MogoNoticeTitleText").GetComponent <UILabel>();
                label.text    = list[count1].title;
                //Mogo.Util.LoggerHelper.Debug("list[index].title:" + list[count1].title);
                Utils.MountToSomeObjWithoutPosChange(go.transform, m_mogoNoticeTitles.transform);

                go.transform.localPosition = new Vector3(go.transform.localPosition.x, go.transform.localPosition.y - count1 * titleGap, go.transform.localPosition.z);

                m_objList.Add(go);
                count1++;
            });

            var tempGap = gap;
            m_contentPositionList.Add(tempGap);
            //遍历contentList,挂到MogoNoticeContents
            AssetCacheMgr.GetUIInstance(CONTENT_PREFAB, (str, id, obj) =>
            {
                GameObject go      = obj as GameObject;
                UILabel labelText  = go.transform.FindChild("MogoNoticeContentText").GetComponent <UILabel>();
                UILabel labelTitle = go.transform.FindChild("MogoNoticeContentTitle").GetComponent <UILabel>();
                labelTitle.text    = list[count2].title;
                labelText.text     = list[count2].text;

                count2++;
                Utils.MountToSomeObjWithoutPosChange(go.transform, m_mogoNoticeContents.transform);

                go.transform.localPosition = new Vector3(go.transform.localPosition.x, go.transform.localPosition.y + tempGap, go.transform.localPosition.z);

                m_objList.Add(go);
            });


            //计算高度
            if (m_contentLabel == null)
            {
                LoggerHelper.Error("m_contentLabel == null");
            }
            if (list.Count <= index)
            {
                LoggerHelper.Error("list[index] == null");
            }
            Vector2 temp       = m_contentLabel.font.CalculatePrintedSize(list[index].text, true, UIFont.SymbolStyle.None);
            float   length     = temp.x * contentFontSize;
            float   contentGap = (length / contentLineWidth) * temp.y * contentFontSize;
            gap -= ((int)contentGap) + 25 + titleGap;
        }

        m_titleDragCamera.height    = list.Count * titleGap - m_titleHeight;
        m_contentsDragCamera.height = -gap - m_contentHeight;
        gameObject.SetActive(true);
    }
Beispiel #13
0
    /// <summary>
    /// 动态创建格子
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="NewCount">需要创建的格子</param>
    /// <param name="parentTrans">格子的父节点</param>
    /// <param name="loaded">创建完成后的回调</param>
    public void SetGridLayout <T>(int NewCount, Transform parentTrans, Action loaded) where T : Component
    {
        // 计算显示宽度高度
        if (width == 0)
        {
            width = ColSize * UnitWidth + (ColSize - 1) * XMargin;
        }
        if (height == 0)
        {
            height = RowSize * UnitHeight + (RowSize - 1) * YMargin;
        }
        int PageSize = ColSize * RowSize;

        MaxPageIndex = (byte)(Math.Ceiling((double)NewCount / PageSize) - 1);

        // 计算最末尾点的位置
        CalLastPoint(NewCount);

        int curMemoryCount = MemoryDataList.Count; // 当前已经创建的格子数量

        // [1]当前缓存的格子数量小于需要创建的格子数量
        if (curMemoryCount < NewCount)
        {
            // 继续创建还需要创建的格子数量
            for (int index = curMemoryCount; index < NewCount; index++)
            {
                var uniqueID   = index;
                var curPage    = index / PageSize;
                var curIndex   = index % PageSize;
                var curRow     = curIndex / ColSize;
                var curCol     = curIndex % ColSize;
                var startPoint = new Vector2();

                startPoint = getStartPoint(curPage);
                zeroPoint  = Vector2.zero;

                AssetCacheMgr.GetUIInstance(PrefabName + ".prefab", (prefab, id, go) =>
                {
                    GameObject obj              = (GameObject)go;
                    obj.transform.parent        = parentTrans;
                    obj.transform.localPosition = new Vector3(startPoint.x
                                                              + (curCol * (XMargin + UnitWidth) + UnitWidth / 2) * IsOpposite
                                                              ,
                                                              startPoint.y
                                                              - (curRow * (YMargin + UnitHeight) + UnitHeight / 2) * IsOpposite
                                                              , 0.0f);
                    obj.transform.localScale = new Vector3(1, 1, 1);
                    if (!IsOneButton)
                    {
                        var btnList = obj.transform.GetComponentsInChildren <MogoButton>(true);
                        foreach (var single in btnList)
                        {
                            single.pressHandler += PressHandler;
                            single.dragHandler  += DragHandler;
                        }
                    }

                    UnityEngine.Component unit = obj.AddComponent <T>();
                    if (MemoryDataList.ContainsKey(uniqueID))
                    {
                        if (MemoryDataList[uniqueID] != null)
                        {
                            AssetCacheMgr.SynReleaseInstance(MemoryDataList[uniqueID].gameObject);
                        }
                    }
                    MemoryDataList[uniqueID] = unit;

                    if (MemoryDataList.Count >= NewCount)
                    {
                        ShowGrid(NewCount);
                        if (loaded != null)
                        {
                            loaded();
                        }
                    }
                });
            }
        }
        // [2]当前缓存的格子数量大于或等于需要创建的格子数量
        else
        {
            ShowGrid(NewCount);
            if (loaded != null)
            {
                loaded();
            }
        }
    }
Beispiel #14
0
    void Awake()
    {
        m_instance    = this;
        m_myTransform = transform;
        FillFullNameData(m_myTransform);

        Initialize();

        m_transPackageItemList     = m_myTransform.Find(m_widgetToFullName["InsetDialogPackageItemList"]);
        m_transInsetDialogIconList = m_myTransform.Find(m_widgetToFullName["InsetDialogIconList"]);
        m_transInsetHoleList       = m_myTransform.Find(m_widgetToFullName["InsetDialogBody"]);

        m_dragCamera = FindTransform("InsetDialogPackageItemListCamera").GetComponentsInChildren <Camera>(true)[0];
        m_dragCamera.GetComponentsInChildren <UIViewport>(true)[0].sourceCamera = GameObject.Find("Camera").GetComponentsInChildren <Camera>(true)[0];

        m_dragIconCamera = FindTransform("InsetDialogIconListCamera").GetComponentsInChildren <Camera>(true)[0];
        m_dragIconCamera.GetComponentsInChildren <UIViewport>(true)[0].sourceCamera = GameObject.Find("Camera").GetComponentsInChildren <Camera>(true)[0];
        m_dragIconCamera.GetComponentsInChildren <UIViewport>(true)[0].topLeft      = GameObject.Find("EquipmentUIIconListBGTopLeft").transform;
        m_dragIconCamera.GetComponentsInChildren <UIViewport>(true)[0].bottomRight  = GameObject.Find("EquipmentUIIconListBGBottomRight").transform;

        m_dragableIconCamera            = m_dragIconCamera.GetComponentsInChildren <MyDragableCamera>(true)[0];
        m_dragableIconCamera.LeftArrow  = FindTransform("InsetDialogIconListArrowU").gameObject;
        m_dragableIconCamera.RightArrow = FindTransform("InsetDialogIconListArrowD").gameObject;

        m_ssInsetEquipmentIcon = m_myTransform.Find(m_widgetToFullName["InsetDialogEquipFG"]).GetComponentsInChildren <UISlicedSprite>(true)[0];

        m_ssInsetEquipmentIconBG  = m_myTransform.Find(m_widgetToFullName["InsetDialogEquipBG"]).GetComponentsInChildren <UISlicedSprite>(true)[0];
        m_goPackageArea           = m_myTransform.Find(m_widgetToFullName["InsetDialogPackageListPos"]).gameObject;
        m_goInsetDialogDiamondTip = m_myTransform.Find(m_widgetToFullName["DiamondInfoTip"]).gameObject;

        m_lblDiamondTipDesc  = m_myTransform.Find(m_widgetToFullName["DiamondInfoDetailEffectNum"]).GetComponentsInChildren <UILabel>(true)[0];
        m_lblDiamondTipLevel = m_myTransform.Find(m_widgetToFullName["DiamondInfoDetailLevelNum"]).GetComponentsInChildren <UILabel>(true)[0];
        m_lblDiamondTipName  = m_myTransform.Find(m_widgetToFullName["DiamondInfoNameText"]).GetComponentsInChildren <UILabel>(true)[0];
        m_lblDiamondTipType  = m_myTransform.Find(m_widgetToFullName["DiamondInfoDetailTypeNum"]).GetComponentsInChildren <UILabel>(true)[0];
        m_ssDiamondTipIcon   = m_myTransform.Find(m_widgetToFullName["DiamondInfoDetailImageFG"]).GetComponentsInChildren <UISlicedSprite>(true)[0];
        m_ssDiamondTipIconBG = m_myTransform.Find(m_widgetToFullName["DiamondInfoDetailImageBG"]).GetComponentsInChildren <UISlicedSprite>(true)[0];

        m_jewelHoleObj = m_myTransform.Find(m_widgetToFullName["InsetDialogHole"]).gameObject;
        m_jewelHole1   = m_myTransform.Find(m_widgetToFullName["InsetDialogHole0"]).gameObject;
        m_jewelHole2   = m_myTransform.Find(m_widgetToFullName["InsetDialogHole1"]).gameObject;
        m_jewelHole3   = m_myTransform.Find(m_widgetToFullName["InsetDialogHole2"]).gameObject;
        m_jewelHole4   = m_myTransform.Find(m_widgetToFullName["InsetDialogHole3"]).gameObject;

        m_myTransform.Find(m_widgetToFullName["InsetDialog1BGMask"]).gameObject.AddComponent <InsetBGMask>();
        m_jewelHoleList = new List <GameObject>();
        m_jewelHoleList.Add(m_jewelHole1);
        m_jewelHoleList.Add(m_jewelHole2);
        m_jewelHoleList.Add(m_jewelHole3);
        m_jewelHoleList.Add(m_jewelHole4);
        m_jewleHoleOriginalPos = m_myTransform.Find(m_widgetToFullName["InsetDialogHolePos"]).localPosition;

        m_dialog1            = m_myTransform.Find(m_widgetToFullName["InsetDialog1"]).gameObject;
        m_dialog2            = m_myTransform.Find(m_widgetToFullName["InsetDialog2"]).gameObject;
        m_dialog2InfoDetail  = m_myTransform.Find(m_widgetToFullName["InsetDialog2Info"]).gameObject;
        m_dialog2Title       = m_myTransform.Find(m_widgetToFullName["InsetDialog2TopTitle"]).GetComponentsInChildren <UILabel>(true)[0];;
        m_dialog2EquipIconFg = m_myTransform.Find(m_widgetToFullName["InsetDialog2IconFg"]).GetComponentsInChildren <UISprite>(true)[0];
        m_dialog2EquipIconBg = m_myTransform.Find(m_widgetToFullName["InsetDialog2IconBg"]).GetComponentsInChildren <UISprite>(true)[0];
        m_dialog2EquipName   = m_myTransform.Find(m_widgetToFullName["InsetDialog2EquipName"]).GetComponentsInChildren <UILabel>(true)[0];
        m_dialog2LevelNeed   = m_myTransform.Find(m_widgetToFullName["InsetDialog2NeedLevel"]).GetComponentsInChildren <UILabel>(true)[0];

        m_lblJewelListDesc = m_myTransform.Find(m_widgetToFullName["InsetDialogPackageText"]).GetComponentsInChildren <UILabel>(true)[0];

        m_texInsetSucessSign   = m_myTransform.Find(m_widgetToFullName["InsetUISucessSign"]).GetComponentsInChildren <UITexture>(true)[0];
        m_texComposeSucessSign = m_myTransform.Find(m_widgetToFullName["InsetUIComposeSucessSign"]).GetComponentsInChildren <UITexture>(true)[0];

        m_myTransform.Find(m_widgetToFullName["InsetDialog1Buy"]).gameObject.AddComponent <MogoUIListener>().MogoOnClick =
            () =>
        {
            EventDispatcher.TriggerEvent(InsetManager.ON_BUY);
        };

        for (int i = 0; i < 4; ++i)
        {
            m_arrInsetHoleIcon[i]       = m_myTransform.Find(m_widgetToFullName["InsetDialogHole" + i + "FG"]).GetComponentsInChildren <UISlicedSprite>(true)[0];
            m_arrInsetHoleUnloadSign[i] = m_myTransform.Find(m_widgetToFullName["InsetDialogHole" + i + "Unload"]).GetComponentsInChildren <UISlicedSprite>(true)[0];
            m_arrInsetHoleUpSign[i]     = m_myTransform.Find(m_widgetToFullName["InsetDialogHole" + i + "Update"]).GetComponentsInChildren <UISlicedSprite>(true)[0];
            m_arrInsetHoleTooltip[i]    = m_myTransform.Find(m_widgetToFullName["InsetDialogHole" + i + "ToolTip"]).gameObject;
            m_arrInsetHoleBGDown[i]     = m_myTransform.Find(m_widgetToFullName["InsetDialogHole" + i + "BG"]).GetComponentsInChildren <UISlicedSprite>(true)[0];
            m_arrInsetHoleBGUp[i]       = m_myTransform.Find(m_widgetToFullName["InsetDialogHole" + i + "BGUp"]).GetComponentsInChildren <UISlicedSprite>(true)[0];
            m_arrInsetHoleTypeName[i]   = m_myTransform.Find(m_widgetToFullName["InsetDialogHole" + i + "TypeName"]).GetComponentsInChildren <UILabel>(true)[0];
        }

        for (int i = 0; i < 6; ++i)
        {
            m_gotransformList.Add(m_myTransform.Find(m_widgetToFullName["transformList" + i]).gameObject);
        }

        for (int i = 0; i < 6; i++)
        {
            if (i > 0)
            {
                m_gotransformList[i].transform.localPosition = new Vector3(
                    m_gotransformList[0].transform.localPosition.x + PACKAGEITEMNUMONEPAGE * PACKAGEITEMSPACE * i,
                    m_gotransformList[i].transform.localPosition.y,
                    m_gotransformList[i].transform.localPosition.z);
            }
        }

        bool m_bIsAllLoaded = false;

        for (int i = 0; i < ICONGRIDNUM; ++i)
        {
            int index = i;

            AssetCacheMgr.GetUIInstance("StrenthenDialogIconGrid.prefab", (prefab, guid, go) =>
            {
                GameObject obj              = (GameObject)go;
                obj.transform.parent        = m_transInsetDialogIconList;
                obj.transform.localPosition = new Vector3(0, ICONGRIDSPACE * index, 0);
                obj.transform.localScale    = new Vector3(0.0008f, 0.0008f, 1);
                obj.GetComponentsInChildren <MyDragCamera>(true)[0].RelatedCamera     = m_dragIconCamera;
                obj.GetComponentsInChildren <MyDragCamera>(true)[0].m_goDraggableArea = m_goPackageArea;
                obj.name = "InsetIconListIcon" + index.ToString();
                var s    = m_transInsetDialogIconList.GetComponentsInChildren <MogoSingleButtonList>(true)[0] as MogoSingleButtonList;
                s.SingleButtonList.Add(obj.GetComponentsInChildren <MogoSingleButton>(true)[0]);
                obj.AddComponent <InsetUIEquipmentGrid>().id = index;

                m_listEquipmentGrid.Add(obj);

                if (m_listEquipmentGrid.Count == ICONGRIDNUM)
                {
                    // 滑动形式需要处理(翻页不需要设置)
                    if (!m_dragableIconCamera.IsMovePage)
                    {
                        m_dragableIconCamera.FPageHeight = ICONGRIDSPACE * ICON_GRID_ONE_PAGE;
                        m_dragableIconCamera.MAXY        = ICON_OFFSET_Y;
                        if (m_listEquipmentGrid.Count > ICON_GRID_ONE_PAGE)
                        {
                            m_dragableIconCamera.MINY = (m_listEquipmentGrid.Count - ICON_GRID_ONE_PAGE) * ICONGRIDSPACE + ICON_OFFSET_Y;
                        }
                        else
                        {
                            m_dragableIconCamera.MINY = m_dragableIconCamera.MAXY;
                        }
                    }
                }

                if (!m_bIsAllLoaded && m_listPackageGrid.Count == PACKAGEITEMNUM && m_listEquipmentGrid.Count == ICONGRIDNUM)
                {
                    EventDispatcher.TriggerEvent(InsetManager.ON_INSET_SHOW);

                    if (MogoUIManager.Instance.InsetUILoaded != null)
                    {
                        MogoUIManager.Instance.InsetUILoaded();
                        MogoUIManager.Instance.InsetUILoaded = null;
                    }

                    m_bIsAllLoaded = true;
                }

                if (index == 0)
                {
                    InsetTabDown(index);
                }
                else
                {
                    InsetTabUp(index);
                }
            });
        }

        for (int i = 0; i < PACKAGEITEMNUM; ++i)
        {
            int index = i;
            AssetCacheMgr.GetUIInstance("InsetDialogPackageGrid.prefab", (prefab, guid, go) =>
            {
                GameObject obj              = (GameObject)go;
                obj.name                    = "InsetDialogPackageGrid" + index;
                obj.transform.parent        = m_transPackageItemList;
                obj.transform.localPosition = new Vector3(PACKAGEITEMSPACE * index - 0.012f, 0, 0);
                obj.transform.localScale    = new Vector3(0.0008f, 0.0008f, 1);
                m_listItemFG.Add(obj.transform.GetComponentsInChildren <UISlicedSprite>(true)[1]);
                m_listItemNum.Add(obj.transform.GetComponentsInChildren <UILabel>(true)[0]);
                m_listItemBG.Add(obj.transform.GetComponentsInChildren <UISlicedSprite>(true)[0]);
                obj.GetComponentsInChildren <MyDragCamera>(true)[0].RelatedCamera = m_dragCamera;

                obj.AddComponent <InsetUIPackageGrid>().ID = index;

                m_listPackageGrid.Add(obj);

                if (!m_bIsAllLoaded && m_listPackageGrid.Count == PACKAGEITEMNUM && m_listEquipmentGrid.Count == ICONGRIDNUM)
                {
                    EventDispatcher.TriggerEvent(InsetManager.ON_INSET_SHOW);

                    if (MogoUIManager.Instance.InsetUILoaded != null)
                    {
                        //Debug.LogError("InsetUILoaded != null");
                        MogoUIManager.Instance.InsetUILoaded();
                        MogoUIManager.Instance.InsetUILoaded = null;
                    }
                    //else
                    //{
                    //    Debug.LogError("InsetUILoaded == null");
                    //}

                    m_bIsAllLoaded = true;
                    MogoGlobleUIManager.Instance.ShowWaitingTip(false);
                }
            });
        }
    }
Beispiel #15
0
    public void AddChatUIDialogText(string text)
    {
        AssetCacheMgr.GetUIInstance("ChatUIDialogLabel.prefab", (prefab, id, go) =>
        {
            GameObject obj = (GameObject)go;
            obj.SetActive(true);
            obj.transform.parent        = m_myTransform.FindChild(m_widgetToFullName["ChatUIDialogLabelList"]);
            obj.transform.localPosition = Vector3.zero;
            obj.transform.localScale    = new Vector3(1, 1, 1);

            string strTmp = text;

            for (int i = 0; i < text.Length; ++i)
            {
                if (text[i] == '<' && text.Substring(i, 6) == "<info=")
                {
                    int tmp = i + 7;

                    while (tmp < text.Length)
                    {
                        if (text[tmp] == '>')
                        {
                            float length = m_inputText.label.font.CalculatePrintedSize(text.Substring(0, i), true, UIFont.SymbolStyle.None).x;

                            string originString = text.Substring(i, tmp - i + 1);
                            text = text.ReplaceFirst(originString, TranslateInputText(originString));
                            AddChatUIEquipmentLabel(TranslateInputText(originString),
                                                    obj.transform.FindChild("ChatUIDialogLabelSLList"), (g) =>
                            {
                                float width = m_inputText.label.font.size * length;
                                int row     = (int)((width + m_fOffect) / 750);

                                float labelWidth = m_inputText.label.font.CalculatePrintedSize(TranslateInputText(originString),
                                                                                               true, UIFont.SymbolStyle.None).x *m_inputText.label.font.size;

                                if ((width + m_fOffect) + labelWidth > 750 * (row + 1))
                                {
                                    m_fOffect += (750 * (row + 1) - (width + m_fOffect));
                                    //m_fOffect += m_inputText.label.font.CalculatePrintedSize("   ", true, UIFont.SymbolStyle.None).x *
                                    //    m_inputText.label.font.size;
                                    text = text.Insert(i, "   ");
                                    m_iOffsetNum++;
                                    width += m_fOffect;
                                }
                                else if (width > 750 && m_iOffsetNum > 0)
                                {
                                    width = width + m_fOffect - (m_inputText.label.font.CalculatePrintedSize("   ", true, UIFont.SymbolStyle.None).x *
                                                                 m_inputText.label.font.size);
                                }
                                else
                                {
                                    width += m_fOffect;
                                }

                                //g.transform.localPosition = new Vector3(obj.transform.localPosition.x +
                                // width % 750,
                                //     obj.transform.localPosition.y - (int)(width / 750) *
                                // 35, obj.transform.localPosition.z);

                                //g.transform.localPosition = new Vector3(obj.transform.localPosition.x +
                                //m_inputText.label.font.size * length % 750,
                                //    obj.transform.localPosition.y - (int)(m_inputText.label.font.size * length / 750) *
                                //m_inputText.label.font.size, obj.transform.localPosition.z);

                                //g.transform.GetComponentsInChildren<ChatUIEquipmentGrid>(true)[0].LogicText = originString;

                                g.transform.localPosition = new Vector3(obj.transform.localPosition.x +
                                                                        width % 750,
                                                                        obj.transform.localPosition.y - (int)(width / 750) * m_inputText.label.font.size, obj.transform.localPosition.z);

                                g.transform.GetComponentsInChildren <ChatUIEquipmentGrid>(true)[0].LogicText = originString;
                            });
                            break;
                        }

                        ++tmp;
                    }
                }
                else if (text[i] == '<' && text.Substring(i, 6) == "<face=")
                {
                    int tmp = i + 7;

                    while (tmp < text.Length)
                    {
                        if (text[tmp] == '>')
                        {
                            float length = m_inputText.label.font.CalculatePrintedSize(text.Substring(0, i), true, UIFont.SymbolStyle.None).x;

                            string originString = text.Substring(i, tmp - i + 1);
                            text = text.ReplaceFirst(originString, /*TranslateInputText(originString)*/ "¡¡");
                            AddChatUIFaceLabel(TranslateInputText(originString),
                                               obj.transform.FindChild("ChatUIDialogLabelSLList"), (g) =>
                            {
                                float width = m_inputText.label.font.size * length;
                                int row     = (int)((width + m_fOffect) / 750);

                                if ((width + m_fOffect) + 22 > 750 * (row + 1))
                                {
                                    m_fOffect += (750 * (row + 1) - (width + m_fOffect));
                                }


                                if (m_iOffsetNum > 0)
                                {
                                    //width = width + m_fOffect - (m_inputText.label.font.CalculatePrintedSize("¡¡", true, UIFont.SymbolStyle.None).x *
                                    //    m_inputText.label.font.size);
                                    width = width + m_fOffect - 22;
                                }
                                else
                                {
                                    width += m_fOffect;
                                }

                                g.transform.localPosition = new Vector3(obj.transform.localPosition.x +
                                                                        width % 750,
                                                                        obj.transform.localPosition.y - (int)(width / 750) *
                                                                        22, obj.transform.localPosition.z);
                            });
                            break;
                        }

                        ++tmp;
                    }
                }
            }

            obj.transform.FindChild("ChatUIDialogLabelText").GetComponentsInChildren <UILabel>(true)[0].text            = text;
            obj.transform.FindChild("ChatUIDialogLabelText").GetComponentsInChildren <UILabel>(true)[0].supportEncoding = true;

            obj.transform.localPosition = new Vector3(obj.transform.parent.FindChild("ChatUIDialogBeginPos").localPosition.x,
                                                      obj.transform.parent.FindChild("ChatUIDialogBeginPos").localPosition.y - 22 * m_iLineNum,
                                                      obj.transform.parent.FindChild("ChatUIDialogBeginPos").localPosition.z);

            obj.transform.GetComponentsInChildren <BoxCollider>(true)[0].size =
                new Vector3(obj.transform.GetComponentsInChildren <BoxCollider>(true)[0].size.x,
                            obj.transform.GetComponentsInChildren <BoxCollider>(true)[0].size.y *
                            ((int)(m_inputText.label.font.CalculatePrintedSize(text, true, UIFont.SymbolStyle.None).x * 22 / 750) + 1),
                            obj.transform.GetComponentsInChildren <BoxCollider>(true)[0].size.z);

            obj.transform.GetComponentsInChildren <BoxCollider>(true)[0].center =
                new Vector3(obj.transform.GetComponentsInChildren <BoxCollider>(true)[0].center.x,
                            obj.transform.GetComponentsInChildren <BoxCollider>(true)[0].center.y -
                            ((int)(m_inputText.label.font.CalculatePrintedSize(text, true, UIFont.SymbolStyle.None).x * 22 / 750)) * 0.5f * 22,
                            obj.transform.GetComponentsInChildren <BoxCollider>(true)[0].center.z);


            obj.GetComponentsInChildren <MyDragPanel>(true)[0].m_myDPanel = obj.transform.parent.GetComponentsInChildren <MyDragablePanel>(true)[0];
            m_iLineNum += ((int)(m_inputText.label.font.CalculatePrintedSize(text, true, UIFont.SymbolStyle.None).x * 22 / 750) + 1);

            obj.transform.parent.GetComponentsInChildren <MyDragablePanel>(true)[0].PanelHeight = m_iLineNum * 22;


            //if (text.Length > 7 && (text[0] == '[' && text[7] == ']'))
            //{
            //    obj.transform.GetComponentsInChildren<BoxCollider>(true)[0].size =
            //   new Vector3((text.Length - 8 - 2) * 22 + 14, 22, 0);

            //    obj.transform.GetComponentsInChildren<BoxCollider>(true)[0].center =
            //      new Vector3(obj.transform.GetComponentsInChildren<BoxCollider>(true)[0].size.x * 0.5f, 0f, 0f);

            //    m_lblInputText.text += text.Substring(8);


            //}
            //else
            //{
            //    obj.transform.GetComponentsInChildren<BoxCollider>(true)[0].size =
            //  new Vector3((text.Length - 2) * 22 + 14, 22, 0);

            //    m_lblInputText.text += text;
            //}

            m_listChatUIDialogText.Add(obj);
        });
    }
Beispiel #16
0
    void Awake()
    {
        m_instance    = this;
        m_myTransform = transform;
        FillFullNameData(m_myTransform);

        Camera cam = GameObject.Find("MogoMainUI").transform.Find("Camera").GetComponentsInChildren <Camera>(true)[0];

        m_myTransform.Find(m_widgetToFullName["ChooseCharacterUIBottomLeft"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera        = cam;
        m_myTransform.Find(m_widgetToFullName["ChooseCharacterUIBottomRight"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera       = cam;
        m_myTransform.Find(m_widgetToFullName["ChooseCharacterUIRight"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera             = cam;
        m_myTransform.Find(m_widgetToFullName["ChooseCharacterUITop"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera               = cam;
        m_myTransform.Find(m_widgetToFullName["ChooseCharacterUITopRight"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera          = cam;
        m_myTransform.Find(m_widgetToFullName["CreateCharacterDetailUIBottomLeft"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera  = cam;
        m_myTransform.Find(m_widgetToFullName["CreateCharacterDetailUITopLeft"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera     = cam;
        m_myTransform.Find(m_widgetToFullName["CreateCharacterDetailUIBottomRight"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera = cam;
        m_myTransform.Find(m_widgetToFullName["CreateCharacterDetailUILeft"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera        = cam;
        m_myTransform.Find(m_widgetToFullName["CreateCharacterDetailUIRight"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera       = cam;
        m_myTransform.Find(m_widgetToFullName["CreateCharacterDetailUITop"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera         = cam;
        m_myTransform.Find(m_widgetToFullName["CreateCharacterUIBottomRight"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera       = cam;
        m_myTransform.Find(m_widgetToFullName["CreateCharacterUITop"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera               = cam;
        m_myTransform.Find(m_widgetToFullName["ChooseServerUITop"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera           = cam;
        m_myTransform.Find(m_widgetToFullName["ChooseServerUIBottomLeft"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera    = cam;
        m_myTransform.Find(m_widgetToFullName["ChooseServerUITopLeft"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera       = cam;
        m_myTransform.Find(m_widgetToFullName["CreateCharacterUIBottomLeft"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera = cam;
        m_myTransform.Find(m_widgetToFullName["CreateCharacterUITopLeft"]).GetComponentsInChildren <UIAnchor>(true)[0].uiCamera    = cam;

        m_camChooseServerGridList = m_myTransform.Find(m_widgetToFullName["ChooseServerUIServerGridListCamera"]).GetComponentsInChildren <Camera>(true)[0];
        m_camChooseServerGridList.GetComponentsInChildren <UIViewport>(true)[0].sourceCamera = cam;

        m_dragableCameraChooseServerGridList            = m_camChooseServerGridList.GetComponentsInChildren <MyDragableCamera>(true)[0];
        m_dragableCameraChooseServerGridList.LeftArrow  = FindTransform("ChooseServerUIArrowL").gameObject;
        m_dragableCameraChooseServerGridList.RightArrow = FindTransform("ChooseServerUIArrowR").gameObject;

        m_lblCreateCharacterText            = m_myTransform.Find(m_widgetToFullName["CreateCharacterUITitleText"]).GetComponentsInChildren <UILabel>(true)[0];
        m_lblJobName                        = m_myTransform.Find(m_widgetToFullName["CreateCharacterDetailUIJobInfoName"]).GetComponentsInChildren <UILabel>(true)[0];
        m_lblJobInfo                        = m_myTransform.Find(m_widgetToFullName["CreateCharacterDetailUIJobInfoDetail"]).GetComponentsInChildren <UILabel>(true)[0];
        m_lblCharacterNameInput             = m_myTransform.Find(m_widgetToFullName["CreateCharacterDetailUIInput"]).GetComponentsInChildren <UIInput>(true)[0];
        m_lblRecommendServerName            = m_myTransform.Find(m_widgetToFullName["RecommendServerUIServerName"]).GetComponentsInChildren <UILabel>(true)[0];
        m_goCreateCharacterDetailUIEnterBtn = m_myTransform.Find(m_widgetToFullName["CreateCharacterDetailUIEnterBtn"]).gameObject;
        m_lblEnter = m_myTransform.Find(m_widgetToFullName["CreateCharacterDetailUIEnterBtnText"]).GetComponentsInChildren <UILabel>(true)[0];
        m_spCreateCharacterDetailUIEnterBtnBGUp = m_myTransform.Find(m_widgetToFullName["CreateCharacterDetailUIEnterBtnBGUp"]).GetComponentsInChildren <UISprite>(true)[0];

        m_goCharacterNameInput = m_myTransform.Find(m_widgetToFullName["CreateCharacterDetailUIInput"]).gameObject;
        m_goRandomBtn          = m_myTransform.Find(m_widgetToFullName["CreateCharacterDetailUIRandomBtn"]).gameObject;

        m_goChooseCharcterGridList   = m_myTransform.Find(m_widgetToFullName["ChooseCharacterUIList"]).gameObject;
        m_goJobAttrList              = m_myTransform.Find(m_widgetToFullName["CreateCharacterDetailUIJobAttrList"]).gameObject;
        m_goChooseServerGridList     = m_myTransform.Find(m_widgetToFullName["ChooseServerUIServerGridList"]).gameObject;
        m_goCreateCharacterUIBackBtn = m_myTransform.Find(m_widgetToFullName["CreateCharacterUIBackBtn"]).gameObject;

        m_goChooseCharacterUI        = m_myTransform.Find("ChooseCharacterUI").gameObject;
        m_goChooseServerUI           = m_myTransform.Find("ChooseServerUI").gameObject;
        m_goCreateCharacterDetailUI  = m_myTransform.Find("CreateCharacterDetailUI").gameObject;
        m_goCreateCharacterUI        = m_myTransform.Find("CreateCharacterUI").gameObject;
        m_goRecommendServerUI        = m_myTransform.Find("RecommendServerUI").gameObject;
        m_goChooseServerGridPageList = m_myTransform.Find(m_widgetToFullName["ChooseServerPageList"]).gameObject;

        m_MTBChooseCharacterUIServer = m_myTransform.Find("ChooseCharacterUI/ChooseCharacterUIBottomLeft/ChooseCharcterUIServerBtn").GetComponentsInChildren <MogoTwoStatusButton>(true)[0];
        m_MTBCreateCharacterUIServer = m_myTransform.Find("CreateCharacterUI/CreateCharacterUIBottomRight/CreateCharacterUIServerBtn").GetComponentsInChildren <MogoTwoStatusButton>(true)[0];
        m_MTBLatelyLog0 = m_myTransform.Find("ChooseServerUI/ChooseServerUILatelyLogBtn0").GetComponentsInChildren <MogoTwoStatusButton>(true)[0];
        m_MTBLatelyLog1 = m_myTransform.Find("ChooseServerUI/ChooseServerUILatelyLogBtn1").GetComponentsInChildren <MogoTwoStatusButton>(true)[0];

        m_goCreateCharacterDetailUIJobIconList = m_myTransform.Find(m_widgetToFullName["CreateCharacterDetailUIJobIconList"]).gameObject;

        m_spResCtrl = m_myTransform.Find(m_widgetToFullName["NewLoginUIResCtrl"]).GetComponentsInChildren <UISprite>(true)[0];

        m_atlasCanRelease = m_spResCtrl.atlas;

        m_goCurrentUI = m_goChooseCharacterUI;

        for (int i = 0; i < 4; ++i)
        {
            AssetCacheMgr.GetUIInstance("ChooseCharcterUIGrid.prefab", (prefab, id, go) =>
            {
                GameObject obj = (GameObject)go;

                obj.transform.parent = m_goChooseCharcterGridList.transform;

                obj.transform.localPosition = new Vector3(0, -m_listChooseCharacterGrid.Count * CHOOSECHARACTERGRIDHEIGHT, 0);
                obj.transform.localScale    = new Vector3(1, 1, 1);
                //obj.GetComponentsInChildren<ChooseCharacterUIGrid>(true)[0].Id = m_listChooseCharacterGrid.Count;
                obj.AddComponent <ChooseCharacterUIGrid>().Id = m_listChooseCharacterGrid.Count;
                m_goChooseCharcterGridList.GetComponentsInChildren <MogoSingleButtonList>(true)[0].SingleButtonList.Add(obj.GetComponentsInChildren <MogoSingleButton>(true)[0]);

                m_listChooseCharacterGrid.Add(obj);

                if (m_listChooseCharacterGrid.Count == 4)
                {
                    TruelyFillChooseCharacterGridData();
                    TruelySetCharacterGridDown();
                    MogoGlobleUIManager.Instance.ShowWaitingTip(false);
                }
            });
        }



        for (int i = 0; i < 3; ++i)
        {
            AssetCacheMgr.GetUIInstance("CreateCharacterDetailUIJobAttr.prefab", (prefab, id, go) =>
            {
                GameObject obj = (GameObject)go;

                obj.transform.parent = m_goJobAttrList.transform;

                obj.transform.localPosition = new Vector3(0, -m_listJobAttr.Count * JOBATTRGRIDHEIGHT, 0);
                obj.transform.localScale    = new Vector3(1, 1, 1);

                obj.AddComponent <CreateCharacterDetailUIJobAttr>();

                m_listJobAttr.Add(obj);
            });
        }

        Initialize();
        inited = true;
    }
    /// <summary>
    /// 添加等级不足活动Grid
    /// </summary>
    /// <param name="num"></param>
    /// <param name="act"></param>
    void AddUIGridList(int num, Action act = null)
    {
        ClearUIGridList();
        ResetGridListCameraPos();

        // 删除翻页位置(滑动形式不需要处理)
        if (m_dragableCamera.IsMovePage)
        {
            if (m_dragableCamera.transformList != null)
            {
                for (int i = 0; i < m_dragableCamera.transformList.Count; ++i)
                {
                    Destroy(m_dragableCamera.transformList[i].gameObject);
                }

                m_dragableCamera.transformList.Clear();
            }
        }

        for (int i = 0; i < num; ++i)
        {
            int index = i;
            AssetCacheMgr.GetUIInstance("LevelNoEnoughUIGrid.prefab", (prefab, guid, go) =>
            {
                GameObject obj              = (GameObject)go;
                obj.transform.parent        = m_tranUIGridlList;
                obj.transform.localPosition = new Vector3(0, ITEMSPACEVERTICAL * index, 0);
                obj.transform.localScale    = new Vector3(1f, 1f, 1f);
                obj.GetComponentsInChildren <MyDragCamera>(true)[0].RelatedCamera = m_gridListCamera;
                LevelNoEnoughUIGrid gridUI = obj.AddComponent <LevelNoEnoughUIGrid>();

                if (m_mapGrid.ContainsKey(index))
                {
                    AssetCacheMgr.ReleaseInstance(m_mapGrid[index].gameObject);
                }
                m_mapGrid[index] = gridUI;

                // 创建翻页位置(滑动形式不需要处理)
                if (m_dragableCamera.IsMovePage)
                {
                    if (index % GRID_COUNT_ONE_PAGE == 0)
                    {
                        GameObject trans                 = new GameObject();
                        trans.transform.parent           = m_gridListCamera.transform;
                        trans.transform.localPosition    = new Vector3(0, index / GRID_COUNT_ONE_PAGE * ITEMSPACEVERTICAL * GRID_COUNT_ONE_PAGE, 0);
                        trans.transform.localEulerAngles = Vector3.zero;
                        trans.transform.localScale       = new Vector3(1, 1, 1);
                        trans.name = "GridListPosHorizon" + index / GRID_COUNT_ONE_PAGE;
                        m_dragableCamera.transformList.Add(trans.transform);
                        m_dragableCamera.SetArrow();
                    }
                }

                if (index == num - 1)
                {
                    // 滑动形式和翻页形式都需要设置
                    //if (!m_dragableCamera.IsMovePage)
                    {
                        m_dragableCamera.FPageHeight = ITEMSPACEVERTICAL * GRID_COUNT_ONE_PAGE;
                        m_dragableCamera.MAXY        = OFFSET_Y;
                        if (m_mapGrid.Count > GRID_COUNT_ONE_PAGE)
                        {
                            m_dragableCamera.MINY = (m_mapGrid.Count - GRID_COUNT_ONE_PAGE) * ITEMSPACEVERTICAL + OFFSET_Y;
                        }
                        else
                        {
                            m_dragableCamera.MINY = m_dragableCamera.MAXY;
                        }
                        m_dragableCamera.SetArrow();
                    }

                    if (act != null)
                    {
                        act();
                    }
                }
            });
        }
    }
Beispiel #18
0
    public void AddChooseServerGrid(ChooseServerGridData cd)
    {
        AssetCacheMgr.GetUIInstance("ChooseServerUIServerBtn.prefab", (prefab, id, go) =>
        {
            GameObject obj = (GameObject)go;

            obj.transform.parent = m_goChooseServerGridList.transform;

            int page = m_listChooseServerGrid.Count / 12;
            int row  = (m_listChooseServerGrid.Count % 12) / 3;
            int col  = (m_listChooseServerGrid.Count % 12) % 3;

            if (page + 1 > m_iCurrentServerGridPage)
            {
                GameObject trans = new GameObject();

                trans.transform.parent           = m_goChooseServerGridList.transform;
                trans.transform.localPosition    = new Vector3(page * CHOOSESERVERGRIDPAGEWIDTH + CHOOSESERVERGRIDWIDTH, -125, 0);
                trans.transform.localEulerAngles = Vector3.zero;
                trans.transform.localScale       = new Vector3(1, 1, 1);

                m_dragableCameraChooseServerGridList.transformList.Add(trans.transform);
                m_dragableCameraChooseServerGridList.SetArrow();

                ++m_iCurrentServerGridPage;
            }

            obj.transform.localPosition = new Vector3(page * CHOOSESERVERGRIDPAGEWIDTH + col * CHOOSESERVERGRIDWIDTH, -row * CHOOSESERVERGRIDHEIGHT, 0);
            obj.transform.localScale    = new Vector3(1, 1, 1);
            obj.AddComponent <MyDragCamera>().RelatedCamera = m_camChooseServerGridList;

            ChooseServerUIGrid sg = obj.AddComponent <ChooseServerUIGrid>();

            sg.Id           = m_listChooseServerGrid.Count;
            sg.ServerName   = cd.serverName;
            sg.ServerStatus = cd.serverStatus;

            m_listChooseServerGrid.Add(obj);

            if (m_iChooseServerPageNum < page + 1)
            {
                ++m_iChooseServerPageNum;

                int num = m_iChooseServerPageNum;

                AssetCacheMgr.GetUIInstance("ChooseServerPage.prefab", (prefabPage, idPage, goPage) =>
                {
                    GameObject objPage = (GameObject)goPage;

                    objPage.transform.parent        = m_goChooseServerGridPageList.transform;
                    objPage.transform.localPosition = new Vector3((num - 1) * 40, 0, 0);
                    objPage.transform.localScale    = Vector3.one;
                    m_dragableCameraChooseServerGridList.ListPageDown.Add(objPage.GetComponentsInChildren <UISprite>(true)[1].gameObject);
                    m_goChooseServerGridPageList.transform.localPosition += new Vector3(-20 * (num - 1), 0, 0);

                    if (num == 1)
                    {
                        objPage.GetComponentsInChildren <UISprite>(true)[1].gameObject.SetActive(true);
                    }

                    m_listChooseServerGridPage.Add(objPage);
                });
            }
        });
    }
Beispiel #19
0
    string AddFaceToChatUIInput(string text)
    {
        string tmp      = text;
        string lastText = text;
        string lastTmp  = text;
        int    length   = text.Length;

        int faceIconId = 1;


        for (int i = 0; i < length; ++i)
        {
            if (text[i] == '{' && i + 1 < length && text[i + 1] == ':')
            {
                int index = i + 2;

                while (index < length)
                {
                    if (text[index] == '}')// && index + 2 < length && text.Substring(index, 3) == "[-]")
                    {
                        lastText = text.Substring(index + 1);
                        lastTmp  = lastText;
                        int lastLenth = lastText.Length;

                        for (int l = 0; l < lastLenth; ++l)
                        {
                            if (lastText[l] == '{' && l + 1 < lastLenth && lastText[l + 1] == ':')
                            {
                                int lastIndex = l + 2;

                                while (lastIndex < lastLenth)
                                {
                                    if (lastText[lastIndex] == '}')            // && index + 2 < length && text.Substring(index, 3) == "[-]")
                                    {
                                        //Debug.LogError(lastText.Substring(l, lastIndex - l + 1));
                                        lastTmp = lastTmp.ReplaceFirst(lastText.Substring(l, lastIndex - l + 1), " ");

                                        break;
                                    }

                                    ++lastIndex;
                                }
                            }
                        }

                        //Debug.LogError(text.Substring(i+2, 1));
                        tmp = tmp.ReplaceFirst(text.Substring(i, index - i + 1), " ");
                        bool isAlready = false;
                        int  faceId    = -1;

                        if (text.Substring(i, index - i + 1).Length == 4)
                        {
                            faceIconId = int.Parse(text.Substring(i + 2, 1)) + 1;
                        }
                        else if (text.Substring(i, index - i + 1).Length == 5)
                        {
                            faceIconId = int.Parse(text.Substring(i + 2, 2)) + 1;
                        }
                        for (int j = 0; j < mFaceList.Count; ++j)
                        {
                            if (mFaceList[j].name == "Face" + i.ToString())
                            {
                                isAlready = true;
                                faceId    = j;
                                break;
                            }
                        }

                        if (!isAlready)
                        {
                            AssetCacheMgr.GetUIInstance("FaceIconDialog.prefab", (prefab, id, go) =>
                            {
                                GameObject obj = (GameObject)go;
                                obj.name       = "Face" + i.ToString();
                                obj.SetActive(true);
                                obj.transform.parent        = transform.Find("CommunityUIPrivateInputList");
                                obj.transform.localScale    = new Vector3(0.7f, 0.7f, 1);
                                obj.transform.localPosition = new Vector3(label.transform.localPosition.x -
                                                                          label.font.CalculatePrintedSize(text.Substring(index + 1), true, UIFont.SymbolStyle.None).x * 22,
                                                                          label.transform.localPosition.y, label.transform.localPosition.z);

                                UISprite sp = obj.transform.GetComponentsInChildren <UISprite>(true)[0];
                                sp.pivot    = UIWidget.Pivot.Right;
                                sp.transform.localPosition = Vector3.zero;

                                //Debug.LogError(faceIconId + " " + UIFaceIconData.dataMap[faceIconId].facefirst);
                                sp.spriteName = UIFaceIconData.dataMap[faceIconId].facefirst;
                                obj.GetComponentsInChildren <UISpriteAnimation>(true)[0].namePrefix =
                                    UIFaceIconData.dataMap[faceIconId].facehead;

                                mFaceList.Add(obj);
                            });
                        }
                        else
                        {
                            if (faceId != -1)
                            {
                                mFaceList[faceId].transform.localPosition = new Vector3(label.transform.localPosition.x -
                                                                                        label.font.CalculatePrintedSize(lastTmp, true, UIFont.SymbolStyle.None).x * 22,
                                                                                        label.transform.localPosition.y, label.transform.localPosition.z);
                            }
                        }
                        break;
                    }

                    ++index;
                }
            }
        }

        float   lineWidth  = CommunityUILogicManager.Instance.GetLabelOffect();
        Vector2 vec2CamPos = CommunityUILogicManager.Instance.GetCameraSize();

        //float fOffect = -lineWidth + 22 * label.font.CalculatePrintedSize(tmp, true, UIFont.SymbolStyle.None).x;
        //if (fOffect >= 0)
        //{
        //    fOffect = 0;
        //}
        //label.transform.localPosition = new Vector3(fOffect+270, label.transform.localPosition.y, label.transform.localPosition.z);

        float textWidth = 22 * label.font.CalculatePrintedSize(tmp, true, UIFont.SymbolStyle.None).x;
        float fOffect   = vec2CamPos.x - textWidth;

        if (fOffect <= vec2CamPos.y)
        {
            fOffect = vec2CamPos.y;
        }

        CommunityUILogicManager.Instance.SetTextCameraPosX(fOffect);

        spriteBG.transform.localScale    = new Vector3(lineWidth, spriteBG.transform.localScale.y, spriteBG.transform.localScale.z);
        spriteBG.transform.localPosition = new Vector3(270, spriteBG.transform.localPosition.y, spriteBG.transform.localPosition.z);
        //panel.clipRange = new Vector4(panel.clipRange.x, panel.clipRange.y, CommunityUILogicManager.Instance.GetPanelClipSize(), panel.clipRange.w);
        return(tmp);
        //bool isAlready = false;
        //int faceId = -1;


        //for (int j = 0; j < mFaceList.Count; ++j)
        //{
        //    if (mFaceList[j].name == "Face" + i.ToString())
        //    {
        //        isAlready = true;
        //        faceId = j;
        //        break;
        //    }
        //}

        //if (!isAlready)
        //{
        //    AssetCacheMgr.GetUIInstance("ChatUIFace.prefab", (prefab, id, go) =>
        //    {
        //        GameObject obj = (GameObject)go;
        //        obj.name = "Face" + i.ToString();
        //        obj.SetActive(true);
        //        obj.transform.parent = transform;
        //        obj.transform.localPosition = new Vector3(label.transform.localPosition.x -
        //            label.font.CalculatePrintedSize(text.Substring(index + 1), true, UIFont.SymbolStyle.None).x  * 22,
        //            obj.transform.localPosition.y, obj.transform.localPosition.z);
        //        Debug.Log(label.font.CalculatePrintedSize(text.Substring(index + 1), true, UIFont.SymbolStyle.None));
        //        Debug.Log(text.Substring(index + 1));

        //        mFaceList.Add(obj);
        //    });
        //}
        //else
        //{
        //    if (faceId != -1)
        //    {
        //        mFaceList[faceId].transform.localPosition = label.transform.localPosition - new Vector3(
        //            label.font.CalculatePrintedSize(text.Substring(index + 1), true, UIFont.SymbolStyle.None).x * 22, 0, 0);
        //    }
        //}
    }
Beispiel #20
0
    public void ShowAsWhiteBlack(bool show, bool isDebugShow = false)
    {
        if (show)
        {
            if (MogoMaterial == null)
            {
                //Material mat = new Material(Shader.Find("Mogo/BlackWhite"));
                //Material mat = Resources.Load("MogoBlackWhiteMat") as Material;
                //mat.mainTexture = material.mainTexture;
                //MogoMaterial = mat;

                if (!BlackWhiteMaterialDic.ContainsKey(material.mainTexture))
                {
                    string matName = "MogoBlackWhiteMat.mat";
                    AssetCacheMgr.GetUIInstance(matName, (resourceName, guid, go) =>
                    {
                        Material mat = go as Material;

                        mat.mainTexture = material.mainTexture;

                        if (material.HasProperty("_AlphaTex"))
                        {
                            mat.SetTexture("_AlphaTex", material.GetTexture("_AlphaTex"));
                            m_oriAlphaTex = material.GetTexture("_AlphaTex");
                        }
                        m_oriTex     = material.mainTexture;
                        MogoMaterial = mat;

                        if (!isDebugShow)
                        {
                            RefreshPanel(gameObject);
                        }
                        BlackWhiteMaterialDic[material.mainTexture] = mat;
                    });
                }
                else
                {
                    m_oriTex = material.mainTexture;
                    if (material.HasProperty("_AlphaTex"))
                    {
                        m_oriAlphaTex = material.GetTexture("_AlphaTex");
                    }
                    MogoMaterial = BlackWhiteMaterialDic[material.mainTexture];

                    if (!isDebugShow)
                    {
                        RefreshPanel(gameObject);
                    }
                }
            }
            else
            {
                MogoMaterial.mainTexture = m_oriTex;
                if (m_oriAlphaTex != null)
                {
                    MogoMaterial.SetTexture("_AlphaTex", m_oriAlphaTex);
                }
                if (!isDebugShow)
                {
                    RefreshPanel(gameObject);
                }
            }
        }
        else
        {
            MogoMaterial = null;
            RefreshPanel(gameObject);
        }
    }
    private void LoadUpgradePowerGridList(int num, Action act = null)
    {
        if (IsLoadUpgradePowerGridList)
        {
            return;
        }

        IsLoadUpgradePowerGridList = true;
        for (int i = 0; i < num; ++i)
        {
            INSTANCE_COUNT++;
            MogoGlobleUIManager.Instance.ShowWaitingTip(true);

            int index = i;
            AssetCacheMgr.GetUIInstance("UpgradePowerUISystemGrid.prefab", (prefab, guid, go) =>
            {
                GameObject obj       = (GameObject)go;
                obj.transform.parent = m_tranUpgradePowerUISystemList;

                if (index % GRID_COUNT_ONE_LINE == 0)
                {
                    obj.transform.localPosition = new Vector3(0, GRIDSPACEVERTICAL * (index / GRID_COUNT_ONE_LINE) + OffsetX, 0);
                }
                else
                {
                    obj.transform.localPosition = new Vector3(GRIDSPACEHORIZON, GRIDSPACEVERTICAL * (index / GRID_COUNT_ONE_LINE) + OffsetX, 0);
                }

                obj.transform.localScale      = new Vector3(1f, 1f, 1f);
                UpgradePowerUISystemGrid grid = obj.AddComponent <UpgradePowerUISystemGrid>();
                m_listUpgradePowerGridGO.Add(grid);

                INSTANCE_COUNT--;
                if (INSTANCE_COUNT <= 0)
                {
                    MogoGlobleUIManager.Instance.ShowWaitingTip(false);
                }


                // 数量大于一页时,创建拖动效果
                if (num > GRID_COUNT_ONE_PAGE)
                {
                    MyDragCamera myDragCamera  = obj.AddComponent <MyDragCamera>();
                    myDragCamera.RelatedCamera = m_camUpgradePowerUISystemListCamera;
                    m_camUpgradePowerUISystemListCamera.GetComponentsInChildren <MyDragableCamera>(true)[0].MAXX =
                        OffsetX + (m_listUpgradePowerGridGO.Count - GRID_COUNT_ONE_PAGE) / GRID_COUNT_ONE_LINE * GRIDSPACEVERTICAL;

                    // 创建翻页位置
                    if (index % GRID_COUNT_ONE_PAGE == 0)
                    {
                        GameObject trans                 = new GameObject();
                        trans.transform.parent           = m_camUpgradePowerUISystemListCamera.transform;
                        trans.transform.localPosition    = new Vector3(index / GRID_COUNT_ONE_LINE * GRIDSPACEVERTICAL, 0, 0);
                        trans.transform.localEulerAngles = Vector3.zero;
                        trans.transform.localScale       = new Vector3(1, 1, 1);
                        trans.name = "DragListPosHorizon" + index / GRID_COUNT_ONE_PAGE;
                        m_camUpgradePowerUISystemListCamera.GetComponentsInChildren <MyDragableCamera>(true)[0].transformList.Add(trans.transform);
                    }
                }

                if (index == num - 1)
                {
                    if (act != null)
                    {
                        act();
                    }
                }
            });
        }
    }
Beispiel #22
0
    /// <summary>
    /// 创建推荐装备Grid列表
    /// </summary>
    /// <param name="num"></param>
    /// <param name="act"></param>
    void AddEquipRecommendGridList(int num, Action action = null)
    {
        ClearEquipRecommendGridList();
        ResetCameraPos();
        ShowEquipRecommendGridListArrow(num);

        // 删除翻页位置(滑动形式不需要处理)
        if (m_dragableCamera.IsMovePage)
        {
            if (m_dragableCamera.transformList != null)
            {
                for (int i = 0; i < m_dragableCamera.transformList.Count; ++i)
                {
                    Destroy(m_dragableCamera.transformList[i].gameObject);
                }

                m_dragableCamera.transformList.Clear();
            }
        }

        for (int i = 0; i < num; ++i)
        {
            int index = i;

            INSTANCE_COUNT++;
            MogoGlobleUIManager.Instance.ShowWaitingTip(true);

            AssetCacheMgr.GetUIInstance("EquipRecommendUIGrid.prefab", (prefab, guid, go) =>
            {
                GameObject obj              = (GameObject)go;
                obj.transform.parent        = m_tranEquipRecommendUIEquipList;
                obj.transform.localPosition = new Vector3(0, ITEMSPACEVERTICAL * index, 0);
                obj.transform.localScale    = new Vector3(1f, 1f, 1f);
                obj.GetComponentsInChildren <MyDragCamera>(true)[0].RelatedCamera = m_equipListCamera;
                EquipRecommendUIGrid gridUI = obj.AddComponent <EquipRecommendUIGrid>();

                if (m_maplistEquipRecommendUIGrid.ContainsKey(index))
                {
                    AssetCacheMgr.ReleaseInstance(m_maplistEquipRecommendUIGrid[i].gameObject);
                }
                m_maplistEquipRecommendUIGrid[index] = gridUI;

                // 创建翻页位置(滑动形式不需要处理)
                if (m_dragableCamera.IsMovePage)
                {
                    if (index % GRID_COUNT_ONE_PAGE == 0)
                    {
                        GameObject trans                 = new GameObject();
                        trans.transform.parent           = m_equipListCamera.transform;
                        trans.transform.localPosition    = new Vector3(0, index / GRID_COUNT_ONE_PAGE * ITEMSPACEVERTICAL * GRID_COUNT_ONE_PAGE, 0);
                        trans.transform.localEulerAngles = Vector3.zero;
                        trans.transform.localScale       = new Vector3(1, 1, 1);
                        trans.name = "DragListPosVertical" + index / GRID_COUNT_ONE_PAGE;
                        m_dragableCamera.transformList.Add(trans.transform);
                    }
                }

                INSTANCE_COUNT--;
                if (INSTANCE_COUNT <= 0)
                {
                    MogoGlobleUIManager.Instance.ShowWaitingTip(false);
                }

                if (index == num - 1)
                {
                    // 滑动形式和翻页形式都需要设置
                    //if (!m_dragableCamera.IsMovePage)
                    {
                        m_dragableCamera.FPageHeight = ITEMSPACEVERTICAL * GRID_COUNT_ONE_PAGE;
                        m_dragableCamera.MAXY        = OFFSET_Y;
                        if (m_maplistEquipRecommendUIGrid.Count > GRID_COUNT_ONE_PAGE)
                        {
                            m_dragableCamera.MINY = (m_maplistEquipRecommendUIGrid.Count - GRID_COUNT_ONE_PAGE) * ITEMSPACEVERTICAL + OFFSET_Y;
                        }
                        else
                        {
                            m_dragableCamera.MINY = m_dragableCamera.MAXY;
                        }

                        if (action != null)
                        {
                            action();
                        }
                    }
                }
            });
        }
    }
    public void RefreshGridList(List <NewLoginRewardGridData> list)
    {
        if (m_listRewardGrid.Count > 0)
        {
            return;
        }

        for (int i = 0; i < list.Count; ++i)
        {
            int index = i;

            AssetCacheMgr.GetUIInstance("NewLoginRewardUIRewardGrid.prefab", (name, id, go) =>
            {
                GameObject gameObj = (GameObject)go;
                gameObj.name       = string.Concat("NewLoginRewardUIRewardGrid", index);
                MFUIUtils.AttachWidget(gameObj.transform, GetTransform("NewLoginRewardUIRewardList"));
                gameObj.transform.localPosition = new Vector3(0, -index * 120f, 0);
                gameObj.transform.localScale    = Vector3.one;
                gameObj.GetComponentsInChildren <MyDragCamera>(true)[0].RelatedCamera = GetTransform("NewLoginRewardUIRewardListCam").GetComponentsInChildren <Camera>(true)[0];
                NewLoginRewardUIRewardGrid grid = gameObj.AddComponent <NewLoginRewardUIRewardGrid>();
                gameObj.transform.FindChild("NewLoginRewardUIGetBtn").GetComponentsInChildren <MFUIButtonHandler>(true)[0].ID           = index;
                gameObj.transform.FindChild("NewLoginRewardUIGetBtn").GetComponentsInChildren <MFUIButtonHandler>(true)[0].ClickHandler = OnGetBtnUp;

                grid.SetDays(list[index].strDays);
                if (list[index].IsGot)
                {
                    grid.ShowItemGotSign(true);
                    grid.ShowSendToMailText(false);
                    grid.ShowGetBtn(false);
                }
                else
                {
                    if (list[index].IsSendToMailBox)
                    {
                        grid.ShowItemGotSign(false);
                        grid.ShowSendToMailText(true);
                        grid.ShowGetBtn(false);
                    }
                    else
                    {
                        grid.ShowGetBtn(true);
                        grid.ShowItemGotSign(false);
                        grid.ShowSendToMailText(false);
                    }
                }

                for (int j = 0; j < 5; ++j)
                {
                    if (j < list[index].listItemID.Count)
                    {
                        grid.ShowItemGrid(true, j);

                        //grid.SetItemImg(list[index].listItemImg[j], j);
                        grid.SetItemID(list[index].listItemID[j], j);
                        grid.SetItemNum(list[index].listItemNum[j].ToString(), j);
                    }
                    else
                    {
                        grid.ShowItemGrid(false, j);
                    }
                }

                if (list.Count > 4)
                {
                    GetTransform("NewLoginRewardUIRewardListCam").GetComponentsInChildren <MyDragableCamera>(true)[0].MINY = -180f - 120f * (list.Count - 4);
                }
                else
                {
                    GetTransform("NewLoginRewardUIRewardListCam").GetComponentsInChildren <MyDragableCamera>(true)[0].MINY = -180f;
                }

                m_listRewardGrid.Add(gameObj);
            });
        }
    }
    /// <summary>
    /// 添加Boss宝箱奖励
    /// </summary>
    /// <param name="num"></param>
    /// <param name="act"></param>
    void AddBossTreasureGridList(int num, Action act = null)
    {
        ClearBossTreasureGridList();
        ResetGridListCameraPos();

        // 删除翻页位置
        if (m_gridListMyDragableCamera.transformList != null)
        {
            for (int i = 0; i < m_gridListMyDragableCamera.transformList.Count; ++i)
            {
                Destroy(m_gridListMyDragableCamera.transformList[i].gameObject);
            }

            m_gridListMyDragableCamera.transformList.Clear();
        }

        for (int i = 0; i < num; ++i)
        {
            int index = i;

            INSTANCE_COUNT++;
            MogoGlobleUIManager.Instance.ShowWaitingTip(true);

            AssetCacheMgr.GetUIInstance("InstanceBossTreasureUIGrid.prefab", (prefab, guid, go) =>
            {
                GameObject obj              = (GameObject)go;
                obj.transform.parent        = m_tranInstanceBossTreasureUIGridlList;
                obj.transform.localPosition = new Vector3(ITEMSPACEHORIZON * index, 0, 0);
                obj.transform.localScale    = new Vector3(0.8f, 0.8f, 1);
                obj.GetComponentsInChildren <MyDragCamera>(true)[0].RelatedCamera = m_gridListCamera;
                InstanceBossTreasureUIGrid gridUI = obj.AddComponent <InstanceBossTreasureUIGrid>();
                m_mapBossTreasure[index]          = gridUI;

                if (m_mapBossTreasure.Count >= BOSSTREASURE_COUNT_ONE_PAGE)
                {
                    m_gridListMyDragableCamera.MAXX =
                        (m_mapBossTreasure.Count - BOSSTREASURE_COUNT_ONE_PAGE) * ITEMSPACEHORIZON;
                }

                // 创建翻页位置
                if (index % BOSSTREASURE_COUNT_ONE_PAGE == 0)
                {
                    GameObject trans                 = new GameObject();
                    trans.transform.parent           = m_gridListCamera.transform;
                    trans.transform.localPosition    = new Vector3(index / BOSSTREASURE_COUNT_ONE_PAGE * ITEMSPACEHORIZON * BOSSTREASURE_COUNT_ONE_PAGE, 0, 0);
                    trans.transform.localEulerAngles = Vector3.zero;
                    trans.transform.localScale       = new Vector3(1, 1, 1);
                    trans.name = "GridListPosHorizon" + index / BOSSTREASURE_COUNT_ONE_PAGE;
                    m_gridListMyDragableCamera.transformList.Add(trans.transform);
                    m_gridListMyDragableCamera.SetCurrentPage(m_gridListMyDragableCamera.GetCurrentPage());
                }

                INSTANCE_COUNT--;
                if (INSTANCE_COUNT <= 0)
                {
                    MogoGlobleUIManager.Instance.ShowWaitingTip(false);
                }

                if (index == num - 1)
                {
                    if (act != null)
                    {
                        act();
                    }
                }
            });
        }
    }
Beispiel #25
0
    /// <summary>
    /// 添加记录Grid
    /// </summary>
    /// <param name="num"></param>
    /// <param name="act"></param>
    void AddUIGridList(int num, Action act = null)
    {
        ClearUIGridList();
        ResetGridListCameraPos();
        ShowUIArrow(num);

        // 删除翻页位置
        m_gridListMyDragableCamera.DestroyMovePagePosList();
        m_gridListMyDragableCamera.FPageHeight = ITEMSPACEVERTICAL * GRID_COUNT_ONE_PAGE;

        if (num == 0)
        {
            if (act != null)
            {
                act();
            }

            return;
        }

        for (int i = 0; i < num; ++i)
        {
            INSTANCE_COUNT++;
            MogoGlobleUIManager.Instance.ShowWaitingTip(true);

            int index = i;
            AssetCacheMgr.GetUIInstance("DragonMatchRecordUIGrid.prefab", (prefab, guid, go) =>
            {
                GameObject obj              = (GameObject)go;
                obj.transform.parent        = m_tranUIGridlList;
                obj.transform.localPosition = new Vector3(0, ITEMSPACEVERTICAL * index, 0);
                obj.transform.localScale    = new Vector3(1f, 1f, 1f);
                obj.GetComponentsInChildren <MyDragCamera>(true)[0].RelatedCamera = m_gridListCamera;
                DragonMatchRecordUIGrid grid = obj.AddComponent <DragonMatchRecordUIGrid>();
                m_listGrid.Add(grid);

                m_gridListMyDragableCamera.MAXY = OFFSET_Y;
                if (m_listGrid.Count > GRID_COUNT_ONE_PAGE)
                {
                    m_gridListMyDragableCamera.MINY = (m_listGrid.Count - GRID_COUNT_ONE_PAGE) * ITEMSPACEVERTICAL + OFFSET_Y;
                }
                else
                {
                    m_gridListMyDragableCamera.MINY = m_gridListMyDragableCamera.MAXY;
                }

                INSTANCE_COUNT--;
                if (INSTANCE_COUNT <= 0)
                {
                    MogoGlobleUIManager.Instance.ShowWaitingTip(false);
                }

                // 创建翻页位置
                if (index % GRID_COUNT_ONE_PAGE == 0)
                {
                    GameObject trans                 = new GameObject();
                    trans.transform.parent           = m_gridListCamera.transform;
                    trans.transform.localPosition    = new Vector3(0, index / GRID_COUNT_ONE_PAGE * ITEMSPACEVERTICAL * GRID_COUNT_ONE_PAGE + OFFSET_Y, 0);
                    trans.transform.localEulerAngles = Vector3.zero;
                    trans.transform.localScale       = new Vector3(1, 1, 1);
                    trans.name = "GridListPosHorizon" + index / GRID_COUNT_ONE_PAGE;
                    m_gridListMyDragableCamera.transformList.Add(trans.transform);
                }

                if (index == num - 1)
                {
                    if (act != null)
                    {
                        act();
                    }
                }
            });
        }
    }
    /// <summary>
    /// ����Grid
    /// </summary>
    /// <param name="gridData"></param>
    /// <param name="theID"></param>
    public void AddActivityGrid(LimitActivityGridData gridData, int theID)
    {
        INSTANCE_COUNT++;
        MogoGlobleUIManager.Instance.ShowWaitingTip(true);

        AssetCacheMgr.GetUIInstance("TimeLimitActivityGrid.prefab", (prefab, id, go) =>
        {
            for (int i = 0; i < m_listActivityGird.Count; ++i)
            {
                if (m_listActivityGird[i].Id == theID)
                {
                    AssetCacheMgr.ReleaseInstance((GameObject)go);
                    return;
                }
            }
            GameObject obj = (GameObject)go;
            TimeLimitActivityGrid gridUI = obj.AddComponent <TimeLimitActivityGrid>();

            obj.name = "TimeLimitActivityGrid" + m_listActivityGird.Count;

            gridUI.LoadResourceInsteadOfAwake();
            gridUI.Id         = theID;
            gridUI.Index      = m_listActivityGird.Count;
            gridUI.CDText     = gridData.CDText;
            gridUI.TitleText  = gridData.TitleText;
            gridUI.GridFGName = gridData.FGImgName;
            gridUI.SetActivityStatus(gridData.Status);

            obj.transform.parent        = m_goActivityGridList.transform;
            obj.transform.localPosition = new Vector3(m_listActivityGirdObject.Count * ACTIVITYGRIDWIDTH, 0, -1);
            obj.transform.localScale    = new Vector3(1, 1, 1);

            m_listActivityGirdObject.Add(obj);
            m_listActivityGird.Add(gridUI);

            obj.GetComponentsInChildren <MyDragCamera>(true)[0].RelatedCamera = m_camActivityGridList.transform.GetComponentsInChildren <Camera>(true)[0];

            INSTANCE_COUNT--;
            if (INSTANCE_COUNT <= 0)
            {
                MogoGlobleUIManager.Instance.ShowWaitingTip(false);
            }

            if (m_listActivityGirdObject.Count - ActivityGridCountOnePage >= 0)
            {
                m_dragableCameraActivityGridList.MAXX = 380 + ACTIVITYGRIDWIDTH * (m_listActivityGirdObject.Count - 3);
            }
            else
            {
                m_dragableCameraActivityGridList.MAXX = 380;
            }

            EventDispatcher.TriggerEvent <int>("LoadTimeLimitActivityGridDone", gridUI.Id);

            if (obj.name == MogoUIManager.Instance.WaitingWidgetName)
            {
                EventDispatcher.TriggerEvent("WaitingWidgetFinished");
            }

            // ������ҳλ��
            int index = m_listActivityGirdObject.Count - 1;
            if (index % ActivityGridCountOnePage == 0)
            {
                GameObject trans                 = new GameObject();
                trans.transform.parent           = m_camActivityGridList.transform;
                trans.transform.localPosition    = new Vector3(index / ActivityGridCountOnePage * 1140 + 380, 0, 0);
                trans.transform.localEulerAngles = Vector3.zero;
                trans.transform.localScale       = new Vector3(1, 1, 1);
                trans.name = "ActivityGridPagePosHorizon" + index / ActivityGridCountOnePage;
                m_dragableCameraActivityGridList.transformList.Add(trans.transform);
                m_dragableCameraActivityGridList.SetCurrentPage(0);

                // ����ҳ����
                ++m_iActivityGridPageNum;
                int num = m_iActivityGridPageNum;
                AssetCacheMgr.GetUIInstance("ChooseServerPage.prefab", (prefabPage, idPage, goPage) =>
                {
                    GameObject objPage = (GameObject)goPage;

                    objPage.transform.parent        = m_goGOTimeLimitActivityUIActivityListPage.transform;
                    objPage.transform.localPosition = new Vector3((num - 1) * 40, 0, 0);
                    objPage.transform.localScale    = Vector3.one;
                    objPage.name = "ActivityGridPage" + num;
                    m_camActivityGridList.GetComponentsInChildren <MyDragableCamera>(true)[0].ListPageDown.Add(objPage.GetComponentsInChildren <UISprite>(true)[1].gameObject);
                    m_goGOTimeLimitActivityUIActivityListPage.transform.localPosition = new Vector3(-20 * (num - 1), m_goGOTimeLimitActivityUIActivityListPage.transform.localPosition.y, 0);

                    // ѡ��ǰҳ
                    if (num - 1 == m_dragableCameraActivityGridList.GetCurrentPage())
                    {
                        objPage.GetComponentsInChildren <UISprite>(true)[1].gameObject.SetActive(true);
                    }
                    else
                    {
                        objPage.GetComponentsInChildren <UISprite>(true)[1].gameObject.SetActive(false);
                    }
                    m_dragableCameraActivityGridList.GODOTPageList = m_goGOTimeLimitActivityUIActivityListPage;
                    m_dragableCameraActivityGridList.SetCurrentPage(m_dragableCameraActivityGridList.GetCurrentPage());
                });
            }
        });
    }