Ejemplo n.º 1
0
        public void Init(OperateCardDataCross data, Action <ScrollData, CrossCardNavType, ScrollDirectionEnum> onChanged, Action <string> onScale, Action <string, string, string> onPlayVideo)
        {
            _isPrepared  = false;
            _data        = data;
            _manager     = GameObject.Find("MagicWall").GetComponent <MagicWallManager>();
            _onChanged   = onChanged;
            _onScale     = onScale;
            _onPlayVideo = onPlayVideo;

            _scrollPanelAgents = new List <ScrollPanelAgent>();
            _scrollPanelAgents.Add(_scrollPanelTop);
            _scrollPanelAgents.Add(_scrollPanelBottom);
            _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.ScrollDic[CrossCardNavType.Index];

            _scrollPanelMiddle.SetData(firstData[0]);

            // 初始化内容
            _currentNavType = CrossCardNavType.Index;
            _index          = 0;
            _navIndex       = 0;
        }
Ejemplo n.º 2
0
 private static bool CheckIsSimple(OperateCardDataCross operateCardDataCross)
 {
     if (operateCardDataCross.ScrollDic != null && operateCardDataCross.ScrollDic.Count > 1)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 3
0
        public override void InitData(OperateCardData operateCardData)
        {
            OperateCardDataCross operateCardDataCross = (OperateCardDataCross)operateCardData;

            _cardData = operateCardDataCross;

            var _navList = new List <CrossCardNavType>();

            _navList.Add(CrossCardNavType.Index);

            if (operateCardDataCross.ScrollDic.ContainsKey(CrossCardNavType.CataLog))
            {
                _navList.Add(CrossCardNavType.CataLog);
            }

            if (operateCardDataCross.ScrollDic.ContainsKey(CrossCardNavType.Product))
            {
                _navList.Add(CrossCardNavType.Product);
            }

            if (operateCardDataCross.ScrollDic.ContainsKey(CrossCardNavType.Activity))
            {
                _navList.Add(CrossCardNavType.Activity);
            }

            if (operateCardDataCross.ScrollDic.ContainsKey(CrossCardNavType.Video))
            {
                _navList.Add(CrossCardNavType.Video);
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

            InitAgency();
            _questionTypeEnum = QuestionTypeEnum.CrossCard;

            _crossScrollAgent.Init(_cardData, (data, navtype, scrollDirection) => {
                DoUpdate();
                Debug.Log("Has Changed : [NAV]" + navtype + "[data]" + data);
                UpdateDescription(data.Description);

                if (scrollDirection == ScrollDirectionEnum.Left)
                {
                    _scrollBarAgent.TurnLeft();
                }
                else if (scrollDirection == ScrollDirectionEnum.Right)
                {
                    _scrollBarAgent.TurnRight();
                }
            }, OnClickScale, DoVideo);

            InitUI();

            _scrollBarAgent.Init(_navList, (dir) => {
            });
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        public static OperateCardDataCross Transfer(Enterprise enterprise, List <Activity> activities,
                                                    List <Product> products, List <Video> videos, List <Catalog> catalogs)
        {
            if (enterprise == null)
            {
                return(null);
            }

            OperateCardDataCross operateCardDataCross = new OperateCardDataCross();

            operateCardDataCross.Id          = enterprise.Ent_id;
            operateCardDataCross.Title       = enterprise.Name;
            operateCardDataCross.Cover       = enterprise.Business_card;
            operateCardDataCross.DataType    = DataTypeEnum.Enterprise;
            operateCardDataCross.Description = enterprise.Description;

            // index;
            Dictionary <CrossCardNavType, List <ScrollData> > dics = new Dictionary <CrossCardNavType, List <ScrollData> > ();

            List <ScrollData> list       = new List <ScrollData>();
            ScrollData        scrollData = new ScrollData();

            scrollData.Cover = enterprise.Business_card;
            scrollData.Type  = 0;
            list.Add(scrollData);
            dics.Add(CrossCardNavType.Index, list);

            // category
            if (catalogs != null && catalogs.Count > 0)
            {
                List <ScrollData> categoryList = new List <ScrollData>();
                for (int i = 0; i < catalogs.Count; i++)
                {
                    var        cat = catalogs[i];
                    ScrollData sd  = new ScrollData();
                    sd.Type        = 0;
                    sd.Cover       = cat.Img;
                    sd.Description = cat.Description;
                    categoryList.Add(sd);
                }
                dics.Add(CrossCardNavType.CataLog, categoryList);
            }

            // product
            if (products != null && products.Count > 0)
            {
                List <ScrollData> l = new List <ScrollData>();
                for (int i = 0; i < products.Count; i++)
                {
                    var        prod = products[i];
                    ScrollData sd   = new ScrollData();
                    sd.Type        = 0;
                    sd.Cover       = prod.Image;
                    sd.Description = prod.Description;
                    l.Add(sd);
                }
                dics.Add(CrossCardNavType.Product, l);
            }

            // activity
            if (activities != null && activities.Count > 0)
            {
                List <ScrollData> l = new List <ScrollData>();
                for (int i = 0; i < activities.Count; i++)
                {
                    var        data = activities[i];
                    ScrollData sd   = new ScrollData();
                    sd.Type        = 0;
                    sd.Cover       = data.Image;
                    sd.Description = data.Description;
                    l.Add(sd);
                }
                dics.Add(CrossCardNavType.Activity, l);
            }

            // video
            if (videos != null && videos.Count > 0)
            {
                List <ScrollData> l = new List <ScrollData>();
                for (int i = 0; i < videos.Count; i++)
                {
                    var        data = videos[i];
                    ScrollData sd   = new ScrollData();
                    sd.Type        = 1;
                    sd.Cover       = data.Cover;
                    sd.Src         = data.Address;
                    sd.Description = data.Description;
                    l.Add(sd);
                }
                dics.Add(CrossCardNavType.Video, l);
            }

            operateCardDataCross.ScrollDic = dics;


            return(operateCardDataCross);
        }