예제 #1
0
    public void ChangePage(int pageNumber)
    {
        if (currentPage == pageNumber)
        {
            return;
        }

        pageScroller.ChangePage(pageNumber);
    }
예제 #2
0
 public override void OnBackButton()
 {
     if (SocketManager.Instance.IsClientRunningAndConnectedToRoom())
     {
         SocketManager.Instance.StopSocket();
     }
     scroller.ChangePage(0);
     ScreenManager.Instance.SwitchToLastScene();
 }
예제 #3
0
        private void BtnCloseClick()
        {
            var cg = GetComponent <CanvasGroup>();

            cg.blocksRaycasts = false;
            LeanTween.alphaCanvas(canvasGroup, 0, 0.2f).setOnComplete(() => {
                horizontalScrollSnap.ChangePage(0);

                canvasGroup.blocksRaycasts = false;

                gameObject.SetActive(false);
            });
        }
예제 #4
0
    IEnumerator CoCenterOnCurrentStage()
    {
        yield return(new WaitForEndOfFrame());

        /*int previousStagePlayedArrayID = User.GetCurrentStage();
         * previousStagePlayedArrayID = Mathf.Min(previousStagePlayedArrayID, stageSelectItems.Count - 1);
         * if (previousStagePlayedArrayID < stageSelectItems.Count && previousStagePlayedArrayID >= 0)
         * {
         *  scrollRectMover.CenterOnItem(stageSelectItems[previousStagePlayedArrayID].GetComponent<RectTransform>());
         * }*/

        int currentPage = Mathf.CeilToInt((float)User.GetCurrentStage() / itemsPerPage) - 1;

        pageScrollSnap.ChangePage(currentPage);
    }
예제 #5
0
    void OnEnable()
    {
        if (CollectionItemSelectionHandler == null)
        {
            return;
        }

        var equipped = _equipment.GetItem(_equipmentSlot);

        CollectionItemSelectionHandler.SelectItem(equipped);

        for (int i = 0; i < _collectionPages.Count; i++)
        {
            if (_collectionPages[i].ContainsItem(equipped))
            {
                _scrollSnap.ChangePage(i);
                break;
            }
        }
    }
예제 #6
0
        public void Set(WorldSheet.Row worldRow)
        {
            if (worldRow is null)
            {
                throw new ArgumentNullException(nameof(worldRow));
            }

            _disposablesForModel.DisposeAllAndClear();
            SharedViewModel = new ViewModel(worldRow);

            var stageRows = Game.Game.instance.TableSheets.StageWaveSheet.Values
                            .Where(stageRow => stageRow.StageId >= worldRow.StageBegin &&
                                   stageRow.StageId <= worldRow.StageEnd)
                            .ToList();
            var stageRowsCount = stageRows.Count;

            if (worldRow.StagesCount != stageRowsCount)
            {
                throw new SheetRowValidateException(
                          $"{worldRow.Id}: worldRow.StagesCount({worldRow.StagesCount}) != stageRowsCount({stageRowsCount})");
            }

            var imageKey = worldRow.Id == GameConfig.MimisbrunnrWorldId ? "99" : $"{worldRow.Id:D2}";

            titleImage.overrideSprite = Resources.Load <Sprite>($"UI/Textures/WorldMap/UI_bg_worldmap_{imageKey}");
            titleImage.SetNativeSize();
            var stageOffset        = 0;
            var nextPageShouldHide = false;
            var pageIndex          = 1;

            foreach (var page in pages)
            {
                page.gameObject.SetActive(false);
                if (nextPageShouldHide)
                {
                    continue;
                }
                page.gameObject.SetActive(true);

                var stageCount  = page.Stages.Count;
                var stageModels = new List <WorldMapStage.ViewModel>();
                for (var i = 0; i < stageCount; i++)
                {
                    if (nextPageShouldHide)
                    {
                        stageModels.Add(new WorldMapStage.ViewModel(WorldMapStage.State.Hidden));

                        continue;
                    }

                    var stageRowsIndex = stageOffset + i;
                    if (stageRowsIndex < stageRowsCount)
                    {
                        var stageRow   = stageRows[stageRowsIndex];
                        var stageModel = new WorldMapStage.ViewModel(
                            stageRow,
                            stageRow.StageId.ToString(),
                            WorldMapStage.State.Normal);

                        stageModels.Add(stageModel);
                    }
                    else
                    {
                        nextPageShouldHide = true;
                        stageModels.Add(new WorldMapStage.ViewModel(WorldMapStage.State.Hidden));
                    }
                }

                page.Show(stageModels, imageKey, worldRow.Id == GameConfig.MimisbrunnrWorldId ? 1 : pageIndex);
                pageIndex   += 1;
                stageOffset += stageModels.Count;
                if (stageOffset >= stageRowsCount)
                {
                    nextPageShouldHide = true;
                }
            }

            SharedViewModel.StageIdToShow.Value     = worldRow.StageBegin + stageRowsCount - 1;
            SharedViewModel.PageCount.Value         = pages.Count(p => p.gameObject.activeSelf);
            SharedViewModel.CurrentPageNumber.Value = 1;

            SharedViewModel.PageCount
            .Subscribe(pageCount =>
                       stagePageText.text = $"{SharedViewModel.CurrentPageNumber.Value}/{pageCount}")
            .AddTo(_disposablesForModel);
            SharedViewModel.CurrentPageNumber
            .Subscribe(currentPageNumber =>
            {
                stagePageText.text = $"{currentPageNumber}/{SharedViewModel.PageCount.Value}";
                previousButton.gameObject.SetActive(currentPageNumber > 1);
                nextButton.gameObject.SetActive(
                    currentPageNumber < SharedViewModel.PageCount.Value);
            })
            .AddTo(_disposablesForModel);

            horizontalScrollSnap.ChangePage(SharedViewModel.CurrentPageNumber.Value - 1);
        }