|
|
@ -45,6 +45,7 @@ public class AchievementManager : MonoBehaviour
|
|
|
|
public static AchievementManager instance = null; //Singleton Instance
|
|
|
|
public static AchievementManager instance = null; //Singleton Instance
|
|
|
|
public AchievenmentStack Stack;
|
|
|
|
public AchievenmentStack Stack;
|
|
|
|
public Button ClaimRewardButton;
|
|
|
|
public Button ClaimRewardButton;
|
|
|
|
|
|
|
|
public AchievenmentListIngame achievementListIngame;
|
|
|
|
|
|
|
|
|
|
|
|
void Awake()
|
|
|
|
void Awake()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -138,17 +139,9 @@ public class AchievementManager : MonoBehaviour
|
|
|
|
float nt;
|
|
|
|
float nt;
|
|
|
|
float tot = animTime;
|
|
|
|
float tot = animTime;
|
|
|
|
Text coinTxt = null;
|
|
|
|
Text coinTxt = null;
|
|
|
|
if(FindAnyObjectByType<HomeScene>()!=null)
|
|
|
|
HomeScene homeScene = FindAnyObjectByType<HomeScene>();
|
|
|
|
{
|
|
|
|
coinTxt = homeScene.coinLbl;
|
|
|
|
coinTxt = FindAnyObjectByType<HomeScene>().coinLbl;
|
|
|
|
coinTxt.transform.DOShakePosition(1f);
|
|
|
|
coinTxt.transform.DOShakePosition(0.5f);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(FindAnyObjectByType<GameScene>()!=null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
coinTxt = FindAnyObjectByType<GameScene>().coinLbl;
|
|
|
|
|
|
|
|
coinTxt.transform.DOShakePosition(0.5f);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//coinTxt.transform.DOShakePosition(0.5f);
|
|
|
|
//coinTxt.transform.DOShakePosition(0.5f);
|
|
|
|
// coinTxt.GetComponent<Animation>().Play("textShake");
|
|
|
|
// coinTxt.GetComponent<Animation>().Play("textShake");
|
|
|
|
while (ct < tot)
|
|
|
|
while (ct < tot)
|
|
|
@ -166,19 +159,37 @@ public class AchievementManager : MonoBehaviour
|
|
|
|
/// Fully unlocks a progression or goal achievement.
|
|
|
|
/// Fully unlocks a progression or goal achievement.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="Index">The index of the achievement to be unlocked</param>
|
|
|
|
/// <param name="Index">The index of the achievement to be unlocked</param>
|
|
|
|
|
|
|
|
public void ButtonSetterForUnlockedAcheivement(int index)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Debug.Log("ButtonSetterForUnlockedAcheivement");
|
|
|
|
|
|
|
|
int numOfCoins = AchievementList[index].TotalCoinReward;
|
|
|
|
|
|
|
|
//int numOfCoins = AchievementList[index].CoinRewards[AchievementList[index].SubAchievementIndex];
|
|
|
|
|
|
|
|
achievementListIngame.Stack[index].ClaimButton.gameObject.SetActive(true);
|
|
|
|
|
|
|
|
achievementListIngame.Stack[index].ClaimButton.onClick.AddListener(() => AddCoins(numOfCoins));
|
|
|
|
|
|
|
|
achievementListIngame.Stack[index].CompleteToClaimButton.SetActive(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
public void Unlock(int Index)
|
|
|
|
public void Unlock(int Index)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!States[Index].Achieved)
|
|
|
|
if (!States[Index].Achieved)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int numOfCoins = AchievementList[Index].CoinRewards[AchievementList[Index].SubAchievementIndex];
|
|
|
|
//ButtonSetterForUnlockedAcheivement(Index);
|
|
|
|
ClaimRewardButton.onClick.AddListener(() => AddCoins(numOfCoins));
|
|
|
|
|
|
|
|
|
|
|
|
//ClaimRewardButton.onClick.AddListener(() => AddCoins(numOfCoins));
|
|
|
|
// Set current progress to the achievement's progress goal
|
|
|
|
// Set current progress to the achievement's progress goal
|
|
|
|
States[Index].Progress = AchievementList[Index].ProgressGoal;
|
|
|
|
States[Index].Progress = AchievementList[Index].ProgressGoal;
|
|
|
|
|
|
|
|
|
|
|
|
var achievementInfromation = AchievementList[Index];
|
|
|
|
var achievementInfromation = AchievementList[Index];
|
|
|
|
achievementInfromation.ProgressGoal += 5;
|
|
|
|
|
|
|
|
States[Index].LastProgressGoal = achievementInfromation.ProgressGoal;
|
|
|
|
States[Index].LastProgressGoal = achievementInfromation.ProgressGoal;
|
|
|
|
|
|
|
|
PlayerPrefs.SetInt("UIAchievement" + Index + "Claimable", 1);
|
|
|
|
|
|
|
|
int numOfPrevCoins = PlayerPrefs.GetInt("TotalCoinsForReward" + Index, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int subAchievementIndex = PlayerPrefs.GetInt("subAchievementIndex" + Index, 0);
|
|
|
|
|
|
|
|
Debug.Log("SubAchievementIndex for " + Index + ": " + subAchievementIndex);
|
|
|
|
|
|
|
|
PlayerPrefs.SetInt("TotalCoinsForReward" + Index, numOfPrevCoins + achievementInfromation.CoinRewards[Mathf.Clamp(subAchievementIndex,0, achievementInfromation.CoinRewards.Count-1)]);
|
|
|
|
|
|
|
|
subAchievementIndex++;
|
|
|
|
|
|
|
|
PlayerPrefs.SetInt("subAchievementIndex" + Index, subAchievementIndex);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
achievementInfromation.ProgressGoal += 5;
|
|
|
|
// Check if the new progress goal has reached or exceeded 50
|
|
|
|
// Check if the new progress goal has reached or exceeded 50
|
|
|
|
if (AchievementList[Index].ProgressGoal >= 50)
|
|
|
|
if (AchievementList[Index].ProgressGoal >= 50)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -196,10 +207,15 @@ public class AchievementManager : MonoBehaviour
|
|
|
|
bool CompletedAll = (Find == -1 || AchievementList[Find].Key.Equals(FinalAchievementKey));
|
|
|
|
bool CompletedAll = (Find == -1 || AchievementList[Find].Key.Equals(FinalAchievementKey));
|
|
|
|
if (CompletedAll)
|
|
|
|
if (CompletedAll)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
//ButtonSetterForUnlockedAcheivement(Index);
|
|
|
|
Unlock(FinalAchievementKey); // Unlock the final achievement if all others are completed
|
|
|
|
Unlock(FinalAchievementKey); // Unlock the final achievement if all others are completed
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ButtonSetterForUnlockedAcheivement(Index);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|