Tic Tac Toe Example User Achievement - TogetherGames/Public-Unity-CSharp GitHub Wiki
The UserAchievement screen displays all the info for a particular UserAchievement. the logged in user has obtained.
The DisplayText() method displays labels containing all the UserAchievements info. All the properties assigned to the UserAchievement are also displayed.
void DisplayText()
{
int labelY = 65;
int labelYStep = 30;
GUI.Label(new Rect((Screen.width - 300) * 0.5f, 15,300,100), "User Achievement", m_TitleStyle);
//Create and set the labels
GUI.Label(new Rect((Screen.width - textWidth) * 0.5f, labelY, textWidth, 100), "UserAchievementID = " + m_UserAchievement.UserAchievementID, m_TextStyle);
labelY += labelYStep;
GUI.Label(new Rect((Screen.width - textWidth) * 0.5f, labelY, textWidth, 100), "RoomID ="+ m_UserAchievement.RoomID, m_TextStyle);
labelY += labelYStep;
GUI.Label(new Rect((Screen.width - textWidth) * 0.5f, labelY, textWidth, 100), "Required Count = "+ m_UserAchievement.RequiredCount, m_TextStyle);
labelY += labelYStep;
GUI.Label(new Rect((Screen.width - textWidth) * 0.5f, labelY, textWidth, 100), "Completed = "+ m_UserAchievement.Completed, m_TextStyle);
labelY += labelYStep;
GUI.Label(new Rect((Screen.width - textWidth) * 0.5f, labelY, textWidth, 100), "AchievementID ="+ m_UserAchievement.Achievement.AchievementID, m_TextStyle);
labelY += labelYStep;
GUI.Label(new Rect((Screen.width - textWidth) * 0.5f, labelY, textWidth, 100),"ActionName = "+ m_UserAchievement.Achievement.ActionName, m_TextStyle);
labelY += labelYStep;
GUI.Label(new Rect((Screen.width - textWidth) * 0.5f, labelY, textWidth, 100), "Name = "+ m_UserAchievement.Achievement.Name, m_TextStyle);
labelY += labelYStep;
GUI.Label(new Rect((Screen.width - textWidth) * 0.5f, labelY, textWidth, 100), "Description = "+ m_UserAchievement.Achievement.Description, m_TextStyle);
labelY += labelYStep;
GUI.Label(new Rect((Screen.width - textWidth) * 0.5f, labelY, textWidth, 100), "Required Count = "+ m_UserAchievement.RequiredCount, m_TextStyle);
labelY += labelYStep;
// Display all the UserAchievement properties.
if (m_UserAchievement.Properties.Properties != null)
{
foreach (Property property in m_UserAchievement.Properties.Properties)
{
GUI.Label(new Rect((Screen.width - textWidth) * 0.5f, labelY, textWidth, 100), property.Name + " = " + property.Value, m_TextStyle);
labelY += labelYStep;
}
}
}
The DisplayButtons() method displays buttons allowing the User to Sell and Delete UserAchievements.
void DisplayButtons()
{
//Create and set the buttons
if( GUI.Button(new Rect(10, 50, 100, 50), "Back"))
Application.LoadLevel("UserAchievementsLobby");
if( GUI.Button(new Rect((Screen.width - 100) * 0.5f, Screen.height - 200, 100, 50), "Sell"))
{
Debug.Log("Sell");
Together.Instance.User.UserAchievementManager.Sell(m_UserAchievement.UserAchievementID, onUserAchievementsReloaded);
}
if( GUI.Button(new Rect((Screen.width - 100) * 0.5f, Screen.height - 140, 100, 50), "Delete"))
{
Debug.Log("Delete");
Together.Instance.User.UserAchievementManager.Delete(m_UserAchievement.UserAchievementID, onUserAchievementAction);
}
}
When the Sell button is pressed, the UserAchievementManager.Sell() method is called.
if( GUI.Button(new Rect((Screen.width - 100) * 0.5f, Screen.height - 200, 100, 50), "Sell"))
{
Debug.Log("Sell");
Together.Instance.User.UserAchievementManager.Sell(m_UserAchievement.UserAchievementID, onUserAchievementsReloaded);
}
When the Delete button is pressed, the UserAchievementManager.Delete() method is called.
if( GUI.Button(new Rect((Screen.width - 100) * 0.5f, Screen.height - 140, 100, 50), "Delete"))
{
Debug.Log("Delete");
Together.Instance.User.UserAchievementManager.Delete(m_UserAchievement.UserAchievementID, onUserAchievementAction);
}