94 lines
2.2 KiB
C#
94 lines
2.2 KiB
C#
using Steamworks;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class InviteFriendItem : MonoBehaviour
|
|
{
|
|
public CSteamID Player_id;
|
|
|
|
public TournamentPlayerCreator tournamentPlayerCreator;
|
|
|
|
[SerializeField]
|
|
private RawImage AvatarImage;
|
|
|
|
[SerializeField]
|
|
public Text PlayerNameText;
|
|
|
|
[SerializeField]
|
|
public Image InGameImage;
|
|
|
|
[SerializeField]
|
|
private Color[] InGameStatusColor;
|
|
|
|
[SerializeField]
|
|
private Button AddButton;
|
|
|
|
[SerializeField]
|
|
private Button RemoveButton;
|
|
|
|
private SteamShowAvatarByUserId avatar;
|
|
|
|
private bool isActive;
|
|
|
|
private void Start()
|
|
{
|
|
avatar = AvatarImage.GetComponent<SteamShowAvatarByUserId>();
|
|
avatar.steamUserID = Player_id.m_SteamID;
|
|
CheckStatusInGame();
|
|
InvokeRepeating("CheckStatusInGame", 1f, 1f);
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (tournamentPlayerCreator.InvitePlayerContent.childCount > 4)
|
|
{
|
|
RemoveInviteButton();
|
|
}
|
|
else if (tournamentPlayerCreator.InvitePlayerContent.childCount == 4)
|
|
{
|
|
AddButton.interactable = false;
|
|
}
|
|
else
|
|
{
|
|
AddButton.interactable = true;
|
|
}
|
|
}
|
|
|
|
private void CheckStatusInGame()
|
|
{
|
|
if (SteamFriends.GetFriendGamePlayed(Player_id, out var _))
|
|
{
|
|
Debug.Log("JEST");
|
|
if (!isActive)
|
|
{
|
|
InGameImage.color = InGameStatusColor[1];
|
|
base.transform.SetAsFirstSibling();
|
|
isActive = true;
|
|
}
|
|
}
|
|
else if (isActive)
|
|
{
|
|
InGameImage.color = InGameStatusColor[0];
|
|
isActive = false;
|
|
}
|
|
}
|
|
|
|
public void AddFriendButton()
|
|
{
|
|
base.transform.SetParent(tournamentPlayerCreator.InvitePlayerContent);
|
|
AddButton.gameObject.SetActive(value: false);
|
|
RemoveButton.gameObject.SetActive(value: true);
|
|
tournamentPlayerCreator.numOfParticipantsInvited++;
|
|
tournamentPlayerCreator.tournamentNumParticipantsDropdown.captionText.text = tournamentPlayerCreator.numOfParticipantsInvited.ToString();
|
|
}
|
|
|
|
public void RemoveInviteButton()
|
|
{
|
|
base.transform.SetParent(tournamentPlayerCreator.FriendsContent);
|
|
AddButton.gameObject.SetActive(value: true);
|
|
RemoveButton.gameObject.SetActive(value: false);
|
|
tournamentPlayerCreator.numOfParticipantsInvited--;
|
|
tournamentPlayerCreator.tournamentNumParticipantsDropdown.captionText.text = tournamentPlayerCreator.numOfParticipantsInvited.ToString();
|
|
}
|
|
}
|