public void SetData(CalendarDetailVo calendarDetailVo)
    {
        Debug.Log("LoveDiaryEditController   SetData");
        _curCalendarDetailVo = calendarDetailVo;
        _curCalendarDetailVo.CurDiaryElementCount.MaxImageCount  = GlobalData.ConfigModel.GetConfigByKey(GameConfigKey.DIARY_MAX_IMAG_COUNT);
        _curCalendarDetailVo.CurDiaryElementCount.MaxTextCount   = GlobalData.ConfigModel.GetConfigByKey(GameConfigKey.DIARY_MAX_TEXT_COUNT);
        _curCalendarDetailVo.CurDiaryElementCount.MaxRacketCount = GlobalData.ConfigModel.GetConfigByKey(GameConfigKey.DIARY_MAX_RACKET_COUNT);
        _curCalendarDetailVo.CurDiaryElementCount.CurImageCount  = 0;
        _curCalendarDetailVo.CurDiaryElementCount.CurTextCount   = 0;
        _curCalendarDetailVo.CurDiaryElementCount.CurRacketCount = 0;
        DiaryElementPB pb;

        for (int i = 0; i < _curCalendarDetailVo.DiaryElements.Count; i++)
        {
            pb = _curCalendarDetailVo.DiaryElements[i];
            ElementPB elementRule = CalendarDetailVo.GetElementRuleById(pb.ElementId);
            if (elementRule.ElementType == ElementTypePB.Image)
            {
                _curCalendarDetailVo.CurDiaryElementCount.CurImageCount++;
            }
            else if (elementRule.ElementType == ElementTypePB.Text)
            {
                _curCalendarDetailVo.CurDiaryElementCount.CurTextCount++;
            }
            else if (elementRule.ElementType == ElementTypePB.Racket)
            {
                _curCalendarDetailVo.CurDiaryElementCount.CurRacketCount++;
            }
        }
        CurLoveDiaryEditView.SetData(_curEditType, GlobalData.DiaryElementModel, calendarDetailVo);
    }
    private void OnElementTextItemEditClick(int elementId)
    {
        Debug.Log("OnElementTextItemEditClick");

        //有个问题啊,要知道点击的是什么类型的元素!
        ElementPB elementRule    = CalendarDetailVo.GetElementRuleById(elementId);
        var       bottomEditType = LoveDiaryBottomEditType.SecondText;

        switch (elementRule.ElementType)
        {
        case ElementTypePB.Text:
            bottomEditType = LoveDiaryBottomEditType.SecondText;
            break;

        case ElementTypePB.Image:
            bottomEditType = LoveDiaryBottomEditType.Image;
            break;

        case ElementTypePB.Racket:
            bottomEditType = LoveDiaryBottomEditType.Racket;
            break;

        case ElementTypePB.Bg:
            bottomEditType = LoveDiaryBottomEditType.Bg;
            break;

        default:
            bottomEditType = LoveDiaryBottomEditType.SecondText;
            break;
        }

        CurLoveDiaryEditView.OperateBottom(true, bottomEditType);
        IsModify = true;
    }
    private void OnElementTextItemDeleteClick(DiaryElementPB pb)
    {
        Debug.Log("OnElementTextItemDeleteClick");
        ElementPB elementRule = CalendarDetailVo.GetElementRuleById(pb.ElementId);

        _curCalendarDetailVo.CurDiaryElementCount.SubCount(elementRule.ElementType);
        IsModify = true;
    }
    private void OnElementItemClick(int id)
    {
        Debug.Log("OnElementItemClick........................ id " + id);

        ElementPB elementRule = CalendarDetailVo.GetElementRuleById(id);


        if (GlobalData.DiaryElementModel.IsCanUseElement(id)) //表示需要购买
        {
            if (_curCalendarDetailVo.CurDiaryElementCount.IsUpperLimited(elementRule.ElementType))
            {
                FlowText.ShowMessage(I18NManager.Get("LoveDiary_Hint6"));// ("已达上限!");
                return;
            }

            if (elementRule.ElementType == ElementTypePB.Label)
            {
                CurLoveDiaryEditView.CurLabelElementId = id;
            }
            else
            {
                CurLoveDiaryEditView.AddElement(GetNewDiaryElementPB(id), false);
            }
            _curCalendarDetailVo.CurDiaryElementCount.AddCount(elementRule.ElementType);
            CurLoveDiaryEditView.OperateBottom(false);
            IsModify = true;
        }
        else
        {
            string stype = "";
            switch (elementRule.ElementType)
            {
            case ElementTypePB.Bg:
                stype = I18NManager.Get("LoveDiary_Background");    //"背景";
                break;

            case ElementTypePB.Image:
                stype = I18NManager.Get("LoveDiary_Tags");    //"贴纸";
                break;
            }
            string str = I18NManager.Get("LoveDiary_Hint12") + elementRule.UnlockClaim.Gem + I18NManager.Get("LoveDiary_Hint7") + stype;
            PopupManager.ShowConfirmWindow(str).WindowActionCallback = evt =>
            {
                if (evt != WindowEvent.Ok)
                {
                    return;
                }

                BuyElementReq req = new BuyElementReq();
                req.ElementId = id;
                var dataBytes = NetWorkManager.GetByteData(req);
                NetWorkManager.Instance.Send <BuyElementRes>(CMD.DIARYC_ELEMENTS_BUY, dataBytes, OnMyBuyElementHandler);
            };
        }
    }
    private void OnElementInputClick(string str)
    {
        //int id = 7000;// rule 默认 Text id==7000;
        ElementPB elementRule = CalendarDetailVo.GetElementRuleById(7000);

        if (_curCalendarDetailVo.CurDiaryElementCount.IsUpperLimited(elementRule.ElementType))
        {
            FlowText.ShowMessage(I18NManager.Get("LoveDiary_Hint6"));//("已达上限!");
            return;
        }

        CurLoveDiaryEditView.AddElement(GetNewDiaryElementPB(7000, str), true);
        _curCalendarDetailVo.CurDiaryElementCount.AddCount(elementRule.ElementType);
        //CurLoveDiaryEditView.OperateBottom(false);
        IsModify = true;
    }
Esempio n. 6
0
    private void CreateElementItem(DiaryElementPB diaryElementPB, bool immidiateInput = false)
    {
        ElementPB elementRule = CalendarDetailVo.GetElementRuleById(diaryElementPB.ElementId);
        string    prefabPath  = "";

        switch (elementRule.ElementType)
        {
        case ElementTypePB.Image:
            prefabPath = "LoveDiary/Prefabs/Elements/ImageElement";
            break;

        case ElementTypePB.Racket:
            prefabPath = "LoveDiary/Prefabs/Elements/ImageElement";
            //    prefabPath = "LoveDiary/Prefabs/LoveDiaryEditRacketItem";
            break;

        case ElementTypePB.Bg:
            _editContains.GetChild(0).GetComponent <BgElememt>()
            .SetData(diaryElementPB, _editContains.GetComponent <RectTransform>());
            SetBgElement(diaryElementPB.ElementId);
            return;

        case ElementTypePB.Text:
            prefabPath = "LoveDiary/Prefabs/Elements/WordElement";
            break;

        default:
            return;
        }

        var prefab = GetPrefab(prefabPath);
        var item   = Instantiate(prefab) as GameObject;

        item.transform.SetParent(_editContains, false);
        item.transform.localScale  = Vector3.one;
        item.transform.eulerAngles = Vector3.zero;
        item.GetComponent <DiaryElementBase>().SetData(diaryElementPB, _editContains.GetComponent <RectTransform>());
        if (immidiateInput)
        {
            _curClickElement = item;
            _curClickElement.GetComponent <DiaryElementBase>().loveDiaryEditType = LoveDiaryEditType.Edit;
            _curBottomEditType = LoveDiaryBottomEditType.SecondText;
        }

        UIEventListener.Get(item).onClick = OnClickElememtItem;
        return;
    }