예제 #1
0
        public FlockAgent GetFlockAgent(AgentContainerType type)
        {
            Transform parentContainer;

            if (type == AgentContainerType.MainPanel)
            {
                parentContainer = _flockContainer;
            }
            else if (type == AgentContainerType.BackPanel)
            {
                parentContainer = _backContainer;
            }
            else
            {
                parentContainer = _starContainer;
            }


            FlockAgent agent = Instantiate(_flockAgentPrefab, parentContainer);

            return(agent);



            //if (type == AgentContainerType.MainPanel)
            //{
            //    return _flockAgentPool.GetObj();
            //}
            //else if (type == AgentContainerType.BackPanel)
            //{
            //    return _flockAgentInBackPool.GetObj();
            //}
            //else
            //{
            //    return _flockAgentInStarPool.GetObj();
            //}
        }
예제 #2
0
 /// <summary>
 ///     清理agent
 /// </summary>
 /// <param name="agent"></param>
 private void ClearAgent(FlockAgent agent)
 {
     // 清理出实体袋
     agent.flockStatus = FlockStatusEnum.OBSOLETE;
 }
예제 #3
0
        //
        //  移除效果列表中的项
        //
        public void AddItem(FlockAgent agent)
        {
            _agents.Add(agent);

            _manager.collisionManager.AddCollisionMoveBasicAgent(agent);
        }
예제 #4
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;
                }
            }
        }
예제 #5
0
        private FlockAgent CreateNewAgent(bool randomZ)
        {
            if (!randomZ)
            {
                //Debug.Log("添加星空块。");
            }


            // 获取数据
            //FlockData data = _daoService.GetFlockData(_dataType,_manager);\

            FlockData data = _daoService.GetFlockDataByScene(_dataType, _manager.SceneIndex);

            // 获取出生位置
            Vector2 randomPosition = UnityEngine.Random.insideUnitSphere;

            Vector3 position = new Vector3();

            position.x = (randomPosition.x / 2 + 0.5f) * _manager.GetScreenRect().x;
            position.y = (randomPosition.y / 2 + 0.5f) * _manager.GetScreenRect().y;


            // 获取长宽
            Sprite logoSprite = data.GetCoverSprite();
            float  width      = _sceneUtil.ResetTexture(new Vector2(logoSprite.rect.width, logoSprite.rect.height)).x;
            float  height     = _sceneUtil.ResetTexture(new Vector2(logoSprite.rect.width, logoSprite.rect.height)).y;

            //FlockAgent go = _itemFactory.Generate(position.x, position.y, position.x, position.y, 0, 0,
            // width, height, data, AgentContainerType.StarContainer);
            FlockAgent go = FlockAgentFactoryInstance.Generate(_manager, position, AgentContainerType.StarContainer,
                                                               position.x, position.y, 0, 0, width, height, data, _sceneConfig.daoTypeEnum);

            go.UpdateImageAlpha(0);

            // 星空效果不会被物理特效影响
            //go.CanEffected = false;
            go.flockStatus  = FlockStatusEnum.STAR;
            go.isStarEffect = true;

            // 设置Z轴

            float z;

            if (randomZ)
            {
                z = Mathf.Lerp(_manager.cutEffectConfig.StarEffectOriginPoint, _manager.cutEffectConfig.StarEffectEndPoint,
                               UnityEngine.Random.Range(0f, 1f));
            }
            else
            {
                z = _manager.cutEffectConfig.StarEffectOriginPoint;
            }

            go.GetComponent <RectTransform>().anchoredPosition3D = go.GetComponent <RectTransform>().anchoredPosition3D + new Vector3(0, 0, z);
            go.Z    = z;
            go.name = "Agent-" + Mathf.RoundToInt(go.Z);

            _activeAgents.Add(go);

            return(go);
        }
예제 #6
0
        /// <summary>
        /// REF: https://www.yuque.com/u314548/fc6a5l/dozp0e
        /// </summary>
        /// <param name="flockAgent"></param>
        private void DoChooseForKinect(FlockAgent flockAgent)
        {
            int _data_id  = flockAgent.DataId;
            var _dataType = flockAgent.dataTypeEnum;

            CardAgent _cardAgent;

            if (CanChoose(flockAgent))
            {
                flockAgent.flockStatus = FlockStatusEnum.TOHIDE;

                var           flockAgentPosition = flockAgent.GetComponent <RectTransform>().transform.position;
                RectTransform flockRect          = flockAgent.GetComponent <RectTransform>();

                // 获取kinect obj 的位置
                var         agents            = _manager.kinectManager.kinectAgents;
                var         distance          = 3000f;
                KinectAgent targetKinectAgent = null;
                for (int i = 0; i < agents.Count; i++)
                {
                    var kinectPosition = agents[i].GetComponent <RectTransform>().transform.position;
                    var d = Vector2.Distance(kinectPosition, flockAgentPosition);

                    // 添加了安全距离
                    if (d < distance && d < 1500f)
                    {
                        targetKinectAgent = agents[i];
                        distance          = d;
                    }
                }


                if (targetKinectAgent == null)
                {
                    flockAgent.flockStatus = FlockStatusEnum.NORMAL;
                    DoChooseForCommon(flockAgent);
                    return;
                }


                /// 遮罩中存在贴附的卡片
                if (targetKinectAgent.refFlockAgent != null)
                {
                    var refFlockAgent = targetKinectAgent.refFlockAgent;
                    targetKinectAgent.RecoverColliderEffect();

                    RemoveRefCard(targetKinectAgent.refFlockAgent);
                }

                targetKinectAgent.refFlockAgent = flockAgent;

                if (targetKinectAgent.status == KinectAgentStatusEnum.Small)
                {
                    // 恢复大小并打开检测
                    targetKinectAgent.SetDisableEffect(false);
                    targetKinectAgent.status = KinectAgentStatusEnum.Recovering;
                    targetKinectAgent.GetComponent <RectTransform>().DOScale(1f, 0.5f).OnComplete(
                        () => {
                        targetKinectAgent.status = KinectAgentStatusEnum.Hide;
                    }
                        );
                }

                if (targetKinectAgent.status == KinectAgentStatusEnum.Destoring)
                {
                    targetKinectAgent.SetDisableEffect(false);
                    targetKinectAgent.CancelClose();
                }

                // 点击的卡片移动至遮罩位置,生成卡片并放大

                targetKinectAgent.status = KinectAgentStatusEnum.WaitingHiding;
                targetKinectAgent.SetDisableEffect(false);

                var ani_time = 1.5f;
                var scaleAni = flockAgent.transform.DOScale(new Vector3(0.2f, 0.2f, 0.2f), ani_time - 0.2f);
                var moveAni  = flockAgent.transform.DOMove(targetKinectAgent.transform.position, ani_time)
                               .OnUpdate(() => {})
                               .OnComplete(() => {
                    flockAgent.transform.SetParent(_manager.OperationPanel);

                    targetKinectAgent.Hide();
                    flockAgent.flockStatus = FlockStatusEnum.HIDE;
                    flockAgent.gameObject.SetActive(false);

                    var _cardGenPos = flockAgent.GetComponent <RectTransform>().anchoredPosition;

                    // 创建卡片
                    _cardAgent = _manager.operateCardManager.CreateNewOperateCard(_data_id, _dataType, _cardGenPos, flockAgent);
                    _cardAgent.SetDisableEffect(true);

                    _cardAgent.GoToFront(() => {
                        _cardAgent.SetDisableEffect(false);
                        //targetKinectAgent.SetDisableEffect(true);
                    });
                });

                flockAgent.flockTweenerManager.Add(FlockTweenerManager.Kinnect_Choose_Scale, scaleAni);
                flockAgent.flockTweenerManager.Add(FlockTweenerManager.Kinnect_Choose_Move, moveAni);
            }
        }
예제 #7
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);
        }
예제 #8
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);
        }
예제 #9
0
        private void DoChooseForCommon(FlockAgent flockAgent)
        {
            int _data_id  = flockAgent.DataId;
            var _dataType = flockAgent.dataTypeEnum;

            CardAgent _cardAgent;

            if (CanChoose(flockAgent))
            {
                flockAgent.flockStatus = FlockStatusEnum.TOHIDE;

                //_isChoosing = true;

                //  先缩小(向后退)
                RectTransform rect = flockAgent.GetComponent <RectTransform>();
                Vector2       positionInMainPanel = rect.anchoredPosition;

                //  移到后方、缩小、透明
                //rect.DOScale(0.1f, 0.3f);
                Vector3 to = new Vector3(0.2f, 0.2f, 0.7f);

                var _cardGenPos = GetCardGeneratePosition(flockAgent);

                // 完成缩小与移动后创建十字卡片
                rect.DOScale(0.5f, 0.3f).OnComplete(() =>
                {
                    flockAgent.flockStatus = FlockStatusEnum.HIDE;
                    flockAgent.gameObject.SetActive(false);

                    //Debug.Log("chose :" + _data_id);

                    _cardAgent = _manager.operateCardManager.CreateNewOperateCard(_data_id, _dataType, _cardGenPos, flockAgent);


                    //靠近四周边界需要偏移
                    float w = _cardAgent.GetComponent <RectTransform>().rect.width;
                    float h = _cardAgent.GetComponent <RectTransform>().rect.height;

                    // 如果点击时,出生位置在最左侧
                    if (_cardGenPos.x < w / 2)
                    {
                        _cardGenPos.x = w / 2;
                    }

                    // 出身位置在最右侧
                    if (_cardGenPos.x > _manager.OperationPanel.rect.width - w / 2)
                    {
                        _cardGenPos.x = _manager.OperationPanel.rect.width - w / 2;
                    }

                    // 出生位置在最下侧
                    if (_cardGenPos.y < h / 2)
                    {
                        _cardGenPos.y = h / 2;
                    }

                    // 出生位置在最上侧
                    if (_cardGenPos.y > _manager.OperationPanel.rect.height - h / 2)
                    {
                        _cardGenPos.y = _manager.OperationPanel.rect.height - h / 2;
                    }

                    _cardAgent.GetComponent <RectTransform>().anchoredPosition = _cardGenPos;

                    _cardAgent.GoToFront(() => {
                    });
                });
            }
        }
예제 #10
0
        /// <summary>
        ///  创建一个新的操作卡片
        /// </summary>
        /// <param name="dataId">数据ID</param>
        /// <param name="dataType">数据类型</param>
        public CardAgent CreateNewOperateCard(int dataId, DataTypeEnum dataType, Vector3 position, FlockAgent refAgent)
        {
            CloseCardWhenOverNumber();


            CardAgent cardAgent = OperateCardFactoryInstance.
                                  Generate(_manager, position, _container, dataId, dataType, refAgent);

            refAgent.cardAgent = cardAgent;

            Vector3 scaleVector3 = new Vector3(0.1f, 0.1f, 0.1f);

            cardAgent.GetComponent <RectTransform>().localScale = scaleVector3;
            cardAgent.CardStatus = CardStatusEnum.GENERATE;

            EffectAgents.Add(cardAgent);

            int iskinect = _manager.magicSceneManager.GetCurrentScene().GetSceneConfig().isKinect;

            cardAgent.SetMoveBehavior(_manager.collisionMoveBehaviourFactory.GetMoveBehavior(_manager.collisionBehaviorConfig.behaviourType, iskinect));
            _manager.collisionManager.AddCollisionEffectAgent(cardAgent);

            return(cardAgent);
        }
예제 #11
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);
        }
예제 #12
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;
                }
            }
        }
예제 #13
0
        public void Starting()
        {
            float time = Time.time - _startTime;  // 当前已运行的时间;

            for (int i = 0; i < _manager.agentManager.Agents.Count; i++)
            {
                FlockAgent agent         = _manager.agentManager.Agents[i];
                Vector2    agent_vector2 = agent.GenVector2;
                Vector2    ori_vector2   = agent.OriVector2;

                // 延时的时间
                float delay_time = agent.DelayTime;

                // 获取此 agent 需要的动画时间
                float run_time = _startingTimeWithOutDelay - delay_time;

                float aniTime = Time.time - _startTime - delay_time;

                if (aniTime < 0)
                {
                    continue;
                }
                else if (aniTime > _startingTimeWithOutDelay)
                {
                    // 此时可能未走完动画
                    if (!agent.isCreateSuccess)
                    {
                        agent.SetChangedPosition(ori_vector2);

                        agent.isCreateSuccess = true;
                    }

                    continue;
                }
                else
                {
                    float t = aniTime / _startingTimeWithOutDelay;

                    Func <float, float> defaultEasingFunction = EasingFunction.Get(_manager.cutEffectConfig.LeftRightDisplayEaseEnum);

                    t = defaultEasingFunction(t);

                    Vector2 to = Vector2.Lerp(agent_vector2, ori_vector2, t);

                    agent.SetChangedPosition(to);
                }
            }

            if ((time - _entranceDisplayTime * 0.8f) > 0)
            {
                if (!_hasCallDisplay)
                {
                    _hasCallDisplay = true;
                    _onDisplayStart.Invoke();
                }
            }

            if ((time - _entranceDisplayTime) > 0)
            {
                Reset();
                _onEffectCompleted.Invoke();
            }
        }
예제 #14
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);
        }
예제 #15
0
        public void Starting()
        {
            float time = Time.time - _startTime;  // 当前已运行的时间;

            for (int i = 0; i < _manager.agentManager.Agents.Count; i++)
            {
                FlockAgent agent         = _manager.agentManager.Agents[i];
                Vector2    agent_vector2 = agent.GenVector2;
                Vector2    ori_vector2   = agent.OriVector2;

                // 获取总运行时间
                float run_time = _startingTimeWithOutDelay + agent.Delay;


                if (time > run_time)
                {
                    // 此时可能未走完动画
                    if (!agent.isCreateSuccess)
                    {
                        agent.SetChangedPosition(ori_vector2);
                        agent.flockStatus = FlockStatusEnum.NORMAL;

                        agent.isCreateSuccess = true;
                    }
                    continue;
                }

                float t = time / run_time;

                Func <float, float> moveEase = EasingFunction.Get(_manager.cutEffectConfig.MidDisperseMoveEaseEnum);
                t = moveEase(t);


                Vector2 to = Vector2.Lerp(agent_vector2, ori_vector2, t);
                agent.SetChangedPosition(to);


                // 透明度动画
                var distance = Vector2.Distance(ori_vector2, to);

                var agentHeight = agent.GetComponent <RectTransform>().rect.height;


                var maxDistance = agentHeight * _manager.cutEffectConfig.MidDisperseAlphaMinDistanceFactor;

                if (distance < maxDistance)
                {
                    float min_alpha = 0.1f;
                    float max_alpha = 1f;
                    float k         = distance / maxDistance;
                    Func <float, float> easeFunction = EasingFunction.Get(_manager.cutEffectConfig.MidDisperseAlphaEaseEnum);
                    k = easeFunction(k);
                    float newAlpha = Mathf.Lerp(max_alpha, min_alpha, k);
                    agent.UpdateImageAlpha(newAlpha);
                }
            }

            if ((time - _entranceDisplayTime * 0.5f) > 0)
            {
                if (!_hasCallDisplay)
                {
                    _hasCallDisplay = true;
                    _onDisplayStart.Invoke();
                }
            }

            if ((time - _entranceDisplayTime) > 0)
            {
                Reset();
                _onEffectCompleted.Invoke();
            }
        }
예제 #16
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);
        }