Esempio n. 1
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;
                }
            }
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }