DO-16 : 기본 UI 구성 및 개발, 서버 연동 스크립트 작성
This commit is contained in:
parent
fe1f22f1eb
commit
51b8b40041
2115
Assets/Prefabs/Leaderboard Panel.prefab
Normal file
2115
Assets/Prefabs/Leaderboard Panel.prefab
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/Prefabs/Leaderboard Panel.prefab.meta
Normal file
7
Assets/Prefabs/Leaderboard Panel.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1260c2be24f60c547af05635e06e0441
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -133,6 +133,140 @@ MonoBehaviour:
|
|||||||
m_StringArgument:
|
m_StringArgument:
|
||||||
m_BoolArgument: 0
|
m_BoolArgument: 0
|
||||||
m_CallState: 2
|
m_CallState: 2
|
||||||
|
--- !u!1 &464194668606902969
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 5226174045956635785}
|
||||||
|
- component: {fileID: 8671322038516107482}
|
||||||
|
- component: {fileID: 9151133375226120243}
|
||||||
|
m_Layer: 5
|
||||||
|
m_Name: Text (TMP)
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!224 &5226174045956635785
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 464194668606902969}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 7516183168886980900}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
|
m_AnchorMax: {x: 1, y: 1}
|
||||||
|
m_AnchoredPosition: {x: 0, y: 0}
|
||||||
|
m_SizeDelta: {x: 0, y: 0}
|
||||||
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
--- !u!222 &8671322038516107482
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 464194668606902969}
|
||||||
|
m_CullTransparentMesh: 1
|
||||||
|
--- !u!114 &9151133375226120243
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 464194668606902969}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_RaycastTarget: 1
|
||||||
|
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_Maskable: 1
|
||||||
|
m_OnCullStateChanged:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_text: "\uB9AC\uB354\uBCF4\uB4DC"
|
||||||
|
m_isRightToLeft: 0
|
||||||
|
m_fontAsset: {fileID: 11400000, guid: 85a19688db53c77469fc4406b01045da, type: 2}
|
||||||
|
m_sharedMaterial: {fileID: -2477908578676791210, guid: 85a19688db53c77469fc4406b01045da, type: 2}
|
||||||
|
m_fontSharedMaterials: []
|
||||||
|
m_fontMaterial: {fileID: 0}
|
||||||
|
m_fontMaterials: []
|
||||||
|
m_fontColor32:
|
||||||
|
serializedVersion: 2
|
||||||
|
rgba: 4281479730
|
||||||
|
m_fontColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
|
||||||
|
m_enableVertexGradient: 0
|
||||||
|
m_colorMode: 3
|
||||||
|
m_fontColorGradient:
|
||||||
|
topLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
topRight: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
bottomRight: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_fontColorGradientPreset: {fileID: 0}
|
||||||
|
m_spriteAsset: {fileID: 0}
|
||||||
|
m_tintAllSprites: 0
|
||||||
|
m_StyleSheet: {fileID: 0}
|
||||||
|
m_TextStyleHashCode: -1183493901
|
||||||
|
m_overrideHtmlColors: 0
|
||||||
|
m_faceColor:
|
||||||
|
serializedVersion: 2
|
||||||
|
rgba: 4294967295
|
||||||
|
m_fontSize: 50
|
||||||
|
m_fontSizeBase: 50
|
||||||
|
m_fontWeight: 400
|
||||||
|
m_enableAutoSizing: 0
|
||||||
|
m_fontSizeMin: 18
|
||||||
|
m_fontSizeMax: 72
|
||||||
|
m_fontStyle: 0
|
||||||
|
m_HorizontalAlignment: 2
|
||||||
|
m_VerticalAlignment: 512
|
||||||
|
m_textAlignment: 65535
|
||||||
|
m_characterSpacing: 0
|
||||||
|
m_wordSpacing: 0
|
||||||
|
m_lineSpacing: 0
|
||||||
|
m_lineSpacingMax: 0
|
||||||
|
m_paragraphSpacing: 0
|
||||||
|
m_charWidthMaxAdj: 0
|
||||||
|
m_enableWordWrapping: 1
|
||||||
|
m_wordWrappingRatios: 0.4
|
||||||
|
m_overflowMode: 0
|
||||||
|
m_linkedTextComponent: {fileID: 0}
|
||||||
|
parentLinkedComponent: {fileID: 0}
|
||||||
|
m_enableKerning: 1
|
||||||
|
m_enableExtraPadding: 0
|
||||||
|
checkPaddingRequired: 0
|
||||||
|
m_isRichText: 1
|
||||||
|
m_parseCtrlCharacters: 1
|
||||||
|
m_isOrthographic: 1
|
||||||
|
m_isCullingEnabled: 0
|
||||||
|
m_horizontalMapping: 0
|
||||||
|
m_verticalMapping: 0
|
||||||
|
m_uvLineOffset: 0
|
||||||
|
m_geometrySortingOrder: 0
|
||||||
|
m_IsTextObjectScaleStatic: 0
|
||||||
|
m_VertexBufferAutoSizeReduction: 0
|
||||||
|
m_useMaxVisibleDescender: 1
|
||||||
|
m_pageToDisplay: 1
|
||||||
|
m_margin: {x: 0, y: 0, z: 0, w: 14.439087}
|
||||||
|
m_isUsingLegacyAnimationComponent: 0
|
||||||
|
m_isVolumetricText: 0
|
||||||
|
m_hasFontAssetChanged: 0
|
||||||
|
m_baseMaterial: {fileID: 0}
|
||||||
|
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
||||||
--- !u!1 &925522282249935710
|
--- !u!1 &925522282249935710
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -722,6 +856,7 @@ RectTransform:
|
|||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 8215565921402706711}
|
- {fileID: 8215565921402706711}
|
||||||
- {fileID: 7302754525869768618}
|
- {fileID: 7302754525869768618}
|
||||||
|
- {fileID: 7516183168886980900}
|
||||||
m_Father: {fileID: 1320056438762570353}
|
m_Father: {fileID: 1320056438762570353}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||||
@ -1023,6 +1158,139 @@ MonoBehaviour:
|
|||||||
m_hasFontAssetChanged: 0
|
m_hasFontAssetChanged: 0
|
||||||
m_baseMaterial: {fileID: 0}
|
m_baseMaterial: {fileID: 0}
|
||||||
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
--- !u!1 &5067029877355654682
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 7516183168886980900}
|
||||||
|
- component: {fileID: 4898680350651387464}
|
||||||
|
- component: {fileID: 456400014775245546}
|
||||||
|
- component: {fileID: 3139988328835879115}
|
||||||
|
m_Layer: 5
|
||||||
|
m_Name: Leaderboard Button
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!224 &7516183168886980900
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 5067029877355654682}
|
||||||
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children:
|
||||||
|
- {fileID: 5226174045956635785}
|
||||||
|
m_Father: {fileID: 5821368595649352925}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
|
m_AnchorMax: {x: 0, y: 0}
|
||||||
|
m_AnchoredPosition: {x: 0, y: 0}
|
||||||
|
m_SizeDelta: {x: 542, y: 165}
|
||||||
|
m_Pivot: {x: 0.5, y: 0}
|
||||||
|
--- !u!222 &4898680350651387464
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 5067029877355654682}
|
||||||
|
m_CullTransparentMesh: 1
|
||||||
|
--- !u!114 &456400014775245546
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 5067029877355654682}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_RaycastTarget: 1
|
||||||
|
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_Maskable: 1
|
||||||
|
m_OnCullStateChanged:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_Sprite: {fileID: 21300000, guid: 05a670e614d7817429ee256ceb7efbe6, type: 3}
|
||||||
|
m_Type: 0
|
||||||
|
m_PreserveAspect: 0
|
||||||
|
m_FillCenter: 1
|
||||||
|
m_FillMethod: 4
|
||||||
|
m_FillAmount: 1
|
||||||
|
m_FillClockwise: 1
|
||||||
|
m_FillOrigin: 0
|
||||||
|
m_UseSpriteMesh: 0
|
||||||
|
m_PixelsPerUnitMultiplier: 1
|
||||||
|
--- !u!114 &3139988328835879115
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 5067029877355654682}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Navigation:
|
||||||
|
m_Mode: 3
|
||||||
|
m_WrapAround: 0
|
||||||
|
m_SelectOnUp: {fileID: 0}
|
||||||
|
m_SelectOnDown: {fileID: 0}
|
||||||
|
m_SelectOnLeft: {fileID: 0}
|
||||||
|
m_SelectOnRight: {fileID: 0}
|
||||||
|
m_Transition: 2
|
||||||
|
m_Colors:
|
||||||
|
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||||
|
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||||
|
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||||
|
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||||
|
m_ColorMultiplier: 1
|
||||||
|
m_FadeDuration: 0.1
|
||||||
|
m_SpriteState:
|
||||||
|
m_HighlightedSprite: {fileID: 21300000, guid: 1cc2af2fc6476554ca42fb2ddfd7727f, type: 3}
|
||||||
|
m_PressedSprite: {fileID: 21300000, guid: 1cc2af2fc6476554ca42fb2ddfd7727f, type: 3}
|
||||||
|
m_SelectedSprite: {fileID: 0}
|
||||||
|
m_DisabledSprite: {fileID: 0}
|
||||||
|
m_AnimationTriggers:
|
||||||
|
m_NormalTrigger: Normal
|
||||||
|
m_HighlightedTrigger: Highlighted
|
||||||
|
m_PressedTrigger: Pressed
|
||||||
|
m_SelectedTrigger: Selected
|
||||||
|
m_DisabledTrigger: Disabled
|
||||||
|
m_Interactable: 1
|
||||||
|
m_TargetGraphic: {fileID: 456400014775245546}
|
||||||
|
m_OnClick:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls:
|
||||||
|
- m_Target: {fileID: 1876512897147745654}
|
||||||
|
m_TargetAssemblyTypeName: SigninPanelController, Assembly-CSharp
|
||||||
|
m_MethodName: OnClickLeaderboardButton
|
||||||
|
m_Mode: 1
|
||||||
|
m_Arguments:
|
||||||
|
m_ObjectArgument: {fileID: 0}
|
||||||
|
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||||
|
m_IntArgument: 0
|
||||||
|
m_FloatArgument: 0
|
||||||
|
m_StringArgument:
|
||||||
|
m_BoolArgument: 0
|
||||||
|
m_CallState: 2
|
||||||
--- !u!1 &5393862130852695535
|
--- !u!1 &5393862130852695535
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -240,13 +240,14 @@ MonoBehaviour:
|
|||||||
m_GameObject: {fileID: 1017982169}
|
m_GameObject: {fileID: 1017982169}
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: b945f44e6cbf420a9f40dc21b5f2e365, type: 3}
|
m_Script: {fileID: 11500000, guid: 35a4c6d5d3a97b444b968e68ec8bb9f7, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
signinPanel: {fileID: 925522282249935710, guid: e14c9b2925f0ddb4192af743e5cc166a, type: 3}
|
signinPanel: {fileID: 925522282249935710, guid: e14c9b2925f0ddb4192af743e5cc166a, type: 3}
|
||||||
signupPanel: {fileID: 3181524094944658765, guid: 8827fe7caa3145e40b1369cc42f8697d, type: 3}
|
signupPanel: {fileID: 3181524094944658765, guid: 8827fe7caa3145e40b1369cc42f8697d, type: 3}
|
||||||
canvas: {fileID: 0}
|
leaderboardPanel: {fileID: 3181524094944658765, guid: 1260c2be24f60c547af05635e06e0441, type: 3}
|
||||||
_userManager: {fileID: 0}
|
canvas: {fileID: 2704399793730691091, guid: 65aac0e22fe25aa42b9cf7df776a854d, type: 3}
|
||||||
|
profileSprites: []
|
||||||
--- !u!4 &1017982171
|
--- !u!4 &1017982171
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -7,7 +7,7 @@ public class GameManager : Singleton<GameManager>
|
|||||||
{
|
{
|
||||||
[SerializeField] private GameObject signinPanel;
|
[SerializeField] private GameObject signinPanel;
|
||||||
[SerializeField] private GameObject signupPanel;
|
[SerializeField] private GameObject signupPanel;
|
||||||
|
[SerializeField] private GameObject leaderboardPanel;
|
||||||
[SerializeField] private Canvas canvas;
|
[SerializeField] private Canvas canvas;
|
||||||
private UserManager _userManager; // UserManager 인스턴스 관리
|
private UserManager _userManager; // UserManager 인스턴스 관리
|
||||||
|
|
||||||
@ -37,9 +37,9 @@ public class GameManager : Singleton<GameManager>
|
|||||||
TryAutoSignin();
|
TryAutoSignin();
|
||||||
|
|
||||||
//게임 씬에서 확인하기 위한 임시 코드
|
//게임 씬에서 확인하기 위한 임시 코드
|
||||||
_stoneController = GameObject.FindObjectOfType<StoneController>();
|
// _stoneController = GameObject.FindObjectOfType<StoneController>();
|
||||||
_stoneController.InitStones();
|
// _stoneController.InitStones();
|
||||||
_gameLogic = new GameLogic(_stoneController, _gameType);
|
// _gameLogic = new GameLogic(_stoneController, _gameType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TryAutoSignin()
|
private void TryAutoSignin()
|
||||||
@ -105,4 +105,28 @@ public class GameManager : Singleton<GameManager>
|
|||||||
}
|
}
|
||||||
_canvas = GameObject.Find("Canvas").GetComponent<Canvas>();
|
_canvas = GameObject.Find("Canvas").GetComponent<Canvas>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 랭킹보드 점수 활성화하는 함수.
|
||||||
|
/// </summary>
|
||||||
|
public void OpenLeaderboardPanel()
|
||||||
|
{
|
||||||
|
if (_canvas != null)
|
||||||
|
{
|
||||||
|
var leaderboardPanelObject = Instantiate(leaderboardPanel, _canvas.transform);
|
||||||
|
StartCoroutine(NetworkManager.Instance.GetLeaderboard(
|
||||||
|
ranks =>
|
||||||
|
{
|
||||||
|
foreach (var rank in ranks.scores)
|
||||||
|
{
|
||||||
|
var leaderboardController = leaderboardPanelObject.GetComponent<LeaderBoardController>();
|
||||||
|
leaderboardController.CreateCell(rank);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
() =>
|
||||||
|
{
|
||||||
|
Debug.LogError("랭킹 불러오기 실패");
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
66
Assets/Script/Main/LeaderBoardController.cs
Normal file
66
Assets/Script/Main/LeaderBoardController.cs
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Networking;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class LeaderBoardController : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] private GameObject scoreCell;
|
||||||
|
[SerializeField] private Transform content;
|
||||||
|
private List<ScoreCellController> scoreCC = new List<ScoreCellController>();
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
StartCoroutine(OnConnectedToServer());
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerator OnConnectedToServer()
|
||||||
|
{
|
||||||
|
string url = Constants.ServerURL + "/users/Leaderboard"; // 서버의 리더보드 데이터 URL
|
||||||
|
|
||||||
|
UnityWebRequest www = UnityWebRequest.Get(url); // GET 요청으로 데이터 받기
|
||||||
|
yield return www.SendWebRequest(); // 요청 전송 대기
|
||||||
|
|
||||||
|
// 요청이 실패했을 때
|
||||||
|
if (www.isNetworkError || www.isHttpError)
|
||||||
|
{
|
||||||
|
Debug.LogError("Error: " + www.error);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 성공적으로 데이터를 받아온 경우
|
||||||
|
string jsonResponse = www.downloadHandler.text; // 응답으로 받은 JSON 데이터
|
||||||
|
|
||||||
|
// JSON을 ScoreInfo 리스트로 파싱
|
||||||
|
List<ScoreInfo> scoreInfos = JsonUtility.FromJson<ScoreListWrapper>(jsonResponse).scoreInfos;
|
||||||
|
|
||||||
|
// 받아온 데이터를 기반으로 점수 셀 생성
|
||||||
|
foreach (var scoreInfo in scoreInfos)
|
||||||
|
{
|
||||||
|
CreateCell(scoreInfo); // 각 점수 정보를 기반으로 셀 생성
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateCell(ScoreInfo scoreInfo)
|
||||||
|
{
|
||||||
|
var scoreCellObj = Instantiate(scoreCell, content);
|
||||||
|
var scoreCellController = scoreCellObj.GetComponent<ScoreCellController>();
|
||||||
|
// 점수 셀 정보 설정
|
||||||
|
if (scoreCellController != null)
|
||||||
|
{
|
||||||
|
scoreCellController.SetCellInfo(scoreInfo); // 점수 셀에 점수 정보 설정
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogError("ScoreCellController 컴포넌트가 점수 셀 프리팹에 없습니다.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class ScoreListWrapper
|
||||||
|
{
|
||||||
|
public List<ScoreInfo> scoreInfos;
|
||||||
|
}
|
11
Assets/Script/Main/LeaderBoardController.cs.meta
Normal file
11
Assets/Script/Main/LeaderBoardController.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d481e07ebe4437c4a9f6bb09a73d3eab
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
27
Assets/Script/Main/ScoreCellController.cs
Normal file
27
Assets/Script/Main/ScoreCellController.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class ScoreCellController : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] private Image profileImage;
|
||||||
|
[SerializeField] private int score;
|
||||||
|
[SerializeField] private string nickname;
|
||||||
|
[SerializeField] private float winRate;
|
||||||
|
[SerializeField] private int win;
|
||||||
|
[SerializeField] private int lose;
|
||||||
|
[SerializeField] private int totalGames;
|
||||||
|
|
||||||
|
public void SetCellInfo(ScoreInfo scoreInfo)
|
||||||
|
{
|
||||||
|
nickname = scoreInfo.nickname;
|
||||||
|
score = scoreInfo.score;
|
||||||
|
winRate = scoreInfo.winRate;
|
||||||
|
win = scoreInfo.win;
|
||||||
|
lose = scoreInfo.lose;
|
||||||
|
totalGames = scoreInfo.totalGames;
|
||||||
|
profileImage = scoreInfo.profileImage;
|
||||||
|
}
|
||||||
|
}
|
11
Assets/Script/Main/ScoreCellController.cs.meta
Normal file
11
Assets/Script/Main/ScoreCellController.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 028cd6e2bf3906148af7fbf262b98281
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -1,7 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Net.Mime;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Serialization;
|
using UnityEngine.Serialization;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
public struct SigninData
|
public struct SigninData
|
||||||
{
|
{
|
||||||
@ -25,6 +27,11 @@ public struct ScoreInfo
|
|||||||
public string email;
|
public string email;
|
||||||
public string nickname;
|
public string nickname;
|
||||||
public int score;
|
public int score;
|
||||||
|
public float winRate;
|
||||||
|
public int win;
|
||||||
|
public int lose;
|
||||||
|
public int totalGames;
|
||||||
|
public Image profileImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
@ -75,4 +82,9 @@ public class SigninPanelController : MonoBehaviour
|
|||||||
passwordInputField.text = "";
|
passwordInputField.text = "";
|
||||||
GameManager.Instance.OpenSignupPanel();
|
GameManager.Instance.OpenSignupPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnClickLeaderboardButton()
|
||||||
|
{
|
||||||
|
GameManager.Instance.OpenLeaderboardPanel();
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user