private static EraInfo[] TrimEras(EraInfo[] baseEras) { EraInfo[] array = new EraInfo[baseEras.Length]; int newSize = 0; for (int index = 0; index < baseEras.Length; ++index) { if (baseEras[index].yearOffset + baseEras[index].minEraYear < 2049) { if (baseEras[index].yearOffset + baseEras[index].maxEraYear >= 1960) { array[newSize] = baseEras[index]; ++newSize; } else { break; } } } if (newSize == 0) { return(baseEras); } Array.Resize <EraInfo>(ref array, newSize); return(array); }
private void UpdateEraAchv(EraInfo info) { var itemData = DataModel.AchvItemDataModel; var finishFlag = info.Record.FinishFlagId; itemData.MaxCount = DataModel.AchvCellList.Count; var finish = PlayerDataManager.Instance.GetFlag(finishFlag); if (finish) { itemData.State = 2; } else { if (itemData.CurrentCount >= itemData.MaxCount) { itemData.State = 1; } else { itemData.State = 0; } } var tbMaya = Table.GetMayaBase(itemData.EraId); if (tbMaya != null) { itemData.AwardNotice = string.Format(GameUtils.GetDictionaryText(100001381), tbMaya.Name); } }
private void ResetAchvList(EraInfo info) { DataModel.AchvCellList.Clear(); if (info == null) { return; } if (info.Record.ActiveType != (int)EraActiveType.Achievement) { return; } DataModel.AchvItemDataModel.CurrentCount = 0; for (var i = 0; i < info.Record.ActiveParam.Count; ++i) { var achievementId = info.Record.ActiveParam[i]; if (achievementId < 0) { continue; } var tbAchv = Table.GetAchievement(achievementId); if (tbAchv == null) { continue; } var achvItem = new EraAchvCellDataModel(); achvItem.Id = achievementId; var state = PlayerDataManager.Instance.GetAccomplishmentStatus(achvItem.Id); achvItem.State = (int)state; if (state == eRewardState.HasGot) { ++DataModel.AchvItemDataModel.CurrentCount; } var progress = Mathf.Min(PlayerDataManager.Instance.GetAccomplishmentProgress(achievementId), tbAchv.ExdataCount); achvItem.CurrentProgress = GameUtils.GetBigValueStr(progress); achvItem.MaxProgress = GameUtils.GetBigValueStr(tbAchv.ExdataCount); for (var j = 0; j < achvItem.Rewards.Count; ++j) { var itemData = achvItem.Rewards[j]; if (j < tbAchv.ShowItems.Count) { itemData.ItemId = tbAchv.ShowItems[j]; } else { itemData.ItemId = -1; } } DataModel.AchvCellList.Add(achvItem); } UpdateEraAchv(info); }
private IEnumerator PlayContentAnimEnd(EraInfo info, float time) { yield return(new WaitForSeconds(time)); info.State = EraState.Finish; DataModel.SkillInfo.State = (int)info.State; var notice = EraManager.Instance.RefreshEraNotice(info.Record.Type); DataModel.BookMarkNotice[info.Record.Type] = notice; }
private IEnumerator TakeEraAward(EraInfo eraInfo) { using (new BlockingLayerHelper(0)) { var msg = NetManager.Instance.CSEnterEraById(eraInfo.Record.Id); yield return(msg.SendAndWaitUntilDone()); if (msg.State == MessageState.Reply) { if (msg.ErrorCode == (int)ErrorCodes.OK) { PlayerDataManager.Instance.SetFlag(eraInfo.Record.FinishFlagId); UpdateEraAchv(GetEraInfo(DataModel.TabIndex)); } } } }
private IEnumerator PlayAnimEnd(EraBookCellDataModel data, EraInfo info, float time) { yield return(new WaitForSeconds(time)); info.State = EraState.PlayAnimEnd; info.State = EraState.Finish; data.State = (int)EraState.Finish; var skillId = GetSkillIdByEraId(info.Record.Id); var skillInfo = GetSkillInfoBySkillId(skillId); if (skillInfo != null) { FillCatalogCell(data, skillInfo); } if (tempEraId == info.Record.Id) { SetCurrEraCell(info.Record.Id); } }
// EraInfo.yearOffset: The offset to Gregorian year when the era starts. Gregorian Year = Era Year + yearOffset // Era Year = Gregorian Year - yearOffset // EraInfo.minEraYear: Min year value in this era. Generally, this value is 1, but this may be affected by the DateTime.MinValue; // EraInfo.maxEraYear: Max year value in this era. (== the year length of the era + 1) private int GetYearOffset(int year, int era, bool throwOnError) { if (year < 0) { if (throwOnError) { throw new ArgumentOutOfRangeException(nameof(year), SR.ArgumentOutOfRange_NeedNonNegNum); } return(-1); } if (era == Calendar.CurrentEra) { era = m_Cal.CurrentEraValue; } var eras = m_EraInfo; for (int i = 0; i < eras.Length; i++) { EraInfo eraInfo = eras[i]; if (era == eraInfo.era) { if (year >= eraInfo.minEraYear) { if (year <= eraInfo.maxEraYear) { return(eraInfo.yearOffset); } else if (!LocalAppContextSwitches.EnforceJapaneseEraYearRanges) { // If we got the year number exceeding the era max year number, this still possible be valid as the date can be created before // introducing new eras after the era we are checking. we'll loop on the eras after the era we have and ensure the year // can exist in one of these eras. otherwise, we'll throw. // Note, we always return the offset associated with the requested era. // // Here is some example: // if we are getting the era number 4 (Heisei) and getting the year number 32. if the era 4 has year range from 1 to 31 // then year 32 exceeded the range of era 4 and we'll try to find out if the years difference (32 - 31 = 1) would lay in // the subsequent eras (e.g era 5 and up) int remainingYears = year - eraInfo.maxEraYear; for (int j = i - 1; j >= 0; j--) { if (remainingYears <= eras[j].maxEraYear) { return(eraInfo.yearOffset); } remainingYears -= eras[j].maxEraYear; } } } if (throwOnError) { throw new ArgumentOutOfRangeException( nameof(year), SR.Format( SR.ArgumentOutOfRange_Range, eraInfo.minEraYear, eraInfo.maxEraYear)); } break; // no need to iterate more on eras. } } if (throwOnError) { throw new ArgumentOutOfRangeException(nameof(era), SR.ArgumentOutOfRange_InvalidEraValue); } return(-1); }