public async Task <UIViewBase> ShowView(UIViewName viewName, params object[] args) { SO_UIViewConfig config = GetConfig(viewName); if (config == null) { return(null); } UIViewBase view = null; if (config.unique) { //界面是唯一打开的 for (int i = 0; i < viewList.Count; i++) { if (viewList[i].Config.viewName == viewName) { //打开过 view = viewList[i]; break; } } //界面被打开过 if (view != null) { if (view.LayerController == null) { Debug.LogError($"展示界面错误: {viewName}, 没有层级"); return(null); } view.SetArguments(args); view.LayerController.Push(view); } else { Task <UIViewBase> handle = ShowViewFromCacheOrCreateNew(config, args); await handle; if (handle.Status == TaskStatus.RanToCompletion) { view = handle.Result; } } } else { Task <UIViewBase> handle = ShowViewFromCacheOrCreateNew(config, args); await handle; if (handle.Status == TaskStatus.RanToCompletion) { view = handle.Result; } } return(view); //刷新显示、隐藏状态 //UpdateViewHideState(); }
private SO_UIViewConfig GetConfig(UIViewName viewName) { if (uiViewConfig.ContainsKey(viewName) == false) { UtilityHelper.LogError(string.Format("Get view config error: {0}", viewName)); return(null); } return(uiViewConfig[viewName]); }
private SO_UIViewConfig GetConfig(UIViewName viewName) { if (uiViewConfigDic.ContainsKey(viewName) == false) { Debug.LogError($"获取配置失败: {viewName}"); return(null); } return(uiViewConfigDic[viewName]); }
//关闭第一个同名界面 public void HideView(UIViewName viewName) { for (int i = viewList.Count - 1; i >= 0; i--) { if (viewList[i].Config.viewName == viewName) { HideView(viewList[i]); return; } } }
public T GetViewByName <T>(UIViewName viewName) where T : UIViewBase { for (int i = 0; i < viewList.Count; ++i) { if (viewList[i].Config.viewName == viewName) { return(viewList[i] as T); } } return(null); }
//只关闭第一个同名界面 public void HideView(UIViewName viewName) { for (int i = viewList.Count - 1; i >= 0; --i) { //关闭 if (viewList[i].config.viewName == viewName) { HideView(viewList[i]); return; } } }
//展示界面 public void ShowView(UIViewName viewName, params object[] args) { //获取界面配置 SO_UIViewConfig config = GetConfig(viewName); if (config == null) { return; } UIViewBase view = null; //如果这个窗口是唯一的 if (config.unique) { //如果界面是唯一打开的,则判断下是否打开过这个界面 for (int i = 0; i < viewList.Count; ++i) { if (viewList[i].config.viewName == viewName) { //我靠居然打开着呢! view = viewList[i]; break; } } //当前这个界面被打开了 if (view != null) { if (view.layerController == null) { UtilityHelper.LogError(string.Format("Show view error: {0}, not layer", viewName)); return; } //设置参数,重新放入窗口层级控制器 view.SetArguments(args); view.layerController.Push(view); } else { //没有,打开个新的吧 ShowViewFromCacheOrCreateNew(config, args); } } else { //开!!什么开... ShowViewFromCacheOrCreateNew(config, args); } //刷新显示、隐藏状态 UpdateViewHideState(); }
//获取名字相同的所有界面 public List <T> GetViewListByName <T>(UIViewName viewName) where T : ViewBaseView { List <T> list = new List <T>(); for (int i = 0; i < viewList.Count; ++i) { if (viewList[i].config.viewName == viewName) { list.Add(viewList[i] as T); } } return(list); }
//展示界面 public void ShowView(UIViewName viewName, params object[] args) { //获取界面配置 UIViewConfig config = GetConfig(viewName); if (config == null) { return; } ViewBaseView view = null; if (config.unique) { //判断是否打开了 for (int i = 0; i < viewList.Count; ++i) { if (viewList[i].config.viewName == viewName) { view = viewList[i]; break; } } //判断是否已被打开,没有打开个新的 if (view != null) { if (view.layerController == null) { UtilityLog.LogError(string.Format("Show view error: {0}, not layer", viewName)); return; } //设置参数,重新放入窗口层级控制器 // view.SetArguments(args); view.layerController.Push(view); } else { ShowViewFromCacheOrCreateNew(config, args); } } else { ShowViewFromCacheOrCreateNew(config, args); } //刷新显示、隐藏状态 UpdateViewHideState(); }
public void CloseView(UIViewName uiName) { string ViewName = uiName.ToString(); if (!openViewDict.ContainsKey(ViewName)) { return; } GameObject ui = openViewDict[ViewName]; openViewDict.Remove(ViewName); closeViewDict[ViewName] = ui; UIBaseView uiView = ui.GetComponent <UIBaseView>(); uiView.CloseView(); ui.transform.parent = hideLayer; ui.transform.localScale = Vector3.one; ui.transform.localEulerAngles = Vector3.zero; ui.transform.localPosition = Vector3.zero; }
public void OpenView(UIViewName uiName, params object[] param) { for (int i = 0; i < openViewStack.Count; ++i) { CloseView(openViewStack[i]); } openViewStack.Clear(); openViewStack.Add(uiName); string ViewName = uiName.ToString(); if (openViewDict.ContainsKey(ViewName)) { return; } GameObject ui = null; if (closeViewDict.ContainsKey(ViewName)) { ui = closeViewDict[ViewName]; closeViewDict.Remove(ViewName); openViewDict[ViewName] = ui; } else { GameObject resGo = Resources.Load <Object>("Prefab/UI/" + ViewName) as GameObject; ui = GameObject.Instantiate(resGo); CanvasDepth cd = ui.AddComponent <CanvasDepth>(); cd.isUI = true; openViewDict[ViewName] = ui; } ui.transform.parent = openLayer; ui.transform.localScale = Vector3.one; ui.transform.localEulerAngles = Vector3.zero; ui.transform.localPosition = Vector3.zero; UIBaseView uiView = ui.GetComponent <UIBaseView>(); uiView.OpenView(param); }
public override void ExceHandleNotification(INotification notification) { //判断是否是转发内容 if (notification.Name.Contains("=>")) { SendNotification(StringUtil.GeNotificationNameForNN(notification.Name), notification.Body, notification.Type); return; } // 处理公共请求 HandleNotificationCommon(notification); ViewChooseStage viewChooseStage = null; List <CardDeckList> cardDeckListLoad = new List <CardDeckList>(); CardMoveAnimation cardMoveAnimation = null; //回调函数 UnityAction callBack = () => { exceINotification = false; SendNotification(UIViewSystemEvent.UI_ANIMATION_SYS, null, UIViewSystemEvent.UI_ANIMATION_SYS_START); }; bool callBackDelay = false; switch (notification.Name) { case UIViewSystemEvent.UI_ANIMATION_SYS: switch (notification.Type) { case UIViewSystemEvent.UI_ANIMATION_SYS_START: DoExceHandleNotification(); break; } break; case UIViewSystemEvent.UI_CARD_ENTRY_SYS: switch (notification.Type) { //卡牌的归属地发生了变化 case UIViewSystemEvent.UI_CARD_ENTRY_SYS_CHANGE_GAME_CONTAINER_TYPE: CardEntry cardEntryMove = notification.Body as CardEntry; if (cardEntryMove.gameContainerType == "CardHand") { SendNotification(HandSystemEvent.HAND_CHANGE, notification.Body, StringUtil.GetNTByNotificationTypeAndPlayerCode(HandSystemEvent.HAND_CHANGE_DRAW_ONE_CARD, cardEntryMove.controllerPlayerItem.playerCode)); return; } if (cardEntryMove.lastGameContainerType == "CardHand") { SendNotification(HandSystemEvent.HAND_CHANGE, cardEntryMove, StringUtil.GetNTByNotificationTypeAndPlayerCode(HandSystemEvent.HAND_CHANGE_REMOVE_ONE_CARD, cardEntryMove.controllerPlayerItem.playerCode)); } break; //卡牌在显示页面需要被隐藏 case UIViewSystemEvent.UI_CARD_ENTRY_SYS_CARD_NEED_HIDE_IN_VIEW: CardEntry cardEntryNeedHide = notification.Body as CardEntry; if (cardEntryNeedHide.gameContainerType == "CardHand") { SendNotification(HandSystemEvent.HAND_CHANGE, notification.Body, StringUtil.GetNTByNotificationTypeAndPlayerCode(UIViewSystemEvent.UI_CARD_ENTRY_SYS_CARD_NEED_HIDE_IN_VIEW, cardEntryNeedHide.controllerPlayerItem.playerCode)); } break; } break; case UIViewSystemEvent.UI_VIEW_CURRENT: switch (notification.Type) { case UIViewSystemEvent.UI_VIEW_CURRENT_OPEN_ONE_VIEW: //是否需要打开遮罩层 if (parameterMap.ContainsKey("OpenMaskLayer")) { string OpenMaskLayer = parameterMap["OpenMaskLayer"]; if ("Y" == OpenMaskLayer) { UIViewName uiMaskLayeView = UIViewConfig.getUIViewNameByNameStr("UIMaskLayeView"); UIControllerLIst.ShowView(uiMaskLayeView); } } UIViewName viewNameOpen = UIViewConfig.getUIViewNameByNameStr(parameterMap["UIViewName"]); UIControllerLIst.ShowView(viewNameOpen); //初始化页面 UIControllerLIst.GetViewByName <ViewBaseView>(viewNameOpen).InitViewForParameter(this, notification.Body, parameterMap); //一些界面打开时需要初始化 switch (viewNameOpen) { case UIViewName.CardDeckList: PlayerItem playerItem = notification.Body as PlayerItem; List <CardDeckList> cardDeckLists = UIControllerLIst.GetViewListByName <CardDeckList>(UIViewName.CardDeckList); for (int num = 0; num < cardDeckLists.Count; num++) { if (cardDeckLists[num].playerItem == null) { cardDeckLists[num].playerItem = playerItem; //设置位置 //0在左,1在右 //己方始终显示在左边 Vector3 position = new Vector3(); if (playerItem.playerCode == playerCode) { position.x = -600; } else { position.x = 430; } cardDeckLists[num].transform.localPosition = position; } } break; } break; case UIViewSystemEvent.UI_VIEW_CURRENT_CLOSE_ONE_VIEW: UIViewName viewNameClose = UIViewConfig.getUIViewNameByNameStr(notification.Body as string); UIControllerLIst.HideView(viewNameClose); //是否需要关闭遮罩层 if (parameterMap.ContainsKey("OpenMaskLayer")) { string OpenMaskLayer = parameterMap["OpenMaskLayer"]; if ("N" == OpenMaskLayer) { UIViewName uiMaskLayeView = UIViewConfig.getUIViewNameByNameStr("UIMaskLayeView"); UIControllerLIst.HideView(uiMaskLayeView); } } break; } break; case UIViewSystemEvent.UI_CHOOSE_STAGE: switch (notification.Type) { case UIViewSystemEvent.UI_CHOOSE_STAGE_LOAD_CARD_ENTRY: viewChooseStage = UIControllerLIst.GetViewByName <ViewChooseStage>(UIViewName.ChooseStage); List <CardEntry> shipCardEntryList = (List <CardEntry>)notification.Body; //载入卡牌列表 viewChooseStage.LoadCardEntryList(shipCardEntryList); //载入完成后绑定事件 foreach (CardIntactView cardIntactView in viewChooseStage.cardIntactViews) { //如果是自己的命令则绑定上点击事件 if (playerCode == playerCodeNotification) { cardIntactView.OnClick = () => { SendNotification(UIViewSystemEvent.UI_CHOOSE_STAGE, cardIntactView.card, UIViewSystemEvent.UI_CHOOSE_STAGE_ONE_CARD); }; } else { //设置为空 cardIntactView.OnClick = () => { }; } } break; case UIViewSystemEvent.UI_CHOOSE_STAGE_ONE_SHIP_CARD_ANIMATION: viewChooseStage = UIControllerLIst.GetViewByName <ViewChooseStage>(UIViewName.ChooseStage); CardEntry choosedShipCard = notification.Body as CardEntry; CardIntactView targetCardIntactView = null; //找到这张组件 foreach (CardIntactView cardIntactView in viewChooseStage.cardIntactViews) { if (cardIntactView.card.uuid == choosedShipCard.uuid) { cardDeckListLoad = UIControllerLIst.GetViewListByName <CardDeckList>(UIViewName.CardDeckList); cardMoveAnimation = UIControllerLIst.GetViewByName <CardMoveAnimation>(UIViewName.CardMoveAnimation); //执行动画,获得卡牌的位置,list的位置 for (int num = 0; num < cardDeckListLoad.Count; num++) { //移动目标 if (cardDeckListLoad[num].playerItem.playerCode == playerCodeNotification) { callBackDelay = true; cardMoveAnimation.MoveShipCardAnimation(cardIntactView, cardDeckListLoad[num], callBack); } } } } break; } break; case UIViewSystemEvent.UI_CHOOSE_MAKE_STAGE: ViewChooseMakeStage viewChooseMakeStage = UIControllerLIst.GetViewByName <ViewChooseMakeStage>(UIViewName.ViewChooseMakeStage); switch (notification.Type) { //获取下一组数据 case UIViewSystemEvent.UI_CHOOSE_MAKE_STAGE_LOAD_NEXT_LIST: List <CardEntry> cardList = notification.Body as List <CardEntry>; viewChooseMakeStage = UIControllerLIst.GetViewByName <ViewChooseMakeStage>(UIViewName.ViewChooseMakeStage); viewChooseMakeStage.LoadNewCardList(cardList); break; case UIViewSystemEvent.UI_CHOOSE_MAKE_STAGE_ONE_CARD_SUCCESS: CardEntry card = notification.Body as CardEntry; viewChooseMakeStage.ChangeOneCradForBuyed(card); break; } break; case UIViewSystemEvent.UI_CARD_DECK_LIST: switch (notification.Type) { //读取牌组 case UIViewSystemEvent.UI_CARD_DECK_LIST_LOAD: PlayerItem playerItemLoad = notification.Body as PlayerItem; cardDeckListLoad = UIControllerLIst.GetViewListByName <CardDeckList>(UIViewName.CardDeckList); for (int num = 0; num < cardDeckListLoad.Count; num++) { if (cardDeckListLoad[num].playerItem.playerCode == playerItemLoad.playerCode) { cardDeckListLoad[num].LoadPlayerInfo(); foreach (CardHeadView cardHeadView in cardDeckListLoad[num].cardHeadViews) { cardHeadView.OnPointerEnter = () => { SendNotification( UIViewSystemEvent.UI_VIEW_CURRENT, cardHeadView, StringUtil.GetNTByNotificationTypeAndUIViewNameAndOtherType( UIViewSystemEvent.UI_VIEW_CURRENT_OPEN_ONE_VIEW, UIViewConfig.getNameStrByUIViewName(UIViewName.OneCardAllInfo), "CardHeadView" ) ); }; cardHeadView.OnPointerExit = () => { SendNotification( UIViewSystemEvent.UI_VIEW_CURRENT, UIViewConfig.getNameStrByUIViewName(UIViewName.OneCardAllInfo), UIViewSystemEvent.UI_VIEW_CURRENT_CLOSE_ONE_VIEW); }; } } } break; } break; //费用控制组件 case UIViewSystemEvent.UI_MANA_INFA_SYS: int changeNum = 0; ManaInfoView manaInfoView = null; switch (notification.Type) { case UIViewSystemEvent.UI_MANA_INFA_SYS_INIT: VariableAttribute manaInitVariableAttribute = notification.Body as VariableAttribute; manaInfoView = UIControllerLIst.GetViewByName <ManaInfoView>(UIViewName.ManaInfoView); manaInfoView.UIManaInfoSysInit(manaInitVariableAttribute, myself, playerCodeNotification); break; case UIViewSystemEvent.UI_MANA_INFA_SYS_NUM_CHANGE: VariableAttribute manaChangeVariableAttribute = notification.Body as VariableAttribute; manaInfoView = UIControllerLIst.GetViewByName <ManaInfoView>(UIViewName.ManaInfoView); manaInfoView.ChangeManaUsable(manaChangeVariableAttribute, myself); break; } break; //科技组件显示 case UIViewSystemEvent.UI_TRAIT_COMBINATION_SYS: TraitCombinationView traitCombinationView = null; switch (notification.Type) { case UIViewSystemEvent.UI_TRAIT_COMBINATION_SYS_INIT: List <TraitType> traitTypes = notification.Body as List <TraitType>; traitCombinationView = UIControllerLIst.GetViewByName <TraitCombinationView>(UIViewName.TraitCombinationView); traitCombinationView.UITraitCombinationSysInit(traitTypes, myself, playerCodeNotification); break; case UIViewSystemEvent.UI_TRAIT_COMBINATION_SYS_ADD: string traitType = notification.Body.ToString(); traitCombinationView = UIControllerLIst.GetViewByName <TraitCombinationView>(UIViewName.TraitCombinationView); traitCombinationView.UITraitCombinationSysAdd(traitType, myself); break; } break; //效果展示列控制 case UIViewSystemEvent.UI_EFFECT_DISPLAY_SYS: EffectDisplayView effectDisplayView = null; switch (notification.Type) { case UIViewSystemEvent.UI_EFFECT_DISPLAY_SYS_PUT_ONE_EFFECT: effectDisplayView = UIControllerLIst.GetViewByName <EffectDisplayView>(UIViewName.EffectDisplayView); CardEntry effectCardNeedShow = notification.Body as CardEntry; callBackDelay = true; //回调函数 callBack = () => { exceINotification = false; SendNotification(EffectExecutionEvent.EFFECT_EXECUTION_SYS, null, EffectExecutionEvent.EFFECT_EXECUTION_SYS_EFFECT_SHOW_OVER); SendNotification(UIViewSystemEvent.UI_ANIMATION_SYS, null, UIViewSystemEvent.UI_ANIMATION_SYS_START); }; effectDisplayView.ShowCradEffectByCardEntryAuto(effectCardNeedShow, callBack); break; case UIViewSystemEvent.UI_EFFECT_DISPLAY_SYS_ONE_EFFECT_NEED_CHOOSE_EXE: effectDisplayView = UIControllerLIst.GetViewByName <EffectDisplayView>(UIViewName.EffectDisplayView); CardEntry effectCardNeedChooseExe = notification.Body as CardEntry; SendNotificationAddCardEntry sendNotificationAddCard = (OneUserSelectionItem oneUserSelectionItem) => { SendNotification(OperateSystemEvent.OPERATE_SYS, oneUserSelectionItem, OperateSystemEvent.OPERATE_SYS_CHOOSE_ONE_USER_SELECTION_ITEM); }; effectDisplayView.ShowCradEffectAndUserSelectionListByCardEntry(effectCardNeedChooseExe, sendNotificationAddCard); break; case UIViewSystemEvent.UI_EFFECT_DISPLAY_SYS_ONE_EFFECT_NEED_CHOOSE_TARGET: effectDisplayView = UIControllerLIst.GetViewByName <EffectDisplayView>(UIViewName.EffectDisplayView); CardEntry effectCardNeedChooseTarget = notification.Body as CardEntry; effectDisplayView.ShowCradEffectByCardEntry(effectCardNeedChooseTarget); break; case UIViewSystemEvent.UI_EFFECT_DISPLAY_SYS_TO_HIDE: effectDisplayView = UIControllerLIst.GetViewByName <EffectDisplayView>(UIViewName.EffectDisplayView); effectDisplayView.cardIntactView.gameObject.SetActive(false); break; } break; //科技组件显示 case UIViewSystemEvent.UI_PLAYER_SCORE_SHOW_SYS: switch (notification.Type) { case UIViewSystemEvent.UI_PLAYER_SCORE_SHOW_SYS_CHANGE: ShipComponentView shipScoreComponentView = UIControllerLIst.GetViewByName <ShipComponentView>(UIViewName.ShipComponentView); shipScoreComponentView.ChangeScoreShow(myself, Convert.ToInt32(notification.Body)); break; } break; //结束按钮的显示控制 case UIViewSystemEvent.UI_NEXT_TURN_SHOW_SYS: NextTurnButton nextTurnButton = null; switch (notification.Type) { case UIViewSystemEvent.UI_NEXT_TURN_SHOW_SYS_SHOW: if (myself) { nextTurnButton = UIControllerLIst.GetViewByName <NextTurnButton>(UIViewName.NextTurnButton); nextTurnButton.ShowButton(); } break; } break; //展示卡牌完整信息的控制 case UIViewSystemEvent.UI_ONE_CARD_ALL_INFO: switch (notification.Type) { case UIViewSystemEvent.UI_ONE_CARD_ALL_INFO_BUFF_CHANGE: CardEntry minionCellItem = notification.Body as CardEntry; OneCardAllInfo oneCardAllInfo = UIControllerLIst.GetViewByName <OneCardAllInfo>(UIViewName.OneCardAllInfo); if (oneCardAllInfo != null) { if (oneCardAllInfo.cardEntryShow.uuid == minionCellItem.uuid) { oneCardAllInfo.LoadingAllInfoByMinionCellItem(minionCellItem); } } break; } break; case UIViewSystemEvent.UI_TURN_STAGE_SYS: switch (notification.Type) { case UIViewSystemEvent.UI_TURN_STAGE_SYS_STAGE_CHANGE: //回调函数 UnityAction turnStageCallBack = () => { SendNotification(EffectExecutionEvent.EFFECT_EXECUTION_SYS, null, EffectExecutionEvent.EFFECT_EXECUTION_SYS_EFFECT_SHOW_OVER); SendNotification(UIViewSystemEvent.UI_ANIMATION_SYS, null, UIViewSystemEvent.UI_ANIMATION_SYS_START); }; TurnSysProgressBarView turnSysProgressBarView = UIControllerLIst.GetViewByName <TurnSysProgressBarView>(UIViewName.TurnSysProgressBarView); QuestStageCircuitItem questStageCircuitItem = notification.Body as QuestStageCircuitItem; turnSysProgressBarView.LoadingAllStageInfoToChange(questStageCircuitItem, playerCode, turnStageCallBack); break; } break; } if (callBackDelay == false) { callBack(); } }
public static string getNameStrByUIViewName(UIViewName viewName) { return(Enum.GetName(typeof(UIViewName), viewName)); }