RiftMayhem/Assets/Scripts/SetCharacterName.cs
Pedro Gomes 410e28e046 Player account update
- Added Player account data with list of characters
- Added character selection scene
- Loading and saving characters flow working with account names as filters
2024-07-17 11:59:51 +01:00

42 lines
1.0 KiB
C#

using Photon.Pun;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SetCharacterName : SetNickName
{
[SerializeField] protected StringSharedField playerAccountName;
protected PlayerAccountData accountData;
protected override void Start()
{
base.Start();
accountData = PlayerDataHandler.Instance.LoadPlayerAccountData(playerAccountName.Value);
}
public override void OnInputFieldChanged(string value)
{
if(accountData != null)
{
if (accountData.PlayerContainsCharacter(value))
{
button.interactable = false;
return;
}
}
base.OnInputFieldChanged(value);
}
public void SaveCharacterOnAccountData()
{
accountData.AddCharacterToPlayerAccount(insertedName.Value);
PhotonNetwork.NickName = insertedName.Value;
PlayerDataHandler.Instance.SavePlayerAccountData(playerAccountName.Value, accountData);
}
}