public void AddAndUnlockMimisbrunnrWorld( WorldSheet.Row worldRow, long unlockedAt, WorldSheet worldSheet, WorldUnlockSheet worldUnlockSheet) { var succeed = false; var worldId = worldRow.Id; if (worldId == GameConfig.MimisbrunnrWorldId) { var unlockRow = worldUnlockSheet.OrderedList.FirstOrDefault(row => row.WorldIdToUnlock == worldId); if (!(unlockRow is null) && IsStageCleared(unlockRow.StageId)) { succeed = true; } } else if (IsStageCleared(worldRow.StageBegin - 1)) { succeed = true; } if (succeed) { var world = new World(worldRow); worlds.Add(worldId, world); UnlockWorld(worldId, unlockedAt, worldSheet); } else { throw new FailedAddWorldException($"Failed to add {worldId} world to WorldInformation."); } }
public static bool TryGetByName(this WorldSheet sheet, string name, out WorldSheet.Row worldRow) { foreach (var row in sheet.OrderedList.Where(row => row.Name.Equals(name))) { worldRow = row; return(true); } worldRow = null; return(false); }
public static bool TryGetStageNumber(this WorldSheet.Row worldRow, int stageId, out int stageNumber) { if (stageId < worldRow.StageBegin || stageId > worldRow.StageEnd) { stageNumber = 0; return(false); } stageNumber = stageId - worldRow.StageBegin + 1; return(true); }
public void UpdateWorld(WorldSheet.Row worldRow) { var originWorld = _worlds[worldRow.Id]; var world = new World( worldRow, originWorld.UnlockedBlockIndex, originWorld.StageClearedBlockIndex, originWorld.StageClearedId ); _worlds[worldRow.Id] = world; }
public bool TryAddWorld(WorldSheet.Row worldRow, out World world) { if (worldRow is null || _worlds.ContainsKey(worldRow.Id)) { world = default; return(false); } world = new World(worldRow); _worlds.Add(worldRow.Id, world); return(true); }
public World( WorldSheet.Row worldRow, long unlockedBlockIndex = -1, long stageClearedBlockIndex = -1, int stageClearedId = -1) { Id = worldRow.Id; Name = worldRow.Name; StageBegin = worldRow.StageBegin; StageEnd = worldRow.StageEnd; UnlockedBlockIndex = unlockedBlockIndex; StageClearedBlockIndex = stageClearedBlockIndex; StageClearedId = stageClearedId; }
public void AddAndUnlockNewWorld(WorldSheet.Row worldRow, long unlockedAt, WorldSheet worldSheet) { var worldId = worldRow.Id; if (IsStageCleared(worldRow.StageBegin - 1)) { var world = new World(worldRow); worlds.Add(worldId, world); UnlockWorld(worldId, unlockedAt, worldSheet); } else { throw new FailedAddWorldException($"Failed to add {worldId} world to WorldInformation."); } }
public static bool TryGetByStageId(this WorldSheet sheet, int stageId, out WorldSheet.Row worldRow) { foreach (var row in sheet.OrderedList) { if (stageId < row.StageBegin || stageId > row.StageEnd) { continue; } worldRow = row; return(true); } worldRow = null; return(false); }
public void Show(WorldMap.ViewModel viewModel, WorldSheet.Row worldRow, StageType stageType) { _sharedViewModel = viewModel; _sharedViewModel.SelectedStageId .Subscribe(stageId => UpdateStageInformation( stageId, States.Instance.CurrentAvatarState?.level ?? 1) ) .AddTo(gameObject); _sharedViewModel.WorldInformation.TryGetWorld(worldRow.Id, out var worldModel); UpdateStageInformation(_sharedViewModel.SelectedStageId.Value, States.Instance.CurrentAvatarState.level); if (_sharedViewModel.SelectedStageId.Value == 1) { stageHelpButton.Show(); } else { stageHelpButton.Hide(); } _stageType = stageType; SetBottomMenu(stageType); world.Set(worldRow); var questStageId = Game.Game.instance.States .CurrentAvatarState.questList .OfType <WorldQuest>() .Where(x => !x.Complete) .OrderBy(x => x.Goal) .FirstOrDefault()? .Goal ?? -1; world.ShowByStageId(_sharedViewModel.SelectedStageId.Value, questStageId); if (worldModel.IsUnlocked) { UnlockWorld(worldModel.GetNextStageIdForPlay(), worldModel.GetNextStageId()); } else { LockWorld(); } base.Show(); }
public void UpdateWorld(WorldSheet.Row worldRow) { var key = (IKey)worldRow.Id.Serialize(); var originWorld = _serialized is Dictionary d ? new World((Dictionary)d[key]) : _worlds[worldRow.Id]; var world = new World( worldRow, originWorld.UnlockedBlockIndex, originWorld.StageClearedBlockIndex, originWorld.StageClearedId ); if (_serialized is Dictionary s) { _serialized = (Dictionary)s.SetItem(key, world.Serialize()); } else { _worlds[worldRow.Id] = world; } }
public bool TryAddWorld(WorldSheet.Row worldRow, out World world) { if (worldRow is null || (_serialized is Dictionary d ? d.ContainsKey((IKey)worldRow.Id.Serialize()) : _worlds.ContainsKey(worldRow.Id))) { world = default; return(false); } world = new World(worldRow); if (_serialized is Dictionary s) { var key = (IKey)worldRow.Id.Serialize(); _serialized = (Dictionary)s.Add(key, world.Serialize()); } else { worlds.Add(worldRow.Id, world); } return(true); }
public static bool ContainsStageId(this WorldSheet.Row worldRow, int stageId) { return(stageId >= worldRow.StageBegin && stageId <= worldRow.StageEnd); }
public static string GetLocalizedName(this WorldSheet.Row worldRow) { return(L10nManager.Localize($"WORLD_NAME_{worldRow.Name.ToUpper().Replace(" ", "_")}")); }
public void Set(WorldSheet.Row worldRow) { Id = worldRow.Id; StageBegin = worldRow.StageBegin; StageEnd = worldRow.StageEnd; }
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); }
public ViewModel(WorldSheet.Row rowData) { RowData = rowData; }