Exemple #1
0
        public void Init(OperateCardDataSlide data, Action <ScrollData, ScrollDirectionEnum> onChanged,
                         Action <string> onScale, Action <string, string, string> onPlayVideo, Action onInitCompleted)
        {
            _isPrepared      = false;
            _data            = data;
            _manager         = GameObject.Find("MagicWall").GetComponent <MagicWallManager>();
            _onChanged       = onChanged;
            _onScale         = onScale;
            _onPlayVideo     = onPlayVideo;
            _onInitCompleted = onInitCompleted;

            _scrollPanelAgents = new List <SliceScrollPanelAgent>();
            _scrollPanelAgents.Add(_scrollPanelLeft);
            _scrollPanelAgents.Add(_scrollPanelRight);
            _scrollPanelAgents.Add(_scrollPanelMiddle);
            _scrollPanelAgents.Add(_scrollPanelPrepare);
            for (int i = 0; i < _scrollPanelAgents.Count; i++)
            {
                _scrollPanelAgents[i].Init(this);
            }

            // 设置首图
            var firstData = data.ScrollData[0];

            _scrollPanelMiddle.SetData(firstData);


            // 初始化内容
            _index = 0;
        }
Exemple #2
0
        public override void InitData(OperateCardData operateCardData)
        {
            OperateCardDataSlide operateCardDataSlide = (OperateCardDataSlide)operateCardData;

            //Debug.Log("Do In slice: " + operateCardDataSlide.Title);
            _data = operateCardDataSlide;

            InitUI();

            // 初始化卡片块
            InitAgency();
            _questionTypeEnum = QuestionTypeEnum.SliceCard;

            _sliceScrollAgent.Init(_data, (data, scrollDirection) => {
                DoUpdate();
                UpdateDescription(data.Description);
                AdjustUILocation();
            }, OnClickScale, DoVideo, () => {
                // scale 部分调整完毕
                //AdjustUI();
                DoUpdate();
                ShowUI();

                var data = operateCardDataSlide.ScrollData[0];
                UpdateDescription(data.Description);
            });

            var extraDatas = operateCardDataSlide.ExtraCardData;

            InitComponents(extraDatas);
        }
Exemple #3
0
        public static OperateCardDataSlide Transfer(Activity activity, Enterprise enterprises)
        {
            if (activity == null)
            {
                return(null);
            }

            OperateCardDataSlide operateCardDataSlide = new OperateCardDataSlide();

            operateCardDataSlide.DataType    = DataTypeEnum.Activity;
            operateCardDataSlide.Cover       = activity.Image;
            operateCardDataSlide.Description = activity.Description;
            operateCardDataSlide.Id          = activity.Id;
            operateCardDataSlide.Title       = activity.Name;


            if (enterprises != null)
            {
                var envcards = enterprises.EnvCards;
                List <ExtraCardData> extraCardDatas = new List <ExtraCardData>();
                for (int i = 0; i < envcards.Count; i++)
                {
                    ExtraCardData extraCardData = new ExtraCardData();
                    extraCardData.Cover = envcards[i];
                    extraCardDatas.Add(extraCardData);
                }
                operateCardDataSlide.ExtraCardData = extraCardDatas;
            }

            var details = activity.ActivityDetails;

            if (details != null && details.Count > 0)
            {
                List <ScrollData> scrollDatas = new List <ScrollData>();

                for (int i = 0; i < details.Count; i++)
                {
                    ScrollData scrollData = new ScrollData();
                    scrollData.Cover       = details[i].Image;
                    scrollData.Type        = details[i].Type;
                    scrollData.Description = details[i].Description;
                    scrollData.Src         = details[i].VideoUrl;
                    scrollDatas.Add(scrollData);
                }
                operateCardDataSlide.ScrollData = scrollDatas;
            }

            return(operateCardDataSlide);
        }
        public static CardAgent Generate(MagicWallManager magicWallManager, Vector3 position
                                         , Transform parent, int dataId, DataTypeEnum dataType, FlockAgent refFlockAgent)
        {
            IDaoService daoService = magicWallManager.daoServiceFactory.GetDaoService(refFlockAgent.daoTypeEnum);

            OperateCardData cardData   = null;
            CardAgent       cardPrefab = null;

            //magicWallManager.daoService.getac
            if (dataType == DataTypeEnum.Enterprise)
            {
                Enterprise enterprise = daoService.GetEnterpriseById(dataId);

                Debug.Log("enterprise : " + (enterprise == null));

                var activities = daoService.GetActivitiesByEnvId(enterprise.Ent_id);
                var products   = daoService.GetProductsByEnvId(enterprise.Ent_id);
                var videos     = daoService.GetVideosByEnvId(enterprise.Ent_id);
                var catalogs   = daoService.GetCatalogs(enterprise.Ent_id);
                OperateCardDataCross operateCardDataCross = EnterpriseAdapter
                                                            .Transfer(enterprise, activities, products, videos, catalogs);
                //Debug.Log(operateCardDataCross.ToString());

                //if (CheckIsSimple(operateCardDataCross))
                //{
                //    cardPrefab = magicWallManager.operateCardManager.singleCardPrefab;
                //    cardData = operateCardDataCross;

                //    Debug.Log("Generate 单个企业卡片");
                //}
                //else
                //{
                cardPrefab = magicWallManager.operateCardManager.crossCardPrefab;
                // 单个卡片的逻辑
                //OperateCardDataSingle operateCardDataSingle = new OperateCardDataSingle();

                // Debug.Log("Generate 正常企业卡片");
                cardData = operateCardDataCross;

                //cardData = (OperateCardDataSingle)operateCardDataCross;
                //}
            }
            else if (dataType == DataTypeEnum.Product || dataType == DataTypeEnum.Wine)
            {
                Product    product    = daoService.GetProductDetail(dataId);
                Enterprise enterprise = daoService.GetEnterpriseById(product.Ent_id);

                Debug.Log("enterprise : " + enterprise);

                //Debug.Log("enterprise to null : " + (enterprise == null));


                OperateCardDataSlide operateCardDataSlide = ProductAdapter.Transfer(product, enterprise);
                cardPrefab = magicWallManager.operateCardManager.sliceCardPrefab;
                cardData   = operateCardDataSlide;
            }
            else
            {
                Activity             activity             = daoService.GetActivityDetail(dataId);
                Enterprise           enterprise           = daoService.GetEnterpriseById(activity.Ent_id);
                OperateCardDataSlide operateCardDataSlide = ActivityAdapter.Transfer(activity, enterprise);
                cardPrefab = magicWallManager.operateCardManager.sliceCardPrefab;
                cardData   = operateCardDataSlide;
            }

            // 创建card
            CardAgent cardAgent = Instantiate(cardPrefab, parent);

            cardAgent.GetComponent <Transform>().position = position;
            //cardAgent.DataId = dataId;
            cardAgent.InitComponent(magicWallManager, dataId, dataType, position, refFlockAgent);
            cardAgent.InitData(cardData);
            return(cardAgent);
        }