148 lines
4.4 KiB
C#
148 lines
4.4 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class SteamUserWidget : MonoBehaviour
|
|
{
|
|
public bool isForFishingPlayerRemote;
|
|
|
|
public Image mediumAvatar;
|
|
|
|
public Image stateImage;
|
|
|
|
public Text nameText;
|
|
|
|
public Text scoreText;
|
|
|
|
public Text levelText;
|
|
|
|
public Text experienceText;
|
|
|
|
public Text totalFishCountText;
|
|
|
|
public Text totalFishWeightText;
|
|
|
|
public Text biggestFishSpeciesText;
|
|
|
|
public Text biggestFishWeightText;
|
|
|
|
public Button inviteBtn;
|
|
|
|
public Button addFriendBtn;
|
|
|
|
public Text showSteamBtnText;
|
|
|
|
[HideInInspector]
|
|
public bool showInviteBtn = true;
|
|
|
|
public SteamStatsManager.SteamUser steamUser;
|
|
|
|
public PhotonPlayer photonPlayer;
|
|
|
|
public FishingPlayerRemote fishingPlayerRemote;
|
|
|
|
private void Start()
|
|
{
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if ((bool)GlobalSettings.Instance)
|
|
{
|
|
inviteBtn.interactable = (bool)GameController.Instance && PhotonNetwork.room != null;
|
|
if (steamUser.platformProfileID == GlobalSettings.Instance.GetPlatformProfileID())
|
|
{
|
|
addFriendBtn.interactable = false;
|
|
}
|
|
else
|
|
{
|
|
addFriendBtn.interactable = (bool)GameController.Instance && PhotonNetwork.room != null && !SteamStatsManager.Instance.IsUserAFriend(steamUser);
|
|
}
|
|
if (isForFishingPlayerRemote && base.gameObject.activeSelf && fishingPlayerRemote == null)
|
|
{
|
|
base.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Refresh()
|
|
{
|
|
if (steamUser == null)
|
|
{
|
|
return;
|
|
}
|
|
if (photonPlayer != null)
|
|
{
|
|
SteamStatsManager.Instance.PhotonPlayerToSteamUser(steamUser, photonPlayer);
|
|
}
|
|
inviteBtn.gameObject.SetActive(showInviteBtn && !isForFishingPlayerRemote);
|
|
addFriendBtn.gameObject.SetActive(!showInviteBtn && !isForFishingPlayerRemote);
|
|
if ((bool)showSteamBtnText)
|
|
{
|
|
showSteamBtnText.text = "Steam";
|
|
}
|
|
if ((bool)steamUser.avatarMedium)
|
|
{
|
|
mediumAvatar.sprite = Sprite.Create(steamUser.avatarMedium, new Rect(0f, 0f, steamUser.avatarMedium.width, steamUser.avatarMedium.height), new Vector2(0.5f, 0.5f));
|
|
}
|
|
else
|
|
{
|
|
mediumAvatar.sprite = null;
|
|
}
|
|
mediumAvatar.gameObject.SetActive(mediumAvatar.sprite != null);
|
|
if ((bool)SteamStatsManager.Instance)
|
|
{
|
|
stateImage.color = SteamStatsManager.Instance.GetUserStateColor(steamUser);
|
|
}
|
|
nameText.text = steamUser.friendName;
|
|
if (steamUser.level == 0)
|
|
{
|
|
scoreText.text = Utilities.GetTranslation("LEADERBOARDS/SCORE") + ": -";
|
|
levelText.text = Utilities.GetTranslation("LEADERBOARDS/LEVEL") + ": -";
|
|
experienceText.text = Utilities.GetTranslation("LEADERBOARDS/EXP") + ": -";
|
|
totalFishCountText.text = Utilities.GetTranslation("LEADERBOARDS/FISH_COUNT") + ": -";
|
|
totalFishWeightText.text = Utilities.GetTranslation("LEADERBOARDS/TOTAL_WEIGHT") + ": -";
|
|
biggestFishSpeciesText.text = Utilities.GetTranslation("LEADERBOARDS/BIGGEST_FISH") + ": -";
|
|
biggestFishWeightText.text = Utilities.GetTranslation("LEADERBOARDS/BIGGEST_WEIGHT") + ": -";
|
|
return;
|
|
}
|
|
scoreText.text = Utilities.GetTranslation("LEADERBOARDS/SCORE") + ": " + steamUser.score;
|
|
levelText.text = Utilities.GetTranslation("LEADERBOARDS/LEVEL") + ": " + steamUser.level;
|
|
experienceText.text = Utilities.GetTranslation("LEADERBOARDS/EXP") + ": " + steamUser.experience;
|
|
totalFishCountText.text = Utilities.GetTranslation("LEADERBOARDS/FISH_COUNT") + ": " + steamUser.totalFishCount;
|
|
totalFishWeightText.text = Utilities.GetTranslation("LEADERBOARDS/TOTAL_WEIGHT") + ": " + UtilitiesUnits.GetWeightString((float)steamUser.totalFishWeight * 0.001f);
|
|
biggestFishWeightText.text = Utilities.GetTranslation("LEADERBOARDS/BIGGEST_WEIGHT") + ": ";
|
|
if (steamUser.biggestFishWeight == -1 || steamUser.totalFishCount == 0)
|
|
{
|
|
biggestFishWeightText.text += "-";
|
|
}
|
|
else
|
|
{
|
|
biggestFishWeightText.text += UtilitiesUnits.GetWeightString((float)steamUser.biggestFishWeight * 0.001f);
|
|
}
|
|
biggestFishSpeciesText.text = Utilities.GetTranslation("LEADERBOARDS/BIGGEST_FISH") + ":\n";
|
|
if (steamUser.biggestFishSpecies == -1 || steamUser.totalFishCount == 0)
|
|
{
|
|
biggestFishSpeciesText.text += "-";
|
|
}
|
|
else if ((bool)GlobalSettings.Instance)
|
|
{
|
|
biggestFishSpeciesText.text += Utilities.GetTranslation(GlobalSettings.Instance.fishManager.GetFishDefinition((Fish.Species)steamUser.biggestFishSpecies).fishPrefab.fishName);
|
|
}
|
|
}
|
|
|
|
public void InviteFriend()
|
|
{
|
|
SteamStatsManager.Instance.InviteFriend(steamUser);
|
|
}
|
|
|
|
public void AddFriend()
|
|
{
|
|
SteamStatsManager.Instance.AddFriend(steamUser);
|
|
}
|
|
|
|
public void ShowSteamUser()
|
|
{
|
|
SteamStatsManager.Instance.ShowSteamUser(steamUser);
|
|
}
|
|
}
|