Hi
I’m still pretty green when it comes to c# and events. Yes I’ve watched the videos and read the docs, but nothing is sinking in quite yet. I’m more of a ‘visual’, learn by example kind of person I guess.
I’m struggling to sort out the following problem:
- When the parameters of an achievement that is already unlocked are met again in game, to not show the achievement completion banner and not register the achievement to Gamecenter again.
What I’ve done so far :
public static List<GameCenterAchievement> achievements;
void Awake ()
{
GameCenterBinding.isGameCenterAvailable();
}
void Start()
{
if (GameCenterBinding.isGameCenterAvailable() )
{
GameCenterBinding.authenticateLocalPlayer(); //Must Have
GameCenterBinding.showCompletionBannerForAchievements(); //Display banners on Achievement Unlocks...
GameCenterBinding.loadReceivedChallenges();
// GameCenterBinding.getAchievements();
}
//Listener
GameCenterManager.achievementsLoaded += achievementStatus;
}
void OnEnable()
{
//Listener for the achievements Loaded event
GameCenterManager.achievementsLoaded += achievementStatus;
}
void OnDisable()
{
GameCenterManager.achievementsLoaded -= achievementStatus;
}
void achievementStatus( List<GameCenterAchievement> achievements )
{
foreach( var achievement in achievements )
{
Debug.Log (achievement);
}
}
//Update the GC with a new unlocked achievement
public static void ReportAchievement(string id)
{
foreach (GameCenterAchievement s in achievements)
{
if (s.identifier == id)
{
Debug.Log ("Achievement already completed");
}
else
{
Debug.Log("Unlocked Achievement: "+id);
GameCenterBinding.reportAchievement( id, 100 );
}
}
}
}
<pre></pre>
So when achievement parameters are met in-game I call "GameCenterGameManager.ReportAchievement(“ach_01”);
However, doing so crashes the game…
Obviously, I’m doing something very wrong and am hoping someone might be able to shed some light on this for me.
What I’m trying to do is when I report a potentially accomplished achievement, I check (through identifier matching my id) that the achievement isn’t already logged as completed (from achievementsLoaded event)
Any feedback or advice on this is appreciated.
And be kind! I am but an artist/designer.
Thanks!