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); }