You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
2.8 KiB
C#
98 lines
2.8 KiB
C#
2 weeks ago
|
|
||
|
using TMPro;
|
||
|
using UnityEngine;
|
||
|
using System.Linq;
|
||
|
using UnityEngine.UI;
|
||
|
using System.Collections.Generic;
|
||
|
|
||
|
public abstract class Panel_CharacterCreation : TWS_UIPanel
|
||
|
{
|
||
|
public bool isMalePanel;
|
||
|
|
||
|
public Sprite buttonBG_SelectedState;
|
||
|
public Sprite buttonBG_UnSelectedState;
|
||
|
public List<Button> attributesButtons;
|
||
|
|
||
|
public TMP_InputField playerName;
|
||
|
|
||
|
public override void Initialize()
|
||
|
{
|
||
|
SpawnPreviewCharacter();
|
||
|
|
||
|
attributesButtons.ForEach(x =>
|
||
|
{
|
||
|
x.onClick.AddListener(() =>
|
||
|
{
|
||
|
DisableAllButtons();
|
||
|
Image btn = x.GetComponentsInParent<Image>().ToList()[1];
|
||
|
btn.sprite = buttonBG_SelectedState;
|
||
|
btn.SetNativeSize();
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
|
||
|
void SpawnPreviewCharacter()
|
||
|
{
|
||
|
TWS_PreviewCharacterSpawner.Instance.SpawnPreviewCharacter(isMalePanel);
|
||
|
}
|
||
|
|
||
|
public override void OnPanelClosed()
|
||
|
{
|
||
|
}
|
||
|
public void OnBtnSelectHairColorClicked()
|
||
|
{
|
||
|
(UI_Manager.Instance.OpenPanel<Panel_HairColorCustomization>() as Panel_HairColorCustomization).isMale = isMalePanel;
|
||
|
}
|
||
|
|
||
|
public void OnBtnSelectSkinColorClicked()
|
||
|
{
|
||
|
(UI_Manager.Instance.OpenPanel<Panel_SkinColorCustomization>() as Panel_SkinColorCustomization).isMale = isMalePanel;
|
||
|
}
|
||
|
public void OnBtnSelectTattooClicked()
|
||
|
{
|
||
|
(UI_Manager.Instance.OpenPanel<Panel_TatooCustomization>() as Panel_TatooCustomization).isMale = isMalePanel;
|
||
|
}
|
||
|
public void OnBtnSelectClothClicked()
|
||
|
{
|
||
|
(UI_Manager.Instance.OpenPanel<Panel_ClothCustomization>() as Panel_ClothCustomization).isMale = isMalePanel;
|
||
|
}
|
||
|
public void OnBtnSelectHairstyleClicked()
|
||
|
{
|
||
|
(UI_Manager.Instance.OpenPanel<Panel_HairstyleCustomization>() as Panel_HairstyleCustomization).isMale = isMalePanel;
|
||
|
}
|
||
|
|
||
|
public void OnBtnConfirmCustomizationClicked()
|
||
|
{
|
||
|
if(!string.IsNullOrEmpty(playerName.text))
|
||
|
{
|
||
|
AudioManager.Instance.PlaySFX(SFX.Click);
|
||
|
FadeSystem.Instance.FadeIn(()=>GameManager.Instance.CreateUser(playerName.text));
|
||
|
}//if end
|
||
|
}//OnBtnConfirmCustomizationClicked() end
|
||
|
|
||
|
void DisableAllButtons()
|
||
|
{
|
||
|
attributesButtons.ForEach(x =>
|
||
|
{
|
||
|
Image btn = x.GetComponentsInParent<Image>().ToList()[1];
|
||
|
btn.sprite = buttonBG_UnSelectedState;
|
||
|
btn.SetNativeSize();
|
||
|
|
||
|
});
|
||
|
}
|
||
|
|
||
|
public void OnBtnGenderSelectionClicked(bool isMale)
|
||
|
{
|
||
|
GameManager.Instance.Gender = isMale ? Gender.Male : Gender.Female;
|
||
|
if (isMale)
|
||
|
{
|
||
|
UI_Manager.Instance.OpenPanel<Panel_CharacterCreationMale>();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
UI_Manager.Instance.OpenPanel<Panel_CharacterCreationFemale>();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|