public void Init(Action doClickAction, CardAgent cardAgent) { _DoClickAction = doClickAction; _moveSubject = cardAgent; _moveSubject.AddObserver(this); }
/// <summary> /// REF: https://www.yuque.com/docs/share/58f46b17-0b98-430b-a14c-4a08e20690e5 /// </summary> private void CloseCardWhenOverNumber() { // 当数量超过设定的额度 if (_effectAgents.Count >= _manager.managerConfig.SelectedItemMaxCount) { Debug.Log("打开卡片超过限度"); CardAgent cardToClose = null; for (int i = 0; i < _effectAgents.Count; i++) { var effectAgent = _effectAgents[i]; if (effectAgent.CardStatus == CardStatusEnum.NORMAL) { if (cardToClose == null || effectAgent.GetFreeTime() > cardToClose.GetFreeTime()) { cardToClose = effectAgent; } } } if (cardToClose != null) { Debug.Log("打开卡片超过限度,关闭:" + cardToClose.name); // 直接删除 cardToClose.DoCloseDirect(); } } }
/// <summary> /// 初始化数据 /// </summary> public void InitData(List <SearchBean> searchBeans, string title, MagicWallManager manager, CardAgent cardAgent) { Reset(); _title.text = title; _manager = manager; _cardAgent = cardAgent; _moveBtnComponent.Init(DoMove, _cardAgent); int count = searchBeans.Count; if (count == 0) { _noResultContainer.gameObject.SetActive(true); } else { _noResultContainer.gameObject.SetActive(false); // 根据 search beans 进行初始化内容 for (int i = 0; i < searchBeans.Count; i++) { CreateItem(searchBeans[i]); } // 获取高度 SetContentSize(); // 初始化滚动条 _searchResultScrollBarAgent.Init(_onUpdated); } }
public void InitData(MagicWallManager manager, CardAgent cardAgent) { _manager = manager; _cardAgent = cardAgent; _flockAgent = cardAgent.OriginAgent; _moveBtnComponent.Init(DoMove, cardAgent); }
public void SetData(string address, string description, CardAgent cardAgent, string cover, Action onVideoUpdated) { SetAddress(address); SetCardAgent(cardAgent); SetDescription(description); _onVideoUpdated = onVideoUpdated; _cover = cover; }
/// <summary> /// 判断是否是本 card 进行移动 /// </summary> /// <param name="cardAgent"></param> /// <returns></returns> private bool IsDoMoved(CardAgent cardAgent) { int this_index = _manager.operateCardManager.EffectAgents.IndexOf(this); int effect_index = _manager.operateCardManager.EffectAgents.IndexOf(cardAgent); if (this_index < effect_index) { return(false); } else { return(true); } }
private void ToDoMoved(Collider2D other) { if (other.gameObject.layer == 5) { GetComponent <Rigidbody2D>().WakeUp(); CardAgent _refCardAgent = other.gameObject.GetComponent <CardAgent>(); if (IsDoMoved(_refCardAgent)) { MoveInvoker(_refCardAgent); } } }
private void ToDoMove(Collider2D col) { if (col.gameObject.layer == 5) { CardAgent cardAgent = col.gameObject.GetComponent <CardAgent>(); if (!cardAgent.isPhysicsMoving) { col.gameObject.GetComponent <Rigidbody2D>().WakeUp(); col.gameObject.GetComponent <Rigidbody2D>().AddForce(GetVector2()); cardAgent.isPhysicsMoving = true; } } }
private void MoveInvoker(CardAgent refCardAgent) { if (!_isPhysicsMoving) { _isPhysicsMoving = true; // 获取相对的位置 Vector2 selfPosition = GetComponent <RectTransform>().anchoredPosition; Vector2 refPosition = refCardAgent.GetComponent <RectTransform>().anchoredPosition; Vector2 to = (selfPosition - refPosition).normalized; Vector2 to2 = to * 100 * _physicesEffectFactor; GetComponent <Rigidbody2D>().AddForce(to2); } }
/// <summary> /// 点击搜索结果的 Item /// </summary> /// <param name="searchBean"></param> private void OnClickSearchResultItem(SearchBean searchBean) { // 将 SearchAgent 关闭 CloseSearchAgentContainer(true); CloseSearchResultContainer(true); // 将card的显示关系打开 _cardAgent.RecoverContainerAfterSearch(); _cardAgent.CardStatus = CardStatusEnum.OBSOLETE; //_manager.agentManager.RemoveItemFromEffectItems(_cardAgent); // 将影响实体清除 // 打开新的卡片 //ItemsFactory itemsFactory = GetItemFactory(searchBean.type); Vector3 genVector3 = _cardAgent.GetComponent <RectTransform>().anchoredPosition; CardAgent cardAgent = _manager.operateCardManager.CreateNewOperateCard(searchBean.id, searchBean.type, genVector3, _cardAgent.OriginAgent); //itemsFactory.GenerateCardAgent(genVector3, null, searchBean.id, true); cardAgent.GoToFront(() => { }); }
/// <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); }
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); }
public void SetCardAgent(CardAgent cardAgent) { _cardAgent = cardAgent; }