93 lines
2.4 KiB
C#
93 lines
2.4 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class ProfileSlot : MonoBehaviour
|
|
{
|
|
public int slotID;
|
|
|
|
public GameObject profileContainer;
|
|
|
|
public GameObject genderContainer;
|
|
|
|
public GameObject chooseBtn;
|
|
|
|
public Hover[] genderOptions;
|
|
|
|
public GameObject[] profileGameModeBtns;
|
|
|
|
public string profileName = "Enter your profile name...";
|
|
|
|
public InputField profileNameText;
|
|
|
|
public Text profileLevelText;
|
|
|
|
public Text profileTotalFishText;
|
|
|
|
private ProfileCreation profileCreation;
|
|
|
|
private void Start()
|
|
{
|
|
profileCreation = Object.FindObjectOfType<ProfileCreation>();
|
|
}
|
|
|
|
public void SelectGameModeBtn(int index)
|
|
{
|
|
profileCreation.SelectGameMode(slotID, index);
|
|
}
|
|
|
|
public void ShowGenderSelection()
|
|
{
|
|
genderContainer.SetActive(value: true);
|
|
genderOptions[0].isSelected = false;
|
|
genderOptions[1].isSelected = false;
|
|
genderOptions[Singleton<SaveDataManager>.Instance.GetSpecifiedPlayerData(slotID).PlayerSexIndex].isSelected = true;
|
|
}
|
|
|
|
public void SetGender(int gendderIndex)
|
|
{
|
|
Singleton<SaveDataManager>.Instance.GetSpecifiedPlayerData(slotID).PlayerSexIndex = gendderIndex;
|
|
ShowGenderSelection();
|
|
}
|
|
|
|
public void SetProfileName()
|
|
{
|
|
if (profileNameText.text == "")
|
|
{
|
|
profileNameText.placeholder.GetComponent<Text>().text = LanguageManager.Instance.GetText("ENTER_NAME");
|
|
return;
|
|
}
|
|
for (int i = 0; i < GameManager.Instance._playerData.Player.Count; i++)
|
|
{
|
|
if (profileNameText.text == Singleton<SaveDataManager>.Instance.GetSpecifiedPlayerData(i).PlayerName)
|
|
{
|
|
if (!(Singleton<SaveDataManager>.Instance.GetSpecifiedPlayerData(slotID).PlayerName == Singleton<SaveDataManager>.Instance.GetSpecifiedPlayerData(i).PlayerName))
|
|
{
|
|
profileNameText.text = "";
|
|
profileNameText.placeholder.GetComponent<Text>().text = LanguageManager.Instance.GetText("PROFILE_NAME_EXIST");
|
|
profileNameText.interactable = true;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
Singleton<SaveDataManager>.Instance.GetSpecifiedPlayerData(slotID).PlayerName = profileNameText.text;
|
|
profileCreation.ShowProfileSlots();
|
|
}
|
|
|
|
public void onEditName()
|
|
{
|
|
profileNameText.text = profileNameText.text.Replace(" ", "");
|
|
}
|
|
|
|
public void ChooseProfile()
|
|
{
|
|
profileCreation.ChooseProfile(slotID);
|
|
Object.FindObjectOfType<BottomBar>().InitializeBackgroundMusic();
|
|
}
|
|
|
|
public void DeleteProfile()
|
|
{
|
|
profileCreation.profileIDtoDellete = slotID;
|
|
GameManager.Instance.CreateMessageBox("DELETE_PROFILE_QUESTION", Object.FindObjectOfType<MainGameScene>().transform, 5);
|
|
}
|
|
}
|