-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from TaloDev/develop
Release 0.21.0
- Loading branch information
Showing
8 changed files
with
135 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
Packages/com.trytalo.talo/Runtime/Utils/LeaderboardEntriesManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace TaloGameServices | ||
{ | ||
public class LeaderboardEntriesManager | ||
{ | ||
private Dictionary<string, List<LeaderboardEntry>> _currentEntries = new Dictionary<string, List<LeaderboardEntry>>(); | ||
|
||
public List<LeaderboardEntry> GetEntries(string internalName) | ||
{ | ||
if (_currentEntries.ContainsKey(internalName)) | ||
{ | ||
return _currentEntries[internalName]; | ||
} | ||
return new List<LeaderboardEntry>(); | ||
} | ||
|
||
public void UpsertEntry(string internalName, LeaderboardEntry entry) | ||
{ | ||
if (!_currentEntries.ContainsKey(internalName)) | ||
{ | ||
_currentEntries[internalName] = new List<LeaderboardEntry>(); | ||
} | ||
else | ||
{ | ||
_currentEntries[internalName].RemoveAll(e => e.id == entry.id); | ||
} | ||
|
||
_currentEntries[internalName].Insert(entry.position, entry); | ||
|
||
for (int idx = entry.position; idx < _currentEntries[internalName].Count; idx++) | ||
{ | ||
_currentEntries[internalName][idx].position = idx; | ||
} | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Packages/com.trytalo.talo/Runtime/Utils/LeaderboardEntriesManager.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.