Skip to content

Instantly share code, notes, and snippets.

@lambdan
Created October 18, 2022 18:55
Show Gist options
  • Save lambdan/0ac3b13ccdd2d89c03dab756a74d74e3 to your computer and use it in GitHub Desktop.
Save lambdan/0ac3b13ccdd2d89c03dab756a74d74e3 to your computer and use it in GitHub Desktop.
using TMPro;
using UnityEngine;
[RequireComponent(typeof(OnlineScoreRecorder))]
public class OldSchoolNameEntry : MonoBehaviour
{
[SerializeField] private TMP_Text _firstLetterButton;
[SerializeField] private TMP_Text _secondLetterButton;
[SerializeField] private TMP_Text _thirdLetterButton;
private int firstChar = (int)'A';
private int secondChar = (int)'A';
private int thirdChar = (int)'A';
private int score;
public void SetScore(int newScore)
{
score = newScore;
}
public void FirstChanged()
{
firstChar += 1;
if (firstChar > (int)'Z')
{
firstChar = (int)'A';
}
_firstLetterButton.text = ((char)firstChar).ToString();
}
public void SecondChanged()
{
secondChar += 1;
if (secondChar > (int)'Z')
{
secondChar = (int)'A';
}
_secondLetterButton.text = ((char)secondChar).ToString();
}
public void ThirdChanged()
{
thirdChar += 1;
if (thirdChar > (int)'Z')
{
thirdChar = (int)'A';
}
_thirdLetterButton.text = ((char)thirdChar).ToString();
}
public string GetName()
{
return ((char)firstChar).ToString() + ((char)secondChar).ToString() + ((char)thirdChar).ToString();
}
public void Submit()
{
GetComponent<OnlineScoreRecorder>().RecordScoreOnline(GetName(), score);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment