diff --git a/Assets/Resources/Prefabs/Panels/Rating Panel.prefab b/Assets/Resources/Prefabs/Panels/Rating Panel.prefab index fb09fef..457892e 100644 --- a/Assets/Resources/Prefabs/Panels/Rating Panel.prefab +++ b/Assets/Resources/Prefabs/Panels/Rating Panel.prefab @@ -17,7 +17,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!224 &2892359980071642891 RectTransform: m_ObjectHideFlags: 0 @@ -35,10 +35,10 @@ RectTransform: - {fileID: 4449227898776835372} m_Father: {fileID: 6614054331963984893} 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: 0, y: 170} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 400, y: -100} + m_SizeDelta: {x: 800, y: 170} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1298835069028732765 MonoBehaviour: @@ -120,10 +120,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 7676248445717112588} 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: 0, y: 100} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 452.5, y: -50} + m_SizeDelta: {x: 125, y: 100} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &7977355815890466338 CanvasRenderer: @@ -270,10 +270,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 7676248445717112588} 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: 0, y: 100} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 327.5, y: -50} + m_SizeDelta: {x: 125, y: 100} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &6301016094153351874 CanvasRenderer: @@ -570,10 +570,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 7676248445717112588} 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: 0, y: 100} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 577.5, y: -50} + m_SizeDelta: {x: 125, y: 100} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &1886539646614887306 CanvasRenderer: @@ -812,8 +812,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_text: "\uAC8C\uC784\uC5D0\uC11C \uC2B9\uB9AC \uD588\uC2B5\uB2C8\uB2E4.\\n10 \uC2B9\uAE09 - \uD3EC\uC778\uD2B8\uB97C \uC5BB\uC5C8\uC2B5\uB2C8\uB2E4." + m_text: '-' m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 85a19688db53c77469fc4406b01045da, type: 2} m_sharedMaterial: {fileID: -2477908578676791210, guid: 85a19688db53c77469fc4406b01045da, type: 2} @@ -914,10 +913,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 7676248445717112588} 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: 0, y: 100} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 202.5, y: -50} + m_SizeDelta: {x: 125, y: 100} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &8475960274811565095 CanvasRenderer: @@ -1473,10 +1472,10 @@ RectTransform: - {fileID: 2571517614704257732} m_Father: {fileID: 2892359980071642891} 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: 0, y: 40} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 400, y: -20} + m_SizeDelta: {x: 780, y: 40} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &7589988445738541794 MonoBehaviour: @@ -2500,9 +2499,9 @@ RectTransform: m_Children: [] m_Father: {fileID: 5145975050385009131} 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_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 130, y: -15} m_SizeDelta: {x: 200, y: 50} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &5764155609364392127 @@ -3010,9 +3009,9 @@ RectTransform: m_Children: [] m_Father: {fileID: 5145975050385009131} 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_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 390, y: -15} m_SizeDelta: {x: 200, y: 50} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &7953870127220333924 @@ -3294,10 +3293,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 7676248445717112588} 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: 0, y: 100} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 702.5, y: -50} + m_SizeDelta: {x: 125, y: 100} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &8108132620148900676 CanvasRenderer: @@ -4639,10 +4638,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 7676248445717112588} 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: 0, y: 100} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 77.5, y: -50} + m_SizeDelta: {x: 125, y: 100} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &380273237471126270 CanvasRenderer: @@ -4861,7 +4860,6 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: panelRectTransform: {fileID: 3191510560908108244} - messageText: {fileID: 1412307801878878688} getPointsText: {fileID: 1412307801878878688} threePointsIndicatorGameObject: {fileID: 16284815793818062} fivePointsIndicatorGameObject: {fileID: 4593229467024718583} @@ -5037,10 +5035,10 @@ RectTransform: - {fileID: 8586608546526436136} m_Father: {fileID: 2892359980071642891} 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: 0, y: 100} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 400, y: -90} + m_SizeDelta: {x: 780, y: 100} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &6912240550662146492 MonoBehaviour: @@ -5247,9 +5245,9 @@ RectTransform: m_Children: [] m_Father: {fileID: 5145975050385009131} 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_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 650, y: -15} m_SizeDelta: {x: 200, y: 50} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &5260096339463299906 @@ -5558,10 +5556,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 2892359980071642891} 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: 0, y: 30} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 400, y: -155} + m_SizeDelta: {x: 780, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &627333909763446630 CanvasRenderer: diff --git a/Assets/Script/UI/PanelChildController/RatingPointsController.cs b/Assets/Script/UI/PanelChildController/RatingPointsController.cs index d5bc1f0..3b5a8e3 100644 --- a/Assets/Script/UI/PanelChildController/RatingPointsController.cs +++ b/Assets/Script/UI/PanelChildController/RatingPointsController.cs @@ -10,42 +10,130 @@ public class RatingPointsController : MonoBehaviour [SerializeField] GameObject[] minusImages; [SerializeField] GameObject[] plusImage; [SerializeField] TMP_Text scoreCountText; - [SerializeField] private float flipDuration = 1f; + private float flipDuration = 1f; private Color32 _minusColor = new Color32(255, 0, 0, 255); private Color32 _plusColor = new Color32(34, 87, 255, 255); private Color32 _defaultColor = new Color32(176, 176, 176, 255); - private int _requiredScore; - public void InitRatingPoints(int oldScore, int requiredScore) + private int _oldRequiredScore; + private int _newRequiredScore; + private int _oldScore; + public void InitRatingPoints(int oldScore,Enums.GameResult gameResult, int defaultRequiredScore) { - _requiredScore = requiredScore; - - if (oldScore == 0) + // TODO: [인덱스계산 ㅇㅖ외처리 ] 계산한 값 절대값이 defaultRequiredScore보다 큰 경우 return. 근데 이런 값이 나온다는게 이미 계산 오류가 어디서 생긴 것이겠죠..? + _oldScore = oldScore; + Sequence sequence = DOTween.Sequence(); + if (_oldScore == 0) { - + if (gameResult == Enums.GameResult.Win) + { + sequence.Append( + plusImage[0].GetComponent().DOLocalRotate(new Vector3(0f, 90f, 0f), flipDuration).SetEase(Ease.InExpo)); + sequence.Append( + plusImage[0].GetComponent().DOLocalRotate(Vector3.zero, flipDuration).SetEase(Ease.OutExpo)); + sequence.Join( + plusImage[0].GetComponent().DOColor(_plusColor, flipDuration/2).SetEase(Ease.OutExpo)); + + //승급까지 남은 판수 계산 + _newRequiredScore = defaultRequiredScore-1; + } + else if(gameResult == Enums.GameResult.Lose) + { + sequence.Append( + minusImages[defaultRequiredScore-1].GetComponent().DOLocalRotate(new Vector3(0f, 90f, 0f), flipDuration).SetEase(Ease.InExpo)); + sequence.Append( + minusImages[defaultRequiredScore-1].GetComponent().DOLocalRotate(Vector3.zero, flipDuration).SetEase(Ease.OutExpo)); + sequence.Join( + minusImages[defaultRequiredScore-1].GetComponent().DOColor(_minusColor, flipDuration/2).SetEase(Ease.OutExpo)); + + //승급까지 남은 판수 계산 + _newRequiredScore = defaultRequiredScore+1; + } } - else if (oldScore > 0) + // 이번 게임 전 기존 점수가 플러스 였을 경우 + else if (_oldScore > 0) { - for (int i = 0; i < oldScore; i++) + for (int i = 0; i < _oldScore; i++) { plusImage[i].GetComponent().color = _plusColor; - plusImage[i].GetComponent().DOFlip(); } - } - else if (oldScore < 0) - { - for (int i = oldScore; i < 0; i++) + if (gameResult == Enums.GameResult.Win) { - minusImages[minusImages.Length+i].GetComponent().DOColor(_minusColor, flipDuration); - plusImage[minusImages.Length+i].GetComponent().DOFlip(); + sequence.Append( + plusImage[_oldScore].GetComponent().DOLocalRotate(new Vector3(0f, 90f, 0f), flipDuration).SetEase(Ease.InExpo)); + sequence.Append( + plusImage[_oldScore].GetComponent().DOLocalRotate(Vector3.zero, flipDuration).SetEase(Ease.OutExpo)); + sequence.Join( + plusImage[_oldScore].GetComponent().DOColor(_plusColor, flipDuration/2).SetEase(Ease.OutExpo)); + + //승급까지 남은 판수 계산 + _newRequiredScore = defaultRequiredScore-oldScore-1; + } + else if(gameResult == Enums.GameResult.Lose) + { + sequence.Append( + plusImage[_oldScore-1].GetComponent().DOLocalRotate(new Vector3(0f, 90f, 0f), flipDuration).SetEase(Ease.InExpo)); + sequence.Append( + plusImage[_oldScore-1].GetComponent().DOLocalRotate(Vector3.zero, flipDuration).SetEase(Ease.OutExpo)); + sequence.Join( + plusImage[_oldScore-1].GetComponent().DOColor(_defaultColor, flipDuration/2).SetEase(Ease.OutExpo)); + + //승급까지 남은 판수 계산 + _newRequiredScore = defaultRequiredScore-oldScore+1; } } + + // 이번 게임 전 기존 점수가 마이너스 였을 경우 + else + { + for (int i = _oldScore; i < 0; i++) + { + minusImages[minusImages.Length+i].GetComponent().color = _minusColor; + } + if (gameResult == Enums.GameResult.Win) + { + sequence.Append( + minusImages[minusImages.Length+_oldScore].GetComponent().DOLocalRotate(new Vector3(0f, 90f, 0f), flipDuration).SetEase(Ease.InExpo)); + sequence.Append( + minusImages[minusImages.Length+_oldScore].GetComponent().DOLocalRotate(Vector3.zero, flipDuration).SetEase(Ease.OutExpo)); + sequence.Join( + minusImages[minusImages.Length+_oldScore].GetComponent().DOColor(_defaultColor, flipDuration/2).SetEase(Ease.OutExpo)); + + //승급까지 남은 판수 계산 + _newRequiredScore = defaultRequiredScore-oldScore-1; + } + else if(gameResult == Enums.GameResult.Lose) + { + sequence.Append( + minusImages[minusImages.Length+_oldScore-1].GetComponent().DOLocalRotate(new Vector3(0f, 90f, 0f), flipDuration).SetEase(Ease.InExpo)); + sequence.Append( + minusImages[minusImages.Length+_oldScore-1].GetComponent().DOLocalRotate(Vector3.zero, flipDuration).SetEase(Ease.OutExpo)); + sequence.Join( + minusImages[minusImages.Length+_oldScore-1].GetComponent().DOColor(_minusColor, flipDuration/2).SetEase(Ease.OutExpo)); + + //승급까지 남은 판수 계산 + _newRequiredScore = defaultRequiredScore-oldScore+1; + } + } + + //TODO: 무승부인 경우 남은 승리 수 계산 + if (gameResult == Enums.GameResult.Draw) + { + _newRequiredScore = defaultRequiredScore-oldScore; + } + + SetScoreCountText(_newRequiredScore,defaultRequiredScore); } - public int CalculateNewRequiredScore(bool isWin) + private void SetScoreCountText(int scoreCount,int defaultRequiredScore) { - return 0; + if (scoreCount == 0 || scoreCount >= defaultRequiredScore * 2) + scoreCountText.text = ""; + else + scoreCountText.text = $"{scoreCount} 게임을 승리하면 승급하게 됩니다."; + //강등되는 경우에도 텍스트 처리 } + //승급, 강등시 패널을 초기화해서 띄워주는 함수 추가 } diff --git a/Assets/Script/UI/PanelController/PanelController.cs b/Assets/Script/UI/PanelController/PanelController.cs index 068c6d1..5af7bed 100644 --- a/Assets/Script/UI/PanelController/PanelController.cs +++ b/Assets/Script/UI/PanelController/PanelController.cs @@ -12,7 +12,8 @@ public class PanelController : MonoBehaviour private CanvasGroup backGroundCanvasGroup; // 배경 페이드 효과를 위한 변수 public delegate void PanelControllerHideDelegate(); - + + public delegate void PanelControllerShowDelegate(); private void Awake() { backGroundCanvasGroup = GetComponent(); @@ -22,7 +23,7 @@ public class PanelController : MonoBehaviour /// Panel 표시 함수 /// 알파값과 크기를 0으로 줄였다가 1로 페이드 /// - public void Show() + public void Show(PanelControllerShowDelegate showDelegate = null) { GameManager.Instance.audioManager.PlayClickSound(); @@ -35,7 +36,10 @@ public class PanelController : MonoBehaviour panelRectTransform.localScale = Vector3.zero; backGroundCanvasGroup.DOFade(1, 0.3f).SetEase(Ease.Linear); - panelRectTransform.DOScale(1, 0.3f).SetEase(Ease.OutBack); + panelRectTransform.DOScale(1, 0.3f).SetEase(Ease.OutBack).OnComplete(() => + { + showDelegate?.Invoke(); + }); } /// diff --git a/Assets/Script/UI/PanelController/RatingPanelController.cs b/Assets/Script/UI/PanelController/RatingPanelController.cs index e77cf22..53695cd 100644 --- a/Assets/Script/UI/PanelController/RatingPanelController.cs +++ b/Assets/Script/UI/PanelController/RatingPanelController.cs @@ -20,8 +20,7 @@ public class RatingPanelController : PanelController public void Show(Enums.GameResult gameResult) { - InitRatingPanel(gameResult); - base.Show(); + base.Show(InitRatingPanel(gameResult)); } public void OnClickConfirmButton() @@ -39,7 +38,7 @@ public class RatingPanelController : PanelController /// 텍스트 초기화, 승급포인트 계산 /// /// - public void InitRatingPanel(Enums.GameResult gameResult) + public PanelControllerShowDelegate InitRatingPanel(Enums.GameResult gameResult) { _gameResult = gameResult; _myRating= UserManager.Instance.Rating; @@ -66,16 +65,25 @@ public class RatingPanelController : PanelController string win = _gameResult == Enums.GameResult.Win ? "승리" : "패배"; string get = _gameResult == Enums.GameResult.Win ? "얻었습니다." : "잃었습니다."; - - getPointsText.text = $"게임에서 {win}했습니다.\n{Constants.RAING_POINTS} 승급 포인트를 {get}"; - //게임 승패 이전의 rating과 score로 패널 초기화 + // 게임 전 스코어로 초기화 NetworkManager.Instance.GetInfo((userInfo) => + { + _oldScore = userInfo.score; + _ratingPointsController.InitRatingPoints(_oldScore,_gameResult,requiredScore); + }, () => + { }); + + if(_gameResult == Enums.GameResult.Draw) { - _oldScore = userInfo.score; - _ratingPointsController.InitRatingPoints(_oldScore,requiredScore); - }, () => - { }); + getPointsText.text = "무승부입니다."; + } + else + { + getPointsText.text = $"게임에서 {win}했습니다.\n{Constants.RAING_POINTS} 승급 포인트를 {get}"; + } + + return null; }