private void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } DontDestroyOnLoad(this); achievementLibrary = GetComponent <AchievementLibrary>(); }
public override void Initialize(AchievementLibrary data) { base.Initialize(data); }
//Inititialization public virtual void Initialize(AchievementLibrary data) { //create base achievement data achievements = new Achievement[data.CoreData.Length]; for (int i = 0; i < achievements.Length; i++) { achievements[i] = data.CoreData[i].CreateAchievement(); } //create base activity var activityIDs = ActivityID.GetInt; activities = new Activity[activityIDs.Length]; for (int i = 0; i < activityIDs.Length; i++) { activities[i] = new Activity() { ID = activityIDs[i], Value = 0 }; } //create base progress progress = new AchievementProgress[achievements.Length]; for (int i = 0; i < progress.Length; i++) { var unlocked = false; AchievementCondition[] conditions = null; foreach (AchievementData achData in data.CoreData) { if (achData.achievementID == achievements[i].ID) { unlocked = true; conditions = achData.Conditions; break; } } progress[i] = new AchievementProgress() { achievementID = achievements[i].ID, Unlock = unlocked }; if (conditions != null) { progress[i].conditionProgresses = new ConditionProgress[conditions.Length]; for (int j = 0; j < progress[i].conditionProgresses.Length; j++) { progress[i].conditionProgresses[j] = new ConditionProgress() { conditionID = conditions[j].activityID, completeStatus = 0 }; } } } //create base group groups = new AchievementGroup[data.GroupData.Length]; for (int i = 0; i < groups.Length; i++) { groups[i] = data.GroupData[i].CreateAchievementGroup(); } newUnlockedAchievements = new List <int>(); }