using Fie.Camera; using Fie.Manager; using Fie.Ponies.Applejack; using Fie.Ponies.RainbowDash; using Fie.Ponies.RisingSun; using Fie.Ponies.Twilight; using Fie.User; using Fie.Utility; using GameDataEditor; using System; using System.Collections; using TMPro; using UnityEngine; namespace Fie.UI { public class FieLobbyCharacterSelectUIController : MonoBehaviour { public enum SelectableElementType { Magic, Kindness, Laghter, Loyalty, Generosity, Honestly, Maximum_Element, PrincessRisingSun } private delegate void ResouceLoadedCallback(T gameCharacter) where T : FieGameCharacter; public bool isEnable; public float lookingEaseTime = 0.5f; public float enableGemLightIntensity = 3f; public float enableGemLightBlinkInterval = 1f; private bool _gemLightAnimationInverseFlag; private bool _initializedFirstTime; [SerializeField] private bool[] existFlagList = new bool[6]; [SerializeField] private Transform[] gemTransformList = new Transform[6]; [SerializeField] private Light[] gemLightList = new Light[6]; [SerializeField] private TextMeshPro elementNameUITextMesh; private SelectableElementType _beforeElement; private SelectableElementType _currentElement; private Tweener _lookAtElementTweener = new Tweener(); private Tweener _lightIntesityTweener = new Tweener(); private Vector3 _beforeLookAtPosition = Vector3.zero; private Vector3 _nowLookAtPosition = Vector3.zero; private IEnumerator AsyncLoadCharacterResouce(ResouceLoadedCallback callback) where T : FieGameCharacter { FiePrefabInfo existsAttribute = (FiePrefabInfo)Attribute.GetCustomAttribute(typeof(T), typeof(FiePrefabInfo)); if (existsAttribute == null) { callback((T)null); } else { ResourceRequest loadRequest = Resources.LoadAsync(existsAttribute.path); float time = 0f; if (time < 3f && !loadRequest.isDone) { float num = time + Time.deltaTime; yield return (object)null; /*Error: Unable to find new state assignment for yield return*/; } GameObject loadObject = loadRequest.asset as GameObject; if (loadObject == null) { callback((T)null); } else { T gameCharacter = loadObject.GetComponent(); if ((UnityEngine.Object)gameCharacter == (UnityEngine.Object)null) { callback((T)null); } else { callback(gameCharacter); } } } } private void Start() { UpdateTextMesh(); } private void Update() { } private void UpdateElementActivity() { switch (_currentElement) { case SelectableElementType.Maximum_Element: break; case SelectableElementType.Magic: FieManagerBehaviour.I.RequestActivity(FieMasterData.I.GetMasterData(GDEItemKeys.ConstantTextList_ACTIVITY_TITLE_ELE_MAGIC_DESCRIPTION), FieMasterData.I.GetMasterData(GDEItemKeys.ConstantTextList_ACTIVITY_NOTE_ELE_MAGIC_DESCRIPTION), 30f); break; case SelectableElementType.Kindness: FieManagerBehaviour.I.RequestToHideActivity(); break; case SelectableElementType.Laghter: FieManagerBehaviour.I.RequestToHideActivity(); break; case SelectableElementType.Loyalty: FieManagerBehaviour.I.RequestActivity(FieMasterData.I.GetMasterData(GDEItemKeys.ConstantTextList_ACTIVITY_TITLE_ELE_LOYALTY_DESCRIPTION), FieMasterData.I.GetMasterData(GDEItemKeys.ConstantTextList_ACTIVITY_NOTE_ELE_LOYALTY_DESCRIPTION), 30f); break; case SelectableElementType.Generosity: FieManagerBehaviour.I.RequestToHideActivity(); break; case SelectableElementType.Honestly: FieManagerBehaviour.I.RequestActivity(FieMasterData.I.GetMasterData(GDEItemKeys.ConstantTextList_ACTIVITY_TITLE_ELE_HONESTY_DESCRIPTION), FieMasterData.I.GetMasterData(GDEItemKeys.ConstantTextList_ACTIVITY_NOTE_ELE_HONESTY_DESCRIPTION), 30f); break; case SelectableElementType.PrincessRisingSun: FieManagerBehaviour.I.RequestActivity(FieMasterData.I.GetMasterData(GDEItemKeys.ConstantTextList_ACTIVITY_TITLE_RISING_SIUN_DESCRIPTION), FieMasterData.I.GetMasterData(GDEItemKeys.ConstantTextList_ACTIVITY_NOTE_RISING_SUN_DESCRIPTION), 30f); break; } } private void UpdateTextMesh() { if (!(elementNameUITextMesh == null)) { string key = null; switch (_currentElement) { case SelectableElementType.Magic: key = GDEItemKeys.ConstantTextList_ELEMENT_NAME_MAGIC; break; case SelectableElementType.Kindness: key = GDEItemKeys.ConstantTextList_ELEMENT_NAME_KINDNESS; break; case SelectableElementType.Laghter: key = GDEItemKeys.ConstantTextList_ELEMENT_NAME_LAUGHTER; break; case SelectableElementType.Loyalty: key = GDEItemKeys.ConstantTextList_ELEMENT_NAME_LOYALTY; break; case SelectableElementType.Generosity: key = GDEItemKeys.ConstantTextList_ELEMENT_NAME_GENEROSITY; break; case SelectableElementType.Honestly: key = GDEItemKeys.ConstantTextList_ELEMENT_NAME_HONESTY; break; case SelectableElementType.PrincessRisingSun: key = GDEItemKeys.ConstantTextList_ELEMENT_NAME_PONICO; break; } GDEConstantTextListData constantTextData; string constantText = FieLocalizeUtility.GetConstantText(key, out constantTextData); elementNameUITextMesh.font = ((!constantTextData.ForceEnableToUseEnglishFont) ? FieManagerBehaviour.I.currentFont : FieManagerBehaviour.I.englishFont); elementNameUITextMesh.text = constantText; elementNameUITextMesh.ForceMeshUpdate(); } } public void IncreaseElementIndex() { int num = (int)(_currentElement + 1); if (num >= 6) { num = 0; } _currentElement = (SelectableElementType)num; } public void DecreaseElementIndex() { int num = (int)(_currentElement - 1); if (num < 0) { num = 5; } _currentElement = (SelectableElementType)num; } public bool isDecidable() { return existFlagList[(int)_currentElement]; } public void Decide() { FieLobbyGameCharacterGenerateManager.LobbyGameCharacterCreatedCallback lobbyCallback = delegate { isEnable = false; FieManagerBehaviour.I.setDefaultCameraOffset(new Vector3(0f, 0.75f, -5f)); FieManagerBehaviour.I.setDefaultCameraRotation(new Vector3(354f, 0f, 0f)); FieManagerBehaviour.I.gameCamera.SetCameraTask(1f); }; int userNumberByHash = FieManagerBehaviour.I.getUserNumberByHash(FieManagerBehaviour.I.myHash); FieUser userData = FieManagerBehaviour.I.GetUserData(userNumberByHash); FieManagerBehaviour.I.RequestToHideActivity(); switch (_currentElement) { case SelectableElementType.Kindness: break; case SelectableElementType.Laghter: break; case SelectableElementType.Generosity: break; case SelectableElementType.Maximum_Element: break; case SelectableElementType.Magic: { ResouceLoadedCallback callback4 = delegate { FieManagerBehaviour.I.RequestToCreateGameCharacter(userData, lobbyCallback); }; StartCoroutine(AsyncLoadCharacterResouce(callback4)); break; } case SelectableElementType.Loyalty: { ResouceLoadedCallback callback3 = delegate { FieManagerBehaviour.I.RequestToCreateGameCharacter(userData, lobbyCallback); }; StartCoroutine(AsyncLoadCharacterResouce(callback3)); break; } case SelectableElementType.Honestly: { ResouceLoadedCallback callback2 = delegate { FieManagerBehaviour.I.RequestToCreateGameCharacter(userData, lobbyCallback); }; StartCoroutine(AsyncLoadCharacterResouce(callback2)); break; } case SelectableElementType.PrincessRisingSun: { ResouceLoadedCallback callback = delegate { FieManagerBehaviour.I.RequestToCreateGameCharacter(userData, lobbyCallback); }; StartCoroutine(AsyncLoadCharacterResouce(callback)); break; } } } } }