private void HandleIndexAfterUpdate(ScrollDirectionEnum scrollDirectionEnum) { // 处理坐标 if (scrollDirectionEnum == ScrollDirectionEnum.Left) { _index = _index + 1; if (_index == _data.ScrollData.Count) { _index = 0; } //_index = 0; } else if (scrollDirectionEnum == ScrollDirectionEnum.Right) { _index = _index - 1; if (_index < 0) { _index = _data.ScrollData.Count - 1; } //_index = 0; } //Debug.Log("修改后的导航位置: " + _index + " INDEX: " + _index); }
private void GeneratePrepareAgent(ScrollDirectionEnum scrollDirectionEnum) { var preAgent = _prepareBarPanelAgent.GetComponentInChildren <ScrollBarItemAgent>(); if (preAgent != null) { Destroy(preAgent.gameObject); } preAgent = Instantiate(_scrollBarItemPrefab, _prepareBarPanelAgent.transform); if (scrollDirectionEnum == ScrollDirectionEnum.Left) { int dataIndex = _index + 2; if (dataIndex >= _navs.Count) { int offset = dataIndex - _navs.Count; dataIndex = 0 + offset; } preAgent.Init(_navs[dataIndex]); } else if (scrollDirectionEnum == ScrollDirectionEnum.Right) { int dataIndex = _index - 2; if (dataIndex < 0) { int offset = Mathf.Abs(dataIndex); dataIndex = _navs.Count - offset; } preAgent.Init(_navs[dataIndex]); ; } }
void OnRecognizeDirection(ScrollDirectionEnum scrollDirectionEnum) { if (_isPrepared) { _isPrepared = false; // 此处判断是否需要进行动画 var needR = NeedResponse(scrollDirectionEnum); if (!needR) { _isPrepared = true; return; } // 设置 prepare agent GeneratePrepareAgent(scrollDirectionEnum); //Debug.Log("scrollDirectionEnum : " + scrollDirectionEnum); for (int i = 0; i < _scrollPanelAgents.Count; i++) { _scrollPanelAgents[i].UpdatePosition(scrollDirectionEnum, () => { _isPrepared = true; }); } HandleIndexAfterUpdate(scrollDirectionEnum); var navType = _navList[_navIndex]; var scrollData = _data.ScrollDic[navType][_index]; _onChanged.Invoke(scrollData, navType, scrollDirectionEnum); Debug.Log("当前的NAV: " + _navList[_navIndex]); } }
public void OnRecognizeDirection(ScrollDirectionEnum scrollDirectionEnum) { if (scrollDirectionEnum == ScrollDirectionEnum.Left) { _flipAgent.FlipRightPage(); } else if (scrollDirectionEnum == ScrollDirectionEnum.Right) { _flipAgent.FlipLeftPage(); } }
private void HandleIndexAfterUpdate(ScrollDirectionEnum scrollDirectionEnum) { // 处理坐标 if (scrollDirectionEnum == ScrollDirectionEnum.Left) { _navIndex = _navIndex + 1; if (_navIndex == _navList.Count) { _navIndex = 0; } _index = 0; _scrollPanelTop.UpdateUpDownContent(_navIndex, _navList); _scrollPanelBottom.UpdateUpDownContent(_navIndex, _navList); } else if (scrollDirectionEnum == ScrollDirectionEnum.Right) { _navIndex = _navIndex - 1; if (_navIndex < 0) { _navIndex = _navList.Count - 1; } _index = 0; _scrollPanelTop.UpdateUpDownContent(_navIndex, _navList); _scrollPanelBottom.UpdateUpDownContent(_navIndex, _navList); } else if (scrollDirectionEnum == ScrollDirectionEnum.Bottom) { var datas = _data.ScrollDic[_navList[_navIndex]]; _index = _index - 1; if (_index < 0) { _index = datas.Count - 1; } } else if (scrollDirectionEnum == ScrollDirectionEnum.Top) { var datas = _data.ScrollDic[_navList[_navIndex]]; _index = _index + 1; if (_index == datas.Count) { _index = 0; } } //Debug.Log("修改后的导航位置: " + _navIndex + " INDEX: " + _index); }
/// <see cref="IScrollService.Scroll"/> public void Scroll(ScrollDirectionEnum direction) { if (this.mapWindowBC.AttachedWindow == null) { throw new InvalidOperationException("Window has not yet been attached!"); } if (direction == ScrollDirectionEnum.NoScroll) { return; } RCNumVector windowCenterMapCoords = this.mapWindowBC.AttachedWindow.WindowMapCoords.Location + this.mapWindowBC.AttachedWindow.WindowMapCoords.Size / 2; if (direction == ScrollDirectionEnum.North) { this.mapWindowBC.ScrollTo(windowCenterMapCoords + new RCNumVector(0, -SCROLL_STEP)); } else if (direction == ScrollDirectionEnum.NorthEast) { this.mapWindowBC.ScrollTo(windowCenterMapCoords + new RCNumVector(SCROLL_STEP, -SCROLL_STEP)); } else if (direction == ScrollDirectionEnum.East) { this.mapWindowBC.ScrollTo(windowCenterMapCoords + new RCNumVector(SCROLL_STEP, 0)); } else if (direction == ScrollDirectionEnum.SouthEast) { this.mapWindowBC.ScrollTo(windowCenterMapCoords + new RCNumVector(SCROLL_STEP, SCROLL_STEP)); } else if (direction == ScrollDirectionEnum.South) { this.mapWindowBC.ScrollTo(windowCenterMapCoords + new RCNumVector(0, SCROLL_STEP)); } else if (direction == ScrollDirectionEnum.SouthWest) { this.mapWindowBC.ScrollTo(windowCenterMapCoords + new RCNumVector(-SCROLL_STEP, SCROLL_STEP)); } else if (direction == ScrollDirectionEnum.West) { this.mapWindowBC.ScrollTo(windowCenterMapCoords + new RCNumVector(-SCROLL_STEP, 0)); } else if (direction == ScrollDirectionEnum.NorthWest) { this.mapWindowBC.ScrollTo(windowCenterMapCoords + new RCNumVector(-SCROLL_STEP, -SCROLL_STEP)); } }
/// <summary> /// 生产准备的agent /// </summary> /// <param name="scrollDirectionEnum"></param> void GeneratePrepareAgent(ScrollDirectionEnum scrollDirectionEnum) { if (scrollDirectionEnum == ScrollDirectionEnum.Left || scrollDirectionEnum == ScrollDirectionEnum.Right) { // 左右滑动、既是滑动更改nav if (_data.ScrollData.Count == 2) { // TODO } else if (_data.ScrollData.Count > 2) { var preAgent = _scrollPanelPrepare.GetComponentInChildren <SliceScrollItemAgent>(); if (preAgent != null) { Destroy(preAgent.gameObject); } preAgent = Instantiate(_scrollItemPrefab, _scrollPanelPrepare.transform); if (scrollDirectionEnum == ScrollDirectionEnum.Left) { int dataIndex = _index + 2; if (dataIndex >= _data.ScrollData.Count) { int offset = dataIndex - _data.ScrollData.Count; dataIndex = 0 + offset; } Debug.Log("_data.ScrollData[dataIndex]" + dataIndex + " - " + _data.ScrollData[dataIndex]); preAgent.Init(_data.ScrollData[dataIndex], _onScale); } else if (scrollDirectionEnum == ScrollDirectionEnum.Right) { int dataIndex = _index - 2; if (dataIndex < 0) { int offset = Mathf.Abs(dataIndex); dataIndex = _data.ScrollData.Count - offset; } preAgent.Init(_data.ScrollData[dataIndex], _onScale); } } } }
/// <summary> /// Called when the mouse cursor is moved over the area of the page. /// </summary> private void OnMouseMove(UISensitiveObject sender, UIMouseEventArgs evtArgs) { ScrollDirectionEnum newScrollDir = ScrollDirectionEnum.NoScroll; if (evtArgs.Position.X == 0 || evtArgs.Position.X == this.scrollEventSource.Range.Width - 1 || evtArgs.Position.Y == 0 || evtArgs.Position.Y == this.scrollEventSource.Range.Height - 1) { if (evtArgs.Position.X == 0 && evtArgs.Position.Y == 0) { newScrollDir = ScrollDirectionEnum.NorthWest; } else if (evtArgs.Position.X == this.scrollEventSource.Range.Width - 1 && evtArgs.Position.Y == 0) { newScrollDir = ScrollDirectionEnum.NorthEast; } else if (evtArgs.Position.X == this.scrollEventSource.Range.Width - 1 && evtArgs.Position.Y == this.scrollEventSource.Range.Height - 1) { newScrollDir = ScrollDirectionEnum.SouthEast; } else if (evtArgs.Position.X == 0 && evtArgs.Position.Y == this.scrollEventSource.Range.Height - 1) { newScrollDir = ScrollDirectionEnum.SouthWest; } else if (evtArgs.Position.X == 0) { newScrollDir = ScrollDirectionEnum.West; } else if (evtArgs.Position.X == this.scrollEventSource.Range.Width - 1) { newScrollDir = ScrollDirectionEnum.East; } else if (evtArgs.Position.Y == 0) { newScrollDir = ScrollDirectionEnum.North; } else if (evtArgs.Position.Y == this.scrollEventSource.Range.Height - 1) { newScrollDir = ScrollDirectionEnum.South; } } this.currentScrollDir = newScrollDir; }
/// <summary> /// 判断是否需要相应动作 /// </summary> /// <param name="scrollDirectionEnum"></param> /// <returns></returns> private bool NeedResponse(ScrollDirectionEnum scrollDirectionEnum) { bool r = false; if (scrollDirectionEnum == ScrollDirectionEnum.Left || scrollDirectionEnum == ScrollDirectionEnum.Right) { if (_data.ScrollData.Count > 2) { r = true; } else if (_data.ScrollData.Count == 2) { if (scrollDirectionEnum == ScrollDirectionEnum.Left) { if (_index == 1) { r = false; } else { r = true; } } else { if (_index == 0) { r = false; } else { r = true; } } } else { r = false; } } return(r); }
void OnRecognizeDirection(ScrollDirectionEnum scrollDirectionEnum) { if (_isPrepared) { _isPrepared = false; // 此处判断是否需要进行动画 var needR = NeedResponse(scrollDirectionEnum); if (!needR) { _isPrepared = true; return; } // 设置 prepare agent GeneratePrepareAgent(scrollDirectionEnum); //Debug.Log("scrollDirectionEnum : " + scrollDirectionEnum); for (int i = 0; i < _scrollPanelAgents.Count; i++) { _scrollPanelAgents[i].UpdatePosition(scrollDirectionEnum, () => { _isPrepared = true; }); } //Debug.Log("当前的移动方向: " + scrollDirectionEnum + " 当前的导航位置: " + _index); HandleIndexAfterUpdate(scrollDirectionEnum); var currentData = _data.ScrollData[_index]; _onChanged.Invoke(currentData, scrollDirectionEnum); } }
private void DoChange(ScrollDirectionEnum scrollDirectionEnum) { if (!_isPrepared) { return; } _isPrepared = false; for (int i = 0; i < _scrollBarPanelAgents.Count; i++) { _scrollBarPanelAgents[i].UpdatePosition(scrollDirectionEnum, () => { _isPrepared = true; }); } // 更新坐标地址 if (scrollDirectionEnum == ScrollDirectionEnum.Left) { _index++; if (_index == _navs.Count) { _index = 0; } } else if (scrollDirectionEnum == ScrollDirectionEnum.Right) { _index--; if (_index < 0) { _index = _navs.Count - 1; } } }
/// <summary> /// 更新位置 /// TODO : 当 nav 只有两个时,修改 /// </summary> /// <param name="scrollDirectionEnum"></param> public void UpdatePosition(ScrollDirectionEnum scrollDirectionEnum, Action updatePositionSuccess) { // 左划 if (scrollDirectionEnum == ScrollDirectionEnum.Left) { // 左划,更换nav if (_currentLocation == PanelLocationEnum.Left) { var item = GetComponentInChildren <SliceScrollItemAgent>(); if (item != null) { Destroy(item.gameObject); } // 右移后销毁 } else if (_currentLocation == PanelLocationEnum.Middle) { // 移动到左侧 var item = GetComponentInChildren <SliceScrollItemAgent>(); item.transform.SetParent(_sliceScrollAgent.scrollPanelLeft.transform, true); item.GetComponent <RectTransform>().DOScale(1f, 0); item.RecoverFrame(); item.GetComponent <RectTransform>().DOAnchorPos(LeftPosition, aniTime) .OnComplete(() => { //AdjustSize(); }); } else if (_currentLocation == PanelLocationEnum.Right) { // 移动到中间 var item = GetComponentInChildren <SliceScrollItemAgent>(); item.transform.SetParent(_sliceScrollAgent.scrollPanelMiddle.transform, true); item.GetComponent <RectTransform>().DOScale(1f, 0); item.GetComponent <RectTransform>().DOAnchorPos(MiddlePosition, aniTime) .OnComplete(() => { item.SetAsMiddle(() => { updatePositionSuccess.Invoke(); }); //AdjustSize(); }); } else if (_currentLocation == PanelLocationEnum.Prepare) { // 移动到右侧 var item = GetComponentInChildren <SliceScrollItemAgent>(); if (item != null) { item.transform.SetParent(_sliceScrollAgent.scrollPanelRight.transform, true); item.RecoverFrame(); item.GetComponent <RectTransform>().DOAnchorPos(RightPosition, aniTime) .OnComplete(() => { //AdjustSize(); }); } } } // 右滑 else if (scrollDirectionEnum == ScrollDirectionEnum.Right) { // 向右移动至中间 if (_currentLocation == PanelLocationEnum.Left) { // 移动到中间 Debug.Log("右侧移动至中间"); var item = GetComponentInChildren <SliceScrollItemAgent>(); item.transform.SetParent(_sliceScrollAgent.scrollPanelMiddle.transform, true); item.GetComponent <RectTransform>().DOAnchorPos(MiddlePosition, aniTime) .OnComplete(() => { item.SetAsMiddle(() => { updatePositionSuccess.Invoke(); }); }); // 右移后销毁 } else if (_currentLocation == PanelLocationEnum.Middle) { // 移动到右侧 var item = GetComponentInChildren <SliceScrollItemAgent>(); item.transform.SetParent(_sliceScrollAgent.scrollPanelRight.transform, true); item.GetComponent <RectTransform>().DOScale(1f, 0); item.RecoverFrame(); item.GetComponent <RectTransform>().DOAnchorPos(Vector2.zero, aniTime) .OnComplete(() => { }); } else if (_currentLocation == PanelLocationEnum.Right) { var item = GetComponentInChildren <SliceScrollItemAgent>(); Destroy(item?.gameObject); } else if (_currentLocation == PanelLocationEnum.Prepare) { // 移动到左侧 var item = GetComponentInChildren <SliceScrollItemAgent>(); if (item != null) { item.transform.SetParent(_sliceScrollAgent.scrollPanelLeft.transform, true); item.RecoverFrame(); item.GetComponent <RectTransform>().DOAnchorPos(MiddlePosition, aniTime) .OnComplete(() => { }); } } } }
public void UpdatePosition(ScrollDirectionEnum scrollDirectionEnum, Action updatePositionSuccess) { if (scrollDirectionEnum == ScrollDirectionEnum.Left) { if (_currentLocation == PanelLocationEnum.Left) { var item = GetComponentInChildren <ScrollBarItemAgent>(); Destroy(item.gameObject); // 右移后销毁 } else if (_currentLocation == PanelLocationEnum.Middle) { // 移动到左侧 var item = GetComponentInChildren <ScrollBarItemAgent>(); item.transform.SetParent(_scrollBarAgent.leftBarPanelAgent.transform, true); item.GetComponent <RectTransform>().DOScale(1f, aniTime); item.GetComponent <RectTransform>().DOAnchorPos(Vector2.zero, aniTime) .OnComplete(() => { updatePositionSuccess.Invoke(); }); } else if (_currentLocation == PanelLocationEnum.Right) { // 移动到中间 var item = GetComponentInChildren <ScrollBarItemAgent>(); item.transform.SetParent(_scrollBarAgent.middleBarPanelAgent.transform, true); item.GetComponent <RectTransform>().DOScale(1f, aniTime); item.GetComponent <RectTransform>().DOAnchorPos(Vector2.zero, aniTime) .OnComplete(() => { }); } else if (_currentLocation == PanelLocationEnum.Prepare) { // 移动到右侧 var item = GetComponentInChildren <ScrollBarItemAgent>(); item.transform.SetParent(_scrollBarAgent.rightBarPanelAgent.transform, true); item.GetComponent <RectTransform>().DOScale(1f, aniTime); item.GetComponent <RectTransform>().DOAnchorPos(Vector2.zero, aniTime) .OnComplete(() => { }); } } // 右滑 else if (scrollDirectionEnum == ScrollDirectionEnum.Right) { // 向右移动至中间 if (_currentLocation == PanelLocationEnum.Left) { // 移动到中间 Debug.Log("右侧移动至中间"); var item = GetComponentInChildren <ScrollBarItemAgent>(); item.transform.SetParent(_scrollBarAgent.middleBarPanelAgent.transform, true); item.GetComponent <RectTransform>().DOScale(1f, aniTime); item.GetComponent <RectTransform>().DOAnchorPos(Vector2.zero, aniTime) .OnComplete(() => { }); // 右移后销毁 } else if (_currentLocation == PanelLocationEnum.Middle) { // 移动到右侧 var item = GetComponentInChildren <ScrollBarItemAgent>(); item.transform.SetParent(_scrollBarAgent.rightBarPanelAgent.transform, true); item.GetComponent <RectTransform>().DOScale(1f, aniTime); item.GetComponent <RectTransform>().DOAnchorPos(Vector2.zero, aniTime) .OnComplete(() => { updatePositionSuccess.Invoke(); }); } else if (_currentLocation == PanelLocationEnum.Right) { var item = GetComponentInChildren <ScrollBarItemAgent>(); Destroy(item.gameObject); } else if (_currentLocation == PanelLocationEnum.Prepare) { // 移动到左侧 var item = GetComponentInChildren <ScrollBarItemAgent>(); item.transform.SetParent(_scrollBarAgent.leftBarPanelAgent.transform, true); item.GetComponent <RectTransform>().DOScale(1f, aniTime); item.GetComponent <RectTransform>().DOAnchorPos(Vector2.zero, aniTime) .OnComplete(() => { }); } } }
/// <summary> /// 判断是否需要相应动作 /// </summary> /// <param name="scrollDirectionEnum"></param> /// <returns></returns> private bool NeedResponse(ScrollDirectionEnum scrollDirectionEnum) { bool r = false; if (scrollDirectionEnum == ScrollDirectionEnum.Left || scrollDirectionEnum == ScrollDirectionEnum.Right) { if (_navList.Count > 2) { r = true; } else if (_navList.Count == 2) { if (scrollDirectionEnum == ScrollDirectionEnum.Left) { if (_navIndex == 1) { r = false; } else { r = true; } } else { if (_navIndex == 0) { r = false; } else { r = true; } } } else { r = false; } } else if (scrollDirectionEnum == ScrollDirectionEnum.Top || scrollDirectionEnum == ScrollDirectionEnum.Bottom) { var datas = _data.ScrollDic[_navList[_navIndex]]; if (datas.Count > 2) { r = true; } else if (datas.Count == 2) { if (scrollDirectionEnum == ScrollDirectionEnum.Top) { if (_index == 1) { r = false; } else { r = true; } } else { if (_index == 0) { r = false; } else { r = true; } } } } return(r); }
/// <summary> /// 生产准备的agent /// </summary> /// <param name="scrollDirectionEnum"></param> void GeneratePrepareAgent(ScrollDirectionEnum scrollDirectionEnum) { if (scrollDirectionEnum == ScrollDirectionEnum.Left || scrollDirectionEnum == ScrollDirectionEnum.Right) { // 左右滑动、既是滑动更改nav if (_navList.Count == 2) { } else if (_navList.Count > 2) { var preAgent = _scrollPanelPrepare.GetComponentInChildren <ScrollItemAgent>(); if (preAgent != null) { Destroy(preAgent.gameObject); } preAgent = Instantiate(_scrollItemPrefab, _scrollPanelPrepare.transform); if (scrollDirectionEnum == ScrollDirectionEnum.Left) { int dataIndex = _navIndex + 2; if (dataIndex >= _navList.Count) { int offset = dataIndex - _navList.Count; dataIndex = 0 + offset; } preAgent.Init(_data.ScrollDic[_navList[dataIndex]][0], _onScale); } else if (scrollDirectionEnum == ScrollDirectionEnum.Right) { int dataIndex = _navIndex - 2; if (dataIndex < 0) { int offset = Mathf.Abs(dataIndex); dataIndex = _navList.Count - offset; } Debug.Log("Prepare - " + _navList[dataIndex]); preAgent.Init(_data.ScrollDic[_navList[dataIndex]][0], _onScale); } else if (scrollDirectionEnum == ScrollDirectionEnum.Top) { var items = _data.ScrollDic[_navList[_navIndex]]; if (items.Count == 1) { return; } else if (items.Count == 2) { } else { int dataIndex = _index + 1; } } } } else { var datas = _data.ScrollDic[_navList[_navIndex]]; if (datas.Count == 2) { } else if (datas.Count > 2) { var preAgent = _scrollPanelPrepare.GetComponentInChildren <ScrollItemAgent>(); if (preAgent != null) { Destroy(preAgent.gameObject); } preAgent = Instantiate(_scrollItemPrefab, _scrollPanelPrepare.transform); int dataIndex; if (scrollDirectionEnum == ScrollDirectionEnum.Top) { dataIndex = _index + 2; if (dataIndex >= datas.Count) { int offset = dataIndex - datas.Count; dataIndex = 0 + offset; } Debug.Log("[当前的Index] : " + _index + " -> [目标的Index]:" + dataIndex); } else { dataIndex = _index - 2; if (dataIndex < 0) { int offset = Mathf.Abs(dataIndex); dataIndex = datas.Count - offset; } } Debug.Log("数据索引: " + dataIndex); preAgent.Init(datas[dataIndex], _onScale); } } }