/// <summary> /// Prevent people from calling default constructor. /// </summary> public AGSSocialLeaderboard() { leaderboard = AGSLeaderboard.GetBlankLeaderboard (); localPlayerScore = -1; localPlayerRank = -1; _timeScope = TimeScope.AllTime; }
private TimeScope Map(TIM tim, Catalog catalog) { DateTime?stamp1 = null; if (tim.A.HasValue) { stamp1 = tim.A.Value; } DateTime?stamp2 = null; if (tim.B.HasValue) { stamp2 = tim.B.Value; } var timeScope = new TimeScope { TimeStamp1 = stamp1, TimeStamp2 = stamp2, DateContext = DateContextEnum.ActualStart }; if (catalog.TimeScopes == null) { catalog.TimeScopes = new List <TimeScope>(); } catalog.TimeScopes.Add(timeScope); return(timeScope); }
private static void OnTopScoresChange(Leaderboard leaderboard, TimeScope timeScope) { if (timeScope == currentTimeScope) { topScoresChanged?.Invoke(leaderboard); } }
public ISOGuidanceShift ExportGuidanceShift(GuidanceShift adaptGuidanceShift) { ISOGuidanceShift gst = new ISOGuidanceShift(); //Group ID gst.GuidanceGroupIdRef = TaskDataMapper.InstanceIDMap.GetISOID(adaptGuidanceShift.GuidanceGroupId); //Pattern ID gst.GuidancePatternIdRef = TaskDataMapper.InstanceIDMap.GetISOID(adaptGuidanceShift.GuidancePatterId); //Shifts gst.GuidanceEastShift = adaptGuidanceShift.EastShift.AsConvertedInt("mm"); gst.GuidanceNorthShift = adaptGuidanceShift.NorthShift.AsConvertedInt("mm"); gst.PropagationOffset = adaptGuidanceShift.PropagationOffset.AsConvertedInt("mm"); //Allocation Stamp if (adaptGuidanceShift.TimeScopeIds.Any()) { TimeScope scope = DataModel.Catalog.TimeScopes.FirstOrDefault(t => t.Id.ReferenceId == adaptGuidanceShift.TimeScopeIds.First()); //Mapping first timescope only if (scope != null) { gst.AllocationStamp = AllocationStampMapper.ExportAllocationStamp(scope); } } return(gst); }
private void ReadPresetTopScores(Leaderboard leaderboard, TimeScope timeScope) { switch (timeScope) { case TimeScope.AllTime: _topScoresAllTimeDict[leaderboard].Clear(); break; case TimeScope.Week: _topScoresWeekDict[leaderboard].Clear(); break; case TimeScope.Today: _topScoresTodayDict[leaderboard].Clear(); break; } string[] rawData = new string[3]; for (int i = 0, imax = PRESET_SCORES_NAME.Length; i < imax; i++) { rawData[0] = PRESET_SCORES_NAME[i]; rawData[1] = "" + (i + 1); rawData[2] = "" + PRESET_SCORES_SCORES[i]; AddTopScore(rawData, leaderboard, timeScope); } WriteTopScores(leaderboard, timeScope); }
/// <summary> /// Shows the leaderboard UI for the given leaderboard in the specified time scope. /// </summary> /// <param name="leaderboardName">Leaderboard name.</param> /// <param name="timeScope">Time scope to display scores in the leaderboard.</param> public static void ShowLeaderboardUI(string leaderboardName, TimeScope timeScope) { if (!IsInitialized()) { Debug.Log("Couldn't show leaderboard UI: user is not logged in."); return; } Leaderboard ldb = GetLeaderboardByName(leaderboardName); if (ldb == null) { Debug.Log("Couldn't show leaderboard UI: unknown leaderboard name."); return; } #if UNITY_IOS GameCenterPlatform.ShowLeaderboardUI(ldb.Id, timeScope); #elif UNITY_ANDROID && EM_GPGS PlayGamesPlatform.Instance.ShowLeaderboardUI(ldb.Id, ToGpgsLeaderboardTimeSpan(timeScope), null); #else // Fallback Social.ShowLeaderboardUI(); #endif }
/// <summary> /// Prevent people from calling default constructor. /// </summary> public AGSSocialLeaderboard() { leaderboard = AGSLeaderboard.GetBlankLeaderboard(); localPlayerScore = -1; localPlayerRank = -1; _timeScope = TimeScope.AllTime; }
private static void AreEqual(TimeScope timeScope, TIM tim) { Assert.AreEqual(timeScope.TimeStamp1, tim.A); Assert.AreEqual(timeScope.TimeStamp2, tim.B); // todo. check other attributes and PTN, dlvs,.... }
public static void DescribeSummaryData(ApplicationDataModel adm, LoggedData loggedData) { Console.WriteLine(); Console.WriteLine("-----------------------"); Console.WriteLine("Task Summary Information"); Console.WriteLine("-----------------------"); Console.WriteLine(); //Each LoggedData object will map to a Summary object via the SummaryId property. Summary summary = adm.Documents.Summaries.SingleOrDefault(s => s.Id.ReferenceId == loggedData.SummaryId); if (summary != null) { //Each summary will have a start date timescope TimeScope timeScope = summary.TimeScopes.SingleOrDefault(t => t.DateContext == DateContextEnum.ActualStart); DateTime startTime = timeScope.TimeStamp1.Value; //In the 2020 Plugin, we include the end date as TimeStamp2. DateTime endTime = timeScope.TimeStamp2.Value; Console.WriteLine($"The field operation started at {startTime.ToString()} and ended at {endTime.ToString()}"); Console.WriteLine(); Console.WriteLine($"The following are totals/averages for the field operation:"); //The 2020 plugin will summarize all field Operation data into a single StampedMetersValues collection. //The ADAPT framework allows for multiple StampedMetersValues in cases where multiple timestamps govern multiple data values foreach (MeteredValue meteredValue in summary.SummaryData.Single().Values) { NumericRepresentationValue representationValue = meteredValue.Value as NumericRepresentationValue; string summaryValueName = representationValue.Representation.Description; string uomCode = representationValue.Value.UnitOfMeasure.Code; double value = representationValue.Value.Value; Console.WriteLine($"{summaryValueName}: {value} {uomCode}"); } Console.WriteLine(); //For seed and liquid fertilizer products, the Plugin will summarize data by product Console.WriteLine($"The following are totals/averages by product:"); foreach (OperationSummary operationSummary in summary.OperationSummaries) { Product product = adm.Catalog.Products.FirstOrDefault(p => p.Id.ReferenceId == operationSummary.ProductId); Console.WriteLine($"{product.Description}:"); foreach (MeteredValue meteredValue in operationSummary.Data.Single().Values) { NumericRepresentationValue representationValue = meteredValue.Value as NumericRepresentationValue; string summaryValueName = representationValue.Representation.Description; string uomCode = representationValue.Value.UnitOfMeasure.Code; double value = representationValue.Value.Value; Console.WriteLine($"{summaryValueName}: {value} {uomCode}"); } Console.WriteLine(); } } }
protected ModifierBase(string type, PhaseCode startPhase, ISource source, ICardInPlay target, TimeScope duration, int value) : base("Modifier", GetText(target, type, value), source) { this.StartPhase = startPhase; this.Target = target; this.Duration = duration; this.Value = value; }
public LeaderboardKey(string id, UserScope userScope, TimeScope timeScope, ushort startingRank, ushort numberOfRanks) { this.id = id; this.userScope = userScope; this.timeScope = timeScope; this.startingRank = startingRank; this.numberOfRanks = numberOfRanks; }
private DateTime FindActualStartTime(TimeScope timeScope) { if (timeScope.TimeStamp1 == null) { return(DateTime.MinValue); } return(timeScope.TimeStamp1.GetValueOrDefault()); }
public void Setup() { _timeScope = new TimeScope(); _timeScopes = new List <TimeScope> { _timeScope }; _timeMapper = new TimeMapper(); }
public static LeaderboardEntry GetTopScores(Leaderboard leaderboard, TimeScope timeScope, int index) { List <LeaderboardEntry> topScores = GetTopScores(leaderboard, timeScope); if (index >= topScores.Count) { return(null); } return(topScores[index]); }
public void NotInIntervalDailyFixdTimeJobScheduleFrequencyTest() { DailyJobScheduleFrequency dailyFrequency = PrepareDailyJobSchedule(2); DateTime startTime = DateTime.Now.Date.AddDays(1); DateTime timePoint = startTime + new TimeSpan(10, 10, 10); TimeScope scope = dailyFrequency.GetTimeScope(startTime, timePoint, _TimeOffset); Assert.IsNotNull(scope); }
private Summary ImportSummary(ISOTask isoLoggedTask, LoggedData loggedData) { //Per ISO11783-10:2015(E) 6.8.3, the last Time element contains the comprehensive task totals. //Earlier Time elements contain the task totals leading up to points where the Task was paused. //As such, the Summary.TimeScopes will include detail on various intermittent Timescopes, //and the Summary.SummaryData will contain totals from only the last time element. //Summary.SummaryData.Stamp will be set to a comprehensive time stamp from the beginning of the first time to the end of the last. Summary summary = null; IEnumerable <ISOTime> timeElements = isoLoggedTask.Times.Where(t => t.HasStart && t.HasType); if (timeElements.Any()) { summary = new Summary(); //TimeScopes summary.TimeScopes = new List <TimeScope>(); foreach (ISOTime time in isoLoggedTask.Times.Where(t => t.HasStart && t.HasType)) //Nothing added without a Start and Type attribute { TimeScope timeScope = new TimeScope(); timeScope.TimeStamp1 = time.Start; if (time.Stop != null) { timeScope.TimeStamp2 = time.Stop; } if (time.Stop == null && time.Duration != null) { //Calculate the Stop time if missing and duration present timeScope.TimeStamp2 = timeScope.TimeStamp1.Value.AddSeconds(time.Duration.Value); } timeScope.DateContext = time.Type == ISOEnumerations.ISOTimeType.Planned ? DateContextEnum.ProposedStart : DateContextEnum.ActualStart; timeScope.Duration = timeScope.TimeStamp2.GetValueOrDefault() - timeScope.TimeStamp1.GetValueOrDefault(); summary.TimeScopes.Add(timeScope); } //Summary Data - does not have a product reference summary.SummaryData = ImportSummaryData(timeElements); //Operation Summaries - includes a product reference summary.OperationSummaries = ImportOperationSummaries(isoLoggedTask); //Copy properties from LoggedData summary.GrowerId = loggedData.GrowerId; summary.FarmId = loggedData.FarmId; summary.FieldId = loggedData.FieldId; summary.CropZoneId = loggedData.CropZoneId; summary.PersonRoleIds = loggedData.PersonRoleIds; summary.WorkItemIds = loggedData.WorkItemIds; summary.GuidanceAllocationIds = loggedData.GuidanceAllocationIds; summary.EquipmentConfigurationGroup = loggedData.EquipmentConfigurationGroup; } return(summary); }
private TIM Map(TimeScope timeScope) { var endTime = FindActualEndTime(timeScope); return(new TIM { A = FindActualStartTime(timeScope), B = endTime, BSpecified = endTime != DateTime.MinValue, D = TIMD.Item4 }); }
public static void DownloadAllLeaderboardTopScores(TimeScope timeScope) { if (instanceExists && instance.debugMode) { Debug.LogFormat("LeaderboardManager:DownloadAllLeaderboardTopScores({0})", timeScope); } for (int i = 0, imax = EnumUtils.GetCount <Leaderboard>(); i < imax; i++) { DownloadLeaderboardTopScores((Leaderboard)i, timeScope); } }
public void NotMatchDayInMonthlyFixdTimeJobScheduleFrequencyTest() { MonthlyJobScheduleFrequency monthlyFrequency = PrepareMonthlyJobSchedule(1, 5); DateTime now = DateTime.Now; DateTime startTime = new DateTime(now.Year, now.Month, 1); DateTime timePoint = startTime.AddDays(10) + new TimeSpan(10, 10, 10); TimeScope scope = monthlyFrequency.GetTimeScope(startTime, timePoint, _TimeOffset); Assert.IsNull(scope); }
public void NotMatchWeekDayWeeklyFixdTimeJobScheduleFrequencyTest() { WeeklyJobScheduleFrequency weeklyFrequency = PrepareWeeklyJobSchedule(1, DayOfWeek.Monday); DateTime now = DateTime.Now; DateTime startTime = now.AddDays(-((int)now.DayOfWeek - (int)DayOfWeek.Sunday)).Date; DateTime timePoint = startTime.AddDays(2) + new TimeSpan(10, 10, 10);; TimeScope scope = weeklyFrequency.GetTimeScope(startTime, timePoint, _TimeOffset); Assert.IsNull(scope); }
public static IEnumerable <TimeScope> ImportAllocationStamps(IEnumerable <ISOAllocationStamp> isoAllocationStamps) { //Import TimeScopes List <TimeScope> adaptTimeScopes = new List <TimeScope>(); foreach (ISOAllocationStamp ISOAllocationStamp in isoAllocationStamps) { TimeScope adaptTimeScope = ImportAllocationStamp(ISOAllocationStamp); adaptTimeScopes.Add(adaptTimeScope); } return(adaptTimeScopes); }
public Leaderboard() { id = "Invalid"; range = new Range(1, 10); userScope = UserScope.Global; timeScope = TimeScope.AllTime; m_Loading = false; m_LocalUserScore = new Score("Invalid", 0L); m_MaxRange = 0u; m_Scores = new Score[0]; m_Title = "Invalid"; m_UserIDs = new string[0]; }
public void BeforeRecurringTimeFrequencyTest() { TimeSpan sTime = new TimeSpan(10, 0, 0); TimeSpan eTime = new TimeSpan(22, 0, 0); TimeFrequencyBase frequency = new RecurringTimeFrequency(10, IntervalUnit.Second, sTime, eTime); Console.WriteLine(frequency.Description); TimeSpan lastExecuteTime = new TimeSpan(9, 59, 59); TimeScope scope = frequency.GetTimeScope(lastExecuteTime, _TimeOffset); Assert.IsNull(scope); }
/// <summary> /// Initializes a new instance of the <see cref="AGSSocialLeaderboard"/> class. /// </summary> /// <param name='leaderboard'> /// Leaderboard. /// </param> public AGSSocialLeaderboard(AGSLeaderboard leaderboard) { if(null == leaderboard) { AGSClient.LogGameCircleError("AGSSocialLeaderboard constructor \"leaderboard\" argument should not be null"); this.leaderboard = AGSLeaderboard.GetBlankLeaderboard(); } else { this.leaderboard = leaderboard; } id = leaderboard.id; scores = new AGSSocialLeaderboardScore[0]; localPlayerScore = -1; localPlayerRank = -1; _timeScope = TimeScope.AllTime; }
public GuidanceShift ImportGuidanceShift(ISOGuidanceShift isoGuidanceShift) { GuidanceShift adaptShift = new GuidanceShift(); //Group ID int?groupID = TaskDataMapper.InstanceIDMap.GetADAPTID(isoGuidanceShift.GuidanceGroupIdRef); if (groupID.HasValue) { adaptShift.GuidanceGroupId = groupID.Value; } //Pattern ID int?patternID = TaskDataMapper.InstanceIDMap.GetADAPTID(isoGuidanceShift.GuidancePatternIdRef); if (patternID.HasValue) { adaptShift.GuidancePatterId = patternID.Value; } //Shifts if (isoGuidanceShift.GuidanceEastShift.HasValue) { adaptShift.EastShift = isoGuidanceShift.GuidanceEastShift.Value.AsNumericRepresentationValue("mm"); } if (isoGuidanceShift.GuidanceNorthShift.HasValue) { adaptShift.NorthShift = isoGuidanceShift.GuidanceNorthShift.Value.AsNumericRepresentationValue("mm"); } if (isoGuidanceShift.PropagationOffset.HasValue) { adaptShift.PropagationOffset = isoGuidanceShift.PropagationOffset.Value.AsNumericRepresentationValue("mm"); } //Allocation Stamp if (isoGuidanceShift.AllocationStamp != null) { TimeScope scope = AllocationStampMapper.ImportAllocationStamp(isoGuidanceShift.AllocationStamp); DataModel.Catalog.TimeScopes.Add(scope); adaptShift.TimeScopeIds = new List <int>() { scope.Id.ReferenceId }; } return(adaptShift); }
public static void ShowPlayGameCenterLeaderboard(Leaderboard leaderboard, TimeScope timeScope = TimeScope.AllTime) { if (!instanceExists) { return; } if (!PlayGameCenterManager.isAuthenticated) { PlayGameCenterManager.TryAuthentication(true); } #if UNITY_IOS || UNITY_TVOS GameCenterBinding.showLeaderboardWithTimeScopeAndLeaderboard(TimeScope2GameCenterLeaderboardTimeScope(timeScope), instance.leaderboardInfos[(int)leaderboard].leaderboardId); #elif UNITY_ANDROID && !CHS PlayGameServices.showLeaderboard(instance.leaderboardInfos[(int)leaderboard].leaderboardId); #endif }
// Call only when successfully downloaded online leaderboard or when there is a change on leaderboard. public static void WriteTopScores(Leaderboard leaderboard = (Leaderboard)0, TimeScope timeScope = TimeScope.AllTime) { List <LeaderboardEntry> topScores = GetTopScores(leaderboard, timeScope); int loadTopScoreCount = topScores.Count; for (int i = 0, imax = LeaderboardManager.numLoadedTopScores; i < imax; i++) { if (i >= loadTopScoreCount) // This only happens in new leaderboard having not enough top scores { break; } PlayerPrefs.SetString(PREF_TOP_SCORES + leaderboard + timeScope + i, topScores[i].prefData); } OnTopScoresChange(leaderboard, timeScope); }
protected override void Awake() { base.Awake(); // Return and not initialize score variables, if no in-game leaderboard needed if (!hasInGameLeaderboards) { return; } // Init all arrays, lists and dictionaries here _myLeaderboardEntries = new LeaderboardEntry[EnumUtils.GetCount <Leaderboard>()]; for (int i = 0, imax = EnumUtils.GetCount <Leaderboard>(); i < imax; i++) { _topScoresAllTimeDict.Add((Leaderboard)i, new List <LeaderboardEntry>()); _topScoresWeekDict.Add((Leaderboard)i, new List <LeaderboardEntry>()); _topScoresTodayDict.Add((Leaderboard)i, new List <LeaderboardEntry>()); } // Read PlayerPref ReadMyLeaderboardScores(); ReadTopScores(); currentTimeScope = (TimeScope)PlayerPrefs.GetInt(PREF_CURRENT_TIME_SCOPE); for (int i = 0, imax = EnumUtils.GetCount <Leaderboard>(); i < imax; i++) { if (shouldLoadMyScores) { _isMyScoreLoadedDict.Add((Leaderboard)i, false); } if (shouldLoadTopScores) { _topScoresLoadedTimeScopeDict.Add((Leaderboard)i, TimeScope.AllTime); } } #if UNITY_IOS || UNITY_TVOS GameCenterManager.scoresLoadedEvent += OnTopScoresLoaded; GameCenterManager.scoresForPlayerIdsLoadedEvent += OnMyScoreLoaded; #elif UNITY_ANDROID && !CHS GPGManager.loadScoresSucceededEvent += OnTopScoresLoaded; GPGManager.loadCurrentPlayerLeaderboardScoreSucceededEvent += OnMyScoreLoaded; #endif PlayGameCenterManager.authenticationSucceededEvent += CheckshouldLoadTopScores; }
private LeaderboardScope fromTimeScope(TimeScope scope) { switch (scope) { case TimeScope.Today: return(LeaderboardScope.GlobalDay); case TimeScope.Week: return(LeaderboardScope.GlobalWeek); case TimeScope.AllTime: return(LeaderboardScope.GlobalAllTime); default: return(LeaderboardScope.GlobalAllTime); } }
/// <summary> /// Initializes a new instance of the <see cref="AGSSocialLeaderboard"/> class. /// </summary> /// <param name='leaderboard'> /// Leaderboard. /// </param> public AGSSocialLeaderboard(AGSLeaderboard leaderboard) { if (null == leaderboard) { AGSClient.LogGameCircleError("AGSSocialLeaderboard constructor \"leaderboard\" argument should not be null"); this.leaderboard = AGSLeaderboard.GetBlankLeaderboard(); } else { this.leaderboard = leaderboard; } id = leaderboard.id; scores = new AGSSocialLeaderboardScore[0]; localPlayerScore = -1; localPlayerRank = -1; _timeScope = TimeScope.AllTime; }
public void InIntervalDailyFixdTimeJobScheduleFrequencyTest() { DailyJobScheduleFrequency dailyFrequency = PrepareDailyJobSchedule(2); DateTime startTime = DateTime.Now.Date.AddDays(2); DateTime timePoint = startTime + new TimeSpan(10, 10, 10); TimeScope scope = dailyFrequency.GetTimeScope(startTime, timePoint, _TimeOffset); Assert.IsNotNull(scope); Console.WriteLine(scope.BeginTime); Console.WriteLine(scope.EndTime); Assert.AreEqual(new TimeSpan(10, 10, 10) - _TimeOffset, scope.BeginTime); Assert.AreEqual(new TimeSpan(10, 10, 10) + _TimeOffset, scope.EndTime); }
static LeaderboardTimeSpan ToGpgsLeaderboardTimeSpan(TimeScope timeScope) { switch (timeScope) { case TimeScope.AllTime: return(LeaderboardTimeSpan.AllTime); case TimeScope.Week: return(LeaderboardTimeSpan.Weekly); case TimeScope.Today: return(LeaderboardTimeSpan.Daily); default: return(LeaderboardTimeSpan.AllTime); } }
public void AfterMidnightFixedTimeFrequencyTest() { TimeSpan occurTime = new TimeSpan(0, 0, 0); FixedTimeFrequency frequency = new FixedTimeFrequency(occurTime); Console.WriteLine(frequency.Description); TimeScope scope = frequency.GetTimeScope(new TimeSpan(0, 0, 5), _TimeOffset); Assert.IsNotNull(scope); Console.WriteLine(scope.BeginTime); Console.WriteLine(scope.EndTime); Assert.AreEqual(occurTime - _TimeOffset, scope.BeginTime); Assert.AreEqual(occurTime + _TimeOffset, scope.EndTime); }
public Limit(PlayerScope playerScope, TimeScope timeScope, byte value) { this.PlayerScope = playerScope; this.TimeScope = timeScope; this.Value = value; }
private LeaderboardScope fromTimeScope(TimeScope scope) { switch (scope) { case TimeScope.Today: return LeaderboardScope.GlobalDay; case TimeScope.Week: return LeaderboardScope.GlobalWeek; case TimeScope.AllTime: return LeaderboardScope.GlobalAllTime; default: return LeaderboardScope.GlobalAllTime; } }
/// <summary> /// 获取排行榜的排名 /// </summary> /// <param name="id">排行榜ID</param> /// <param name="range">区间</param> /// <param name="onComplete">完成回调</param> /// <param name="scope">时间区间</param> /// <param name="userScope">用户区间</param> public void GetTopByByLeaderboardID(string id, Range range, System.Action<bool, IScore[]> onComplete, TimeScope scope = TimeScope.AllTime, UserScope userScope = UserScope.Global) { if (!Social.localUser.authenticated) return; ILeaderboard lb = Social.CreateLeaderboard(); Debug.Log(lb); if (lb == null) return; lb.id = id; lb.range = range; lb.timeScope = scope; lb.userScope = userScope; lb.LoadScores(ok => { onComplete(ok, lb.scores); }); }
public static void ShowLeaderboardUI(string leaderboardID, TimeScope timeScope) { Debug.Log("ShowLeaderboardUI - no effect in editor"); }
public AttackModifier(PhaseCode startPhase, ISource source, ICardInPlay target, TimeScope duration, int value) : base("Attack", startPhase, source, target, duration, value) { }
public ThreatModifier(PhaseCode startPhase, ISource source, IThreateningInPlay target, TimeScope duration, int value) : base("Threat", startPhase, source, target, duration, value) { }
public static void ShowLeaderboardUI(string leaderboardID, TimeScope timeScope){}
public WillpowerModifier(PhaseCode startPhase, ISource source, ICardInPlay target, TimeScope duration, int value) : base("Willpower", startPhase, source, target, duration, value) { }