Tic Tac Toe Example UserItem - TogetherGames/Public-Unity-CSharp GitHub Wiki
The UserItem screen displays all the info for a particular UserItem. the logged in user has obtained.
The DisplayText() method displays labels containing all the UserItems info. All the properties assigned to the UserItem are also displayed.
void DisplayText()
{
int labelY = 65;
int labelYStep = 30;
GUI.Label(new Rect((Screen.width - textWidth) * 0.5f, 15, textWidth, 100), "User Item", m_TitleStyle);
//Create and set the labels
GUI.Label(new Rect((Screen.width - textWidth) * 0.5f, labelY, textWidth, 100), "UserItemID =" + m_UserItem.Item.ItemID, m_TextStyle);
labelY += labelYStep;
GUI.Label(new Rect((Screen.width - textWidth) * 0.5f, labelY, textWidth, 100), "Name = " + m_UserItem.Item.Name, m_TextStyle);
labelY += labelYStep;
GUI.Label(new Rect((Screen.width - textWidth) * 0.5f, labelY, textWidth, 100), "Description = "+ m_UserItem.Item.Description, m_TextStyle);
labelY += labelYStep;
// Display all the UserItem properties.
if (m_UserItem.Properties.Properties != null)
{
foreach (Property property in m_UserItem.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 UserItems.
void DisplayButtons()
{
//Create and set the buttons
if( GUI.Button(new Rect(10, 50, 100, 50), "Back"))
Application.LoadLevel("UserItemsLobby");
if( GUI.Button(new Rect((Screen.width - 100) * 0.5f, Screen.height - 200, 100, 50), "Sell"))
{
Debug.Log("Sell");
Together.Instance.User.UserItemManager.Sell(m_UserItem.UserItemID, onUserItemAction);
}
if( GUI.Button(new Rect((Screen.width - 100) * 0.5f, Screen.height - 140, 100, 50), "Delete"))
{
Debug.Log("Delete");
Together.Instance.User.UserItemManager.Delete(m_UserItem.UserItemID, onUserItemAction);
}
}
When the Sell button is pressed, the UserItemManager.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.UserItemManager.Sell(m_UserItem.UserItemID, onUserItemAction);
}
When the Delete button is pressed, the UserItemManager.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.UserItemManager.Delete(m_UserItem.UserItemID, onUserItemAction);
}