Here you will see how to use the achievement system package
You need to add this component to your Packages/manifest file
"ie.itcarlow.achievementsystem":"https://github.com/itcOnlineGaming/Achievement_System.git?path=/Achievement System/Packages/ie.itcarlow.achievementsystem"
Here you can customize various parts of the achievement pop up by calling a singelton class, which will globablly effect all achievements by default. This can be changed to swap between this singeltons global setting to use alternatice settings here : .
-
Call the singeleton instance
AchievementPopUpGlobalSettings.settings
. -
**THen customise any of the following aspects of the achievement pop:
AchievementPopUpGlobalSettings.settings.timeToLive; // how long it will stay on screen for AchievementPopUpGlobalSettings.settings.postion; // position on screen AchievementPopUpGlobalSettings.settings.textFont; // font AchievementPopUpGlobalSettings.settings.textColor; // color of text AchievementPopUpGlobalSettings.settings.textPadding; // space between the text and the edge of the pop up background AchievementPopUpGlobalSettings.settings.backgroundSize; // size of background size AchievementPopUpGlobalSettings.settings.backgroundColor; // color of background
Here you can see how to add a profile to the achievement system.
- Call the singeleton instances function to add a profile to the system
AchievementSystem.Instance.addProfile( t_username, t_displayNameOnPopUp )
t_username
will assign a name to the user.t_displayNameOnPopUp
boolean willdetermine whether you want that name to be displayed on the achievement pop up.- This function will return an integer which will correspond to the profile you added to the system and is used to retrieve said profile from the system.
- To get a players profile call:
AchievementSystem.getProfile( playerIndex )
- The players are kept in a list, to retrieve them you must keep track of the index.
- Used the previously return integer to access the profile.
-
The profile constains also contains a list of completed achievements and uncompleted achievements to keep track of progress.
-
If you want to directly add to the lists of completed achievements of a specific profile, call:
AchievementSystem.Instance.addCompletedAchievement( int t_playerIndex, string t_achievement)
- This could be used if you want to fill the list of completed achievements from sonme save data before the games starts from a file or player prefs.
Achievements are tracked with strings, the string will also be the title of the achievement on the Pop Up.
- T o add an achievemnt to all existing profiles in the system, Call:
AchievementSystem.Instance.AddAchievementToProfiles( string t_achievement)
- This function will not add an achievement to a profile that has it listed as a completed achievement.
- ** To complete an achievemnt, Call: .
AchievementSystem.Instance.CompletedAchievement(int playerIndex, string t_achievement)
- this will remove the achievement from the uncompleted achievment list to the completed achievment list of the passed in profile index.
- this will also create a pop up in game, the settings for which are specified Pop-Up Visuals
- if more than 1 achievement is called at once they will be staggered so they don't obscure each other.
The system saves achievements evertime they are completed to the profile automaitically so no need for additional code.
The user can also specify whether to use settings that are not the global ones, if for some reason you wanted to use a different background for a specific achievement. This must be done on a case by case basis.
// create yoru new settings ( doesnt need to be done multiple times, as is stored)
AchievementPopUpSetting newsettings;
newSettings.timeToLive = 5;
newSettings.postion = new Vector2( 200, 200);
newSettings.textFont = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
newSettings.textColor = Color.White;
newSettings.textPadding = new Vector2( 10, 10);
newSettings.backgroundSize = new Vector2( 200, 200);
// assign to the system
AchievementSystem.Instance.userDefinedSettings = newsettings;
// tell system to use the stored settings ( this will have to be switched if you want to go back to using global settings)
AchievementSystem.Instance.useGlobalDefaults = false;
// complete achievement which will creat pop up with the above alternative setting to global
AchievementSystem.Instance.CompletedAchievement( index, achievement.string );
// If you want settings goiong forward to be be back to global settings
AchievementSystem.Instance.useGlobalDefaults = true;