I’m trying to detect whether an achievement is unlocked using OpenFeint but it always return all achievements as locked. Moreover, if I try to unlock the same achievement twice it two notifications that the achievement has been unlocked!
I’m using the OpenFeint plugin posted by Wozik but added achievements querying functionality:
http://forum.unity3d.com/threads/77546-OpenFeint-plugin-that-works-in-Unity-3.2/page3
Any clues?
The modified OpenFeintFacade.java:
package com.unity3d.Plugin;
import android.app.Activity;
import android.util.Log;
import com.openfeint.api.*;
import com.openfeint.api.ui.Dashboard;
import com.openfeint.api.resource.Score;
import com.openfeint.api.resource.Leaderboard;
import com.openfeint.api.resource.Achievement;
import android.util.Log;
public class OpenFeintFacade {
static public void Init(final Activity currentActivity, final OpenFeintSettings settings)
{
Log.d("OpenFeintFacade", "Init() called");
currentActivity.runOnUiThread (new Runnable () {
public void run ()
{
OpenFeint.initialize(currentActivity, settings, new OpenFeintDelegate() { });
} } );
}
static public void SubmitScore(String leaderboard, int score)
{
Log.d("OpenFeintFacade", "SubmitScore(" + score + ") on " + leaderboard);
Score s = new Score(score);
Leaderboard l = new Leaderboard(leaderboard);
s.submitTo(l, new Score.SubmitToCB()
{
public void onSuccess(boolean newHighScore)
{
Log.d("OpenFeintFacade", "Leaderboard submit score: success!");
}
public void onFailure(String exceptionMessage)
{
Log.d("OpenFeintFacade", "Leaderboard submit score: fail.");
}
});
}
static boolean busyReadingAchievement = false;
static Achievement achievement;
static public boolean IsAchievementUnlockedQueryInProgress()
{
return busyReadingAchievement;
}
static public boolean IsAchievementUnlocked()
{
return achievement.isUnlocked;
}
static public void StartIsAchievementUnlockedQuery(int achievementID)
{
busyReadingAchievement = true;
achievement = null;
achievement = new Achievement(Integer.toString(achievementID));
achievement.load(
new Achievement.LoadCB ()
{
public void onSuccess()
{
busyReadingAchievement = false;
Log.d("OpenFeintFacade", "Achievement load: success!");
}
public void onFailure(String exceptionMessage)
{
busyReadingAchievement = false;
Log.d("OpenFeintFacade", "Achievement load: fail.");
}
}
);
}
static public void SubmitAchievement(int achievementID)
{
new Achievement(Integer.toString(achievementID))
.unlock(
new Achievement.UnlockCB ()
{
public void onSuccess(boolean newUnlock)
{
Log.d("OpenFeintFacade", "Achievement submit: success!");
}
public void onFailure(String exceptionMessage)
{
Log.d("OpenFeintFacade", "Achievement submit: fail.");
}
}
);
}
}