Example #1
0
        /// <summary>
        ///     获得固定高度状态下,不规律的item的位置
        /// </summary>
        /// <param name="previousItem">上一个item的信息</param>
        /// <param name="fixedHeight">固定的高度</param>
        /// <param name="itemWidth">当前item的宽度</param>
        /// <returns></returns>
        public Vector2 GetPositionOfIrregularItemByFixedHeight(ItemPositionInfoBean currentItem, int fixedHeight, int itemWidth, int row)
        {
            int gap = GetGap();
            int x;

            x = currentItem.xposition + gap / 2 + itemWidth / 2;

            int y = row * (fixedHeight + gap) + fixedHeight / 2 + gap;

            return(new Vector2(x, y));
        }
Example #2
0
        private void FillAgents(DataTypeEnum dataType)
        {
            //Debug.Log("Fill Agents");

            float gap = _displayBehaviorConfig.sceneUtils.GetGap();

            // 获取右侧最小的距离
            var columnAgentsDic = _displayBehaviorConfig.columnAgentsDic;

            // 查看每一列顶部是否已低于阈值
            int column = 0;    // 最短的列下表
            int last_y = int.MaxValue;
            ItemPositionInfoBean bean = new ItemPositionInfoBean();

            foreach (KeyValuePair <int, ItemPositionInfoBean> keyValuePair in columnAgentsDic)
            {
                if (keyValuePair.Value.yposition < last_y)
                {
                    last_y = keyValuePair.Value.yposition;
                    column = keyValuePair.Key;
                    bean   = keyValuePair.Value;
                }
            }


            // 定义偏差值 (因实际运行时会出现延时)
            float deviationValue = _displayBehaviorConfig.sceneUtils.GetFixedItemWidth() / 2;

            // 超过屏幕的距离
            float overDistense = last_y - Screen.height - deviationValue;

            if ((overDistense - _manager.PanelOffsetY) < 0)
            {
                if (flag == false)
                {
                    flag = true;
                    int itemwidth = _displayBehaviorConfig.sceneUtils.GetFixedItemWidth();


                    //在该列上补充一个
                    //FlockData data = _daoService.GetFlockData(dataType);
                    FlockData data        = _daoService.GetFlockDataByScene(dataType, _manager.SceneIndex);
                    Sprite    coverSprite = data.GetCoverSprite();
                    int       itemHeight  = Mathf.RoundToInt(AppUtils.GetSpriteHeightByWidth(coverSprite, itemwidth));

                    float ori_x = _displayBehaviorConfig.sceneUtils.GetXPositionByFixedWidth(itemwidth, column);
                    float ori_y = Mathf.RoundToInt(last_y + itemHeight / 2);

                    int row = bean.row + 1;

                    // 创建agent
                    //FlockAgent go = _displayBehaviorConfig.ItemsFactory.Generate(ori_x, ori_y, ori_x, ori_y, row, column,
                    //         itemwidth, itemHeight, data, AgentContainerType.MainPanel);

                    FlockAgent go = FlockAgentFactoryInstance.Generate(_manager, new Vector2(ori_x, ori_y), AgentContainerType.MainPanel
                                                                       , ori_x, ori_y, row, column, itemwidth, itemHeight, data, _displayBehaviorConfig.sceneConfig.daoTypeEnum);
                    go.flockStatus = FlockStatusEnum.NORMAL;


                    go.NextVector2 = new Vector2(ori_x, ori_y);


                    // 完成创建更新字典
                    last_y = Mathf.RoundToInt(last_y + itemHeight + gap);
                    _displayBehaviorConfig.columnAgentsDic[column].yposition = last_y;
                    _displayBehaviorConfig.columnAgentsDic[column].row       = row;
                    flag = false;
                }
            }
        }
Example #3
0
        private void CreateItem(DataTypeEnum dataType)
        {
            //  获取持续时间
            _entranceDisplayTime      = _manager.cutEffectConfig.CurveStaggerDisplayDurTime;
            _startingTimeWithOutDelay = _entranceDisplayTime;

            //  初始化 config
            _displayBehaviorConfig = new DisplayBehaviorConfig();
            _sceneUtil             = new SceneUtils(_manager, _sceneConfig.isKinect);


            // 固定高度
            int _row = _manager.managerConfig.Row;

            if (_sceneConfig.isKinect == 1)
            {
                _row = _manager.managerConfig.KinectRow;
            }

            int   _itemHeight = _sceneUtil.GetFixedItemHeight();
            float gap         = _sceneUtil.GetGap();

            int   _nearColumn = Mathf.RoundToInt(_manager.mainPanel.rect.width / (_itemHeight + gap));
            float w           = _manager.mainPanel.rect.width;


            // 从上至下,生成
            for (int row = 0; row < _row; row++)
            {
                int column = 0;

                ItemPositionInfoBean itemPositionInfoBean;
                if (_displayBehaviorConfig.rowAgentsDic.ContainsKey(row))
                {
                    itemPositionInfoBean = _displayBehaviorConfig.rowAgentsDic[row];
                }
                else
                {
                    itemPositionInfoBean = new ItemPositionInfoBean();
                    _displayBehaviorConfig.rowAgentsDic.Add(row, itemPositionInfoBean);
                }

                int gen_x_position = itemPositionInfoBean.xposition;

                while (gen_x_position < _manager.mainPanel.rect.width)
                {
                    // 获取数据
                    //FlockData data = _daoService.GetFlockData(dataType);
                    FlockData data        = _daoService.GetFlockDataByScene(dataType, _manager.SceneIndex);
                    Sprite    coverSprite = data.GetCoverSprite();
                    float     itemWidth   = AppUtils.GetSpriteWidthByHeight(coverSprite, _itemHeight);

                    int ori_y = Mathf.RoundToInt(_sceneUtil.GetYPositionByFixedHeight(_itemHeight, row));
                    int ori_x = Mathf.RoundToInt(gen_x_position + itemWidth / 2 + gap / 2);

                    int middleY = _row / 2;
                    int middleX = _nearColumn / 2;

                    float delayX = column * 0.06f;
                    float delayY;

                    // 定义源位置
                    float gen_x, gen_y;

                    if (row < middleY)
                    {
                        delayY = System.Math.Abs(middleY - row) * 0.3f;
                        gen_x  = w + (middleY - row) * 500;
                        gen_y  = w - ori_x + (_row - 1) * _itemHeight;
                    }
                    else
                    {
                        delayY = (System.Math.Abs(middleY - row) + 1) * 0.3f;
                        gen_x  = w + (row - middleY + 1) * 500;
                        gen_y  = -(w - ori_x) + 2 * _itemHeight;
                    }

                    //生成 agent
                    Vector2    genPosition = new Vector2(gen_x, gen_y);
                    FlockAgent go          = FlockAgentFactoryInstance.Generate(_manager, genPosition, AgentContainerType.MainPanel
                                                                                , ori_x, ori_y, row, column, itemWidth, _itemHeight, data, _sceneConfig.daoTypeEnum);
                    go.flockStatus = FlockStatusEnum.RUNIN;

                    // 装载延迟参数
                    go.DelayX = delayX;
                    go.DelayY = delayY;

                    // 生成透明度动画
                    go.GetComponentInChildren <Image>().DOFade(0, _entranceDisplayTime - delayX + delayY).From();

                    // 获取启动动画的延迟时间
                    if ((delayY - delayX) > _startDelayTime)
                    {
                        _startDelayTime = delayY - delayX;
                    }

                    gen_x_position = Mathf.RoundToInt(gen_x_position + itemWidth + gap / 2);
                    _displayBehaviorConfig.rowAgentsDic[row].xposition    = gen_x_position;
                    _displayBehaviorConfig.rowAgentsDic[row].xPositionMin = 0;
                    _displayBehaviorConfig.rowAgentsDic[row].column       = column;

                    column++;
                }
            }

            _entranceDisplayTime += _startDelayTime;

            _displayBehaviorConfig.dataType    = _dataTypeEnum;
            _displayBehaviorConfig.Manager     = _manager;
            _displayBehaviorConfig.sceneUtils  = _sceneUtil;
            _displayBehaviorConfig.sceneConfig = _sceneConfig;

            _onCreateAgentCompleted.Invoke(_displayBehaviorConfig);
        }
Example #4
0
        /// <summary>
        /// 创建代理
        /// </summary>
        private void CreateItem(DataTypeEnum dataType)
        {
            //  获取持续时间
            _entranceDisplayTime      = _manager.cutEffectConfig.UpDownDisplayDurTime;
            _startingTimeWithOutDelay = _entranceDisplayTime;

            //  初始化 config
            _displayBehaviorConfig = new DisplayBehaviorConfig();
            _sceneUtil             = new SceneUtils(_manager, _sceneConfig.isKinect);

            //int _column = _manager.managerConfig.Column;


            int _column = 0;

            if (_sceneConfig.isKinect == 0)
            {
                _column = _manager.managerConfig.Column;
            }
            else
            {
                _column = _manager.managerConfig.KinectColumn;
            }


            int   _itemWidth = _sceneUtil.GetFixedItemWidth();
            float gap        = _sceneUtil.GetGap();

            //从下往上,从左往右
            for (int j = 0; j < _column; j++)
            {
                int row = 0;
                // 获取该列的 gen_y

                ItemPositionInfoBean itemPositionInfoBean;
                if (_displayBehaviorConfig.columnAgentsDic.ContainsKey(j))
                {
                    itemPositionInfoBean = _displayBehaviorConfig.columnAgentsDic[j];
                }
                else
                {
                    itemPositionInfoBean = new ItemPositionInfoBean();
                    _displayBehaviorConfig.columnAgentsDic.Add(j, itemPositionInfoBean);
                }

                int gen_y_position = itemPositionInfoBean.yposition;

                while (gen_y_position < _manager.mainPanel.rect.height)
                {
                    // 获取数据
                    //FlockData data = _daoService.GetFlockData(dataType);
                    FlockData data = _daoService
                                     .GetFlockDataByScene(dataType, _manager.SceneIndex);

                    Sprite coverSprite = data.GetCoverSprite();
                    float  itemHeigth  = AppUtils.GetSpriteHeightByWidth(coverSprite, _itemWidth);

                    int ori_x = Mathf.RoundToInt(_sceneUtil.GetXPositionByFixedWidth(_itemWidth, j));
                    int ori_y = Mathf.RoundToInt(gen_y_position + itemHeigth / 2);

                    // 获取出生位置
                    float gen_x, gen_y;

                    // 计算移动的目标位置
                    if (j % 2 == 0)
                    {
                        //偶数列向下偏移itemHeight
                        gen_y = ori_y - (itemHeigth + gap);
                    }
                    else
                    {
                        //奇数列向上偏移itemHeight
                        gen_y = ori_y + itemHeigth + gap;
                    }
                    gen_x = ori_x; //横坐标不变

                    // 创建agent
                    //FlockAgent go = ItemsFactory.Generate(gen_x, gen_y, ori_x, ori_y, row, j,
                    //         _itemWidth, itemHeigth, data, AgentContainerType.MainPanel);
                    //go.NextVector2 = new Vector2(gen_x, gen_y);
                    FlockAgent go = FlockAgentFactoryInstance.Generate(_manager, new Vector2(gen_x, gen_y), AgentContainerType.MainPanel
                                                                       , ori_x, ori_y, row, j, _itemWidth, itemHeigth, data, _sceneConfig.daoTypeEnum);
                    go.flockStatus = FlockStatusEnum.RUNIN;

                    gen_y_position = Mathf.RoundToInt(gen_y_position + itemHeigth + gap);
                    _displayBehaviorConfig.columnAgentsDic[j].yposition    = gen_y_position;
                    _displayBehaviorConfig.columnAgentsDic[j].xPositionMin = Mathf.RoundToInt(0 - gap);
                    _displayBehaviorConfig.columnAgentsDic[j].yPositionMin = Mathf.RoundToInt(0 - gap);
                    _displayBehaviorConfig.columnAgentsDic[j].row          = row;
                    row++;
                }
            }

            _displayBehaviorConfig.dataType    = _dataTypeEnum;
            _displayBehaviorConfig.Manager     = _manager;
            _displayBehaviorConfig.sceneUtils  = _sceneUtil;
            _displayBehaviorConfig.sceneConfig = _sceneConfig;

            _onCreateAgentCompleted.Invoke(_displayBehaviorConfig);
        }
Example #5
0
        /// <summary>
        ///     补充内容
        /// </summary>
        /// <param name="dataType"></param>
        private void FillItem(DataTypeEnum dataType)
        {
            float gap = _displayBehaviorConfig.sceneUtils.GetGap();

            // 获取右侧最小的距离
            var rowDic = _displayBehaviorConfig.rowAgentsDic;

            int row    = 0; // 最短行长的行值
            int last_x = int.MaxValue;


            ItemPositionInfoBean bean = new ItemPositionInfoBean();

            foreach (KeyValuePair <int, ItemPositionInfoBean> keyValuePair in rowDic)
            {
                if (keyValuePair.Value.xposition < last_x)
                {
                    last_x = keyValuePair.Value.xposition;
                    row    = keyValuePair.Key;
                    bean   = keyValuePair.Value;
                }
            }


            float deviationValue = _displayBehaviorConfig.sceneUtils.GetFixedItemHeight() / 2;

            // 超过屏幕的距离
            float overDistense = last_x - deviationValue - _manager.mainPanel.rect.width;

            if ((overDistense - _manager.PanelOffsetX) < 0)
            {
                if (flag == false)
                {
                    // 该行添加内容
                    //FlockData data = _manager.daoService.GetFlockData(dataType);
                    FlockData data        = _daoService.GetFlockDataByScene(dataType, _manager.SceneIndex);
                    Sprite    spriteImage = data.GetCoverSprite();

                    int itemHeight = _displayBehaviorConfig.sceneUtils.GetFixedItemHeight();
                    int itemWidth  = Mathf.RoundToInt(AppUtils.GetSpriteWidthByHeight(spriteImage, itemHeight));


                    // 拿位置
                    float gen_y = _displayBehaviorConfig.sceneUtils.GetYPositionByFixedHeight(itemHeight, row);
                    float gen_x = last_x + itemWidth / 2 + gap / 2;

                    // 生成 agent
                    //FlockAgent go = _displayBehaviorConfig.ItemsFactory.Generate(gen_x, gen_y, gen_x, gen_y
                    //    , row, bean.column + 1, itemWidth, itemHeight, data, AgentContainerType.MainPanel);

                    FlockAgent go = FlockAgentFactoryInstance.Generate(_manager, new Vector2(gen_x, gen_y), AgentContainerType.MainPanel
                                                                       , gen_x, gen_y, row, bean.column + 1, itemWidth, itemHeight, data, _displayBehaviorConfig.sceneConfig.daoTypeEnum);
                    go.flockStatus = FlockStatusEnum.NORMAL;

                    go.NextVector2 = new Vector2(gen_x, gen_y);

                    last_x                = Mathf.RoundToInt(last_x + itemWidth + gap / 2);
                    rowDic[row].column    = bean.column + 1;
                    rowDic[row].xposition = last_x;
                }
            }
        }
Example #6
0
        /// <summary>
        /// 创建代理
        /// </summary>
        private void CreateItem(DataTypeEnum dataType)
        {
            //Debug.Log("开始加载左右动画");
            //  获取持续时间
            _entranceDisplayTime      = _manager.cutEffectConfig.LeftRightDisplayDurTime;
            _startingTimeWithOutDelay = _entranceDisplayTime;

            //  初始化 config
            _displayBehaviorConfig = new DisplayBehaviorConfig();
            _sceneUtil             = new SceneUtils(_manager, _sceneConfig.isKinect);

            // 固定高度
            int   _row        = row_set;
            int   _itemHeight = _sceneUtil.GetFixedItemHeight();
            float gap         = _sceneUtil.GetGap();

            int   _nearColumn = Mathf.RoundToInt(_manager.mainPanel.rect.width / (_itemHeight + gap));
            float w           = _manager.mainPanel.rect.width;

            float _maxDelayTime = 0f;


            // 从上至下,生成
            for (int row = 0; row < _row; row++)
            {
                int column = 0;

                ItemPositionInfoBean itemPositionInfoBean;
                if (_displayBehaviorConfig.rowAgentsDic.ContainsKey(row))
                {
                    itemPositionInfoBean = _displayBehaviorConfig.rowAgentsDic[row];
                }
                else
                {
                    itemPositionInfoBean = new ItemPositionInfoBean();
                    _displayBehaviorConfig.rowAgentsDic.Add(row, itemPositionInfoBean);
                }

                int gen_x_position = itemPositionInfoBean.xposition;

                while (gen_x_position < _manager.mainPanel.rect.width)
                {
                    // 获取数据
                    //FlockData data = _daoService.GetFlockData(dataType);
                    FlockData data        = _daoService.GetFlockDataByScene(dataType, _manager.SceneIndex);
                    Sprite    coverSprite = data.GetCoverSprite();
                    float     itemWidth   = AppUtils.GetSpriteWidthByHeight(coverSprite, _itemHeight);

                    int ori_y = Mathf.RoundToInt(_sceneUtil.GetYPositionByFixedHeight(_itemHeight, row));
                    int ori_x = Mathf.RoundToInt(gen_x_position + itemWidth / 2 + gap / 2);

                    // 获取参照点
                    int middleY = _row / 2;
                    int middleX = _nearColumn / 2;

                    // 定义出生位置
                    float gen_x, gen_y;

                    // 计算出生位置与延时时间
                    float delay;

                    int maxYOffset = System.Math.Abs(middleY - _row);
                    int nowYOffset;

                    if (row < middleY)
                    {
                        nowYOffset = System.Math.Abs(middleY - row);
                        //delay = (System.Math.Abs(middleY - row)) * _manager.cutEffectConfig.LeftRightGapTime;
                        gen_x = ori_x + w;
                    }
                    else
                    {
                        nowYOffset = System.Math.Abs(middleY - row) + 1;
                        //delay = (System.Math.Abs(middleY - row) + 1) * _manager.cutEffectConfig.LeftRightGapTime;
                        gen_x = ori_x - w - 500;
                    }

                    float f = (float )nowYOffset / (float)maxYOffset;
                    //Debug.Log("f : " + f);
                    Func <float, float> lrfun = EasingFunction.Get(_manager.cutEffectConfig.LeftRightGapEaseEnum);
                    f = lrfun(f);

                    delay = Mathf.Lerp(0, maxYOffset * _manager.cutEffectConfig.LeftRightGapTime, f);

                    gen_y = ori_y; //纵坐标不变

                    //生成 agent
                    Vector2    genPosition = new Vector2(gen_x, gen_y);
                    FlockAgent go          = FlockAgentFactoryInstance.Generate(_manager, genPosition, AgentContainerType.MainPanel
                                                                                , ori_x, ori_y, row, column, itemWidth, _itemHeight, data, _sceneConfig.daoTypeEnum);
                    go.flockStatus = FlockStatusEnum.RUNIN;

                    go.Delay     = delay;
                    go.DelayTime = delay;

                    if (delay > _maxDelayTime)
                    {
                        _maxDelayTime = delay;
                    }

                    gen_x_position = Mathf.RoundToInt(gen_x_position + itemWidth + gap / 2);
                    _displayBehaviorConfig.rowAgentsDic[row].xposition    = gen_x_position;
                    _displayBehaviorConfig.rowAgentsDic[row].xPositionMin = 0;
                    _displayBehaviorConfig.rowAgentsDic[row].column       = column;

                    column++;
                }
            }

            _entranceDisplayTime += _startDelayTime;

            _displayBehaviorConfig.dataType    = _dataTypeEnum;
            _displayBehaviorConfig.Manager     = _manager;
            _displayBehaviorConfig.sceneUtils  = _sceneUtil;
            _displayBehaviorConfig.sceneConfig = _sceneConfig;


            _onCreateAgentCompleted.Invoke(_displayBehaviorConfig);
        }
Example #7
0
        private void CreateItem(DataTypeEnum dataType)
        {
            //  获取持续时间
            _entranceDisplayTime      = _manager.cutEffectConfig.LeftRightDisplayDurTime;
            _startingTimeWithOutDelay = _entranceDisplayTime;

            //  初始化 config
            _displayBehaviorConfig = new DisplayBehaviorConfig();
            _sceneUtil             = new SceneUtils(_manager, _sceneConfig.isKinect);

            List <FlockAgent> agents = new List <FlockAgent>();

            _displayBehaviorConfig.dataType   = dataType;
            _displayBehaviorConfig.sceneUtils = _sceneUtil;


            int _column = 0;

            if (_sceneConfig.isKinect == 0)
            {
                _column = _manager.managerConfig.Column;
            }
            else
            {
                _column = _manager.managerConfig.KinectColumn;
            }

            int   _itemWidth = _sceneUtil.GetFixedItemWidth();
            float gap        = _sceneUtil.GetGap();


            int middleX = _column / 2;

            //从下往上,从左往右
            for (int j = 0; j < _column; j++)
            {
                int row = 0;

                // 获取该列的 gen_y
                ItemPositionInfoBean itemPositionInfoBean;
                if (_displayBehaviorConfig.columnAgentsDic.ContainsKey(j))
                {
                    itemPositionInfoBean = _displayBehaviorConfig.columnAgentsDic[j];
                }
                else
                {
                    itemPositionInfoBean = new ItemPositionInfoBean();
                    _displayBehaviorConfig.columnAgentsDic.Add(j, itemPositionInfoBean);
                }

                int gen_y_position = itemPositionInfoBean.yposition;
                int ori_x          = Mathf.RoundToInt(_sceneUtil.GetXPositionByFixedWidth(_itemWidth, j));

                while (gen_y_position < _manager.mainPanel.rect.height)
                {
                    // 获取数据
                    //FlockData data = _daoService.GetFlockData(dataType);
                    FlockData data        = _daoService.GetFlockDataByScene(dataType, _manager.SceneIndex);
                    Sprite    coverSprite = data.GetCoverSprite();
                    float     itemHeigth  = AppUtils.GetSpriteHeightByWidth(coverSprite, _itemWidth);

                    int ori_y = Mathf.RoundToInt(gen_y_position + itemHeigth / 2);

                    float minDelay = 0;
                    //float maxDelay = middleX * 0.05f;
                    float maxDelay = _manager.cutEffectConfig.MidDisperseDelayMax;
                    int   offset   = Mathf.Abs(middleX - j);

                    float k = (float)offset / (float)middleX;
                    Func <float, float> easeFunction = EasingFunction.Get(_manager.cutEffectConfig.MidDisperseMoveEaseEnum);
                    k = easeFunction(k);

                    //float delay = Mathf.Lerp(minDelay, maxDelay, k);
                    float delay = 0;
                    float gen_x, gen_y;

                    gen_x = middleX * (_itemWidth + gap) + (_itemWidth / 2);
                    gen_y = ori_y + itemHeigth / 3
                            + itemHeigth * _manager.cutEffectConfig.MidDisperseHeightFactor;

                    // 创建agent
                    //FlockAgent go = ItemsFactory.Generate(gen_x, gen_y, ori_x, ori_y, row, j,
                    //         _itemWidth, itemHeigth, data, AgentContainerType.MainPanel);

                    FlockAgent go = FlockAgentFactoryInstance.Generate(_manager, new Vector2(gen_x, gen_y), AgentContainerType.MainPanel
                                                                       , ori_x, ori_y, row, j, _itemWidth, itemHeigth, data, _sceneConfig.daoTypeEnum);

                    go.flockStatus = FlockStatusEnum.RUNIN;

                    // 初始化透明度
                    go.UpdateImageAlpha(0.1f);

                    go.Delay = delay;
                    agents.Add(go);
                    //go.UpdateImageAlpha(1f - Mathf.Abs(j - middleX)*0.05f);
                    if (delay > _startDelayTime)
                    {
                        _startDelayTime = delay;
                    }

                    gen_y_position = Mathf.RoundToInt(gen_y_position + itemHeigth + gap);
                    _displayBehaviorConfig.columnAgentsDic[j].yposition = gen_y_position;
                    _displayBehaviorConfig.columnAgentsDic[j].row       = row;
                    row++;
                }
            }

            // 调整显示的前后
            agents.Sort((x, y) =>
            {
                return(Mathf.Abs(x.Y - middleX).CompareTo(Mathf.Abs(y.Y - middleX)));
            });

            for (int i = 0; i < agents.Count; i++)
            {
                agents[i].GetComponent <RectTransform>().SetAsFirstSibling();
            }


            // 调整启动动画的时间
            _entranceDisplayTime = _startingTimeWithOutDelay + _startDelayTime + 0.05f;

            _displayBehaviorConfig.dataType    = _dataTypeEnum;
            _displayBehaviorConfig.Manager     = _manager;
            _displayBehaviorConfig.sceneUtils  = _sceneUtil;
            _displayBehaviorConfig.sceneConfig = _sceneConfig;


            _onCreateAgentCompleted.Invoke(_displayBehaviorConfig);
        }