From d4056d56ed40e7ed3f08aea1d04e481cd23d0c95 Mon Sep 17 00:00:00 2001 From: Jen-Chieh Shen Date: Thu, 25 Aug 2022 20:14:50 +0800 Subject: [PATCH] refactor(DeltaNumber): Remove ambiguous keyword, Score --- .../Scripts/UI/JCS_3DLiquidBarText.cs | 4 +- Assets/JCSUnity/Scripts/UI/JCS_DeltaNumber.cs | 204 +++++++++--------- .../JCSUnity/Scripts/UI/JCS_LiquidBarText.cs | 4 +- .../Scripts/UI/JCS_TextDeltaNumber.cs | 6 +- docs/ScriptReference/UI/JCS_DeltaNumber.md | 52 ++--- 5 files changed, 135 insertions(+), 135 deletions(-) diff --git a/Assets/JCSUnity/Scripts/UI/JCS_3DLiquidBarText.cs b/Assets/JCSUnity/Scripts/UI/JCS_3DLiquidBarText.cs index ce4bd49d..6ce5c1b3 100644 --- a/Assets/JCSUnity/Scripts/UI/JCS_3DLiquidBarText.cs +++ b/Assets/JCSUnity/Scripts/UI/JCS_3DLiquidBarText.cs @@ -83,10 +83,10 @@ private void DoTextRender() mFullText.text = mLiquidBar.MaxValue.ToString(); if (mCounterTextSprite != null) - mCounterTextSprite.UpdateScore((int)mLiquidBar.GetCurrentValue()); + mCounterTextSprite.UpdateNumber((int)mLiquidBar.GetCurrentValue()); if (mFullTextSprite != null) - mFullTextSprite.UpdateScore((int)mLiquidBar.MaxValue); + mFullTextSprite.UpdateNumber((int)mLiquidBar.MaxValue); } /// diff --git a/Assets/JCSUnity/Scripts/UI/JCS_DeltaNumber.cs b/Assets/JCSUnity/Scripts/UI/JCS_DeltaNumber.cs index 9baa9f21..9538981e 100644 --- a/Assets/JCSUnity/Scripts/UI/JCS_DeltaNumber.cs +++ b/Assets/JCSUnity/Scripts/UI/JCS_DeltaNumber.cs @@ -54,44 +54,44 @@ public class JCS_DeltaNumber : MonoBehaviour [Header("** Initialize Variables (JCS_DeltaNumber) **")] - [Tooltip(@"Current score rendering..., do not use this to + [Tooltip(@"Current number rendering..., do not use this to check value. Because this will always be animate.")] [SerializeField] - private int mCurrentScore = 0; + private int mCurrentNumber = 0; [Tooltip("Default null slot. [Default: transparent_256.png]")] [SerializeField] - private Sprite mScoreNull = null; - [Tooltip("Score text 0.")] + private Sprite mNumberNull = null; + [Tooltip("Number image 0.")] [SerializeField] - private Sprite mScoreText0 = null; - [Tooltip("Score text 1.")] + private Sprite mNumberText0 = null; + [Tooltip("Number image 1.")] [SerializeField] - private Sprite mScoreText1 = null; - [Tooltip("Score text 2.")] + private Sprite mNumberText1 = null; + [Tooltip("Number image 2.")] [SerializeField] - private Sprite mScoreText2 = null; - [Tooltip("Score text 3.")] + private Sprite mNumberText2 = null; + [Tooltip("Number image 3.")] [SerializeField] - private Sprite mScoreText3 = null; - [Tooltip("Score text 4.")] + private Sprite mNumberText3 = null; + [Tooltip("Number image 4.")] [SerializeField] - private Sprite mScoreText4 = null; - [Tooltip("Score text 5.")] + private Sprite mNumberText4 = null; + [Tooltip("Number image 5.")] [SerializeField] - private Sprite mScoreText5 = null; - [Tooltip("Score text 6.")] + private Sprite mNumberText5 = null; + [Tooltip("Number image 6.")] [SerializeField] - private Sprite mScoreText6 = null; - [Tooltip("Score text 7.")] + private Sprite mNumberText6 = null; + [Tooltip("Number image 7.")] [SerializeField] - private Sprite mScoreText7 = null; - [Tooltip("Score text 8.")] + private Sprite mNumberText7 = null; + [Tooltip("Number image 8.")] [SerializeField] - private Sprite mScoreText8 = null; - [Tooltip("Score text 9.")] + private Sprite mNumberText8 = null; + [Tooltip("Number image 9.")] [SerializeField] - private Sprite mScoreText9 = null; + private Sprite mNumberText9 = null; [Tooltip("Each digit, the more length the more digit.")] [SerializeField] @@ -118,33 +118,33 @@ public class JCS_DeltaNumber : MonoBehaviour [Header("- Min/Max Settings (JCS_DeltaNumber)")] - [Tooltip("Maxinum score.")] + [Tooltip("Maxinum number.")] [SerializeField] - private int mMaxScore = 999; + private int mMaxNumber = 999; - [Tooltip("Mininum score.")] + [Tooltip("Mininum number.")] [SerializeField] - private int mMinScore = 0; + private int mMinNumber = 0; [Header("- Delta Animation Settings (JCS_DeltaNumber)")] - [Tooltip(@"This will make the score have the transition -between, setting to a new score. If you want the score set directly, you + [Tooltip(@"This will make the number have the transition +between, setting to a new number. If you want the number set directly, you should disable this effect for best purpose.")] [SerializeField] - private bool mDeltaToCurrentScore = false; + private bool mDeltaToCurrentNumber = false; - [Tooltip("Toward to this score, if mDeltaToCurrentScore active.")] + [Tooltip("Toward to this number, if mDeltaToCurrentScore active.")] [SerializeField] - private int mTargetScore = 0; + private int mTargetNumber = 0; - [Tooltip("How fast the score animate.")] + [Tooltip("How fast the number animate.")] [SerializeField] [Range(0.01f, 1.0f)] - private float mAnimScoreTime = 0; + private float mAnimNumberTime = 0; - // timer for animation the score - private float mAnimScoreTimer = 0; + // timer for animation the number + private float mAnimNumberTimer = 0; [Tooltip("How much the delta value add up.")] [SerializeField] [Range(1, 1000)] @@ -154,17 +154,17 @@ [SerializeField] [Range(1, 1000)] public bool IsEnable { get { return this.mIsEnable; } } public bool ClearEmptyLeftZero { get { return this.mClearEmptyLeftZero; } set { this.mClearEmptyLeftZero = value; } } - public bool DeltaToCurrentScore { get { return this.mDeltaToCurrentScore; } set { this.mDeltaToCurrentScore = value; } } - public int TargetScore + public bool DeltaToCurrentNumber { get { return this.mDeltaToCurrentNumber; } set { this.mDeltaToCurrentNumber = value; } } + public int TargetNumber { - get { return this.mTargetScore; } + get { return this.mTargetNumber; } set { - this.mTargetScore = value; + this.mTargetNumber = value; - // by setting the delta score will enable the - // delta to current score effect. - this.mDeltaToCurrentScore = true; + // by setting the delta number will enable the delta to current + // number effect. + this.mDeltaToCurrentNumber = true; } } public bool VisibleOnZero { get { return this.mVisibleOnZero; } set { this.mVisibleOnZero = value; } } @@ -186,8 +186,8 @@ private void Awake() // update interval UpdateIntervalForEachDigit(); - // init score to current. - UpdateScore(); + // init number to current. + UpdateNumber(); } private void Update() @@ -196,7 +196,7 @@ private void Update() Test(); #endif - DoDeltaCurrentScore(); + DoDeltaCurrentNumber(); } #if (UNITY_EDITOR) @@ -206,9 +206,9 @@ private void Test() return; if (JCS_Input.GetKey(mDeltaToA)) - UpdateScore(mDeltaValueA); + UpdateNumber(mDeltaValueA); if (JCS_Input.GetKey(mDeltaToB)) - UpdateScore(mDeltaValueB); + UpdateNumber(mDeltaValueB); } #endif @@ -230,43 +230,43 @@ public void EnableDigitsRendererSlot(bool act) } /// - /// Update the score GUI. + /// Update the number GUI. /// - public void UpdateScore() + public void UpdateNumber() { - UpdateScore(mCurrentScore); + UpdateNumber(mCurrentNumber); } /// - /// Update the score GUI + /// Update the number GUI /// - /// score apply to show - public void UpdateScore(int score, bool anime = false) + /// number apply to show + public void UpdateNumber(int number, bool anime = false) { - int targetScore = score; + int targetNumber = number; - if (targetScore < mMinScore) - targetScore = mMinScore; - else if (targetScore > mMaxScore) - targetScore = mMaxScore; + if (targetNumber < mMinNumber) + targetNumber = mMinNumber; + else if (targetNumber > mMaxNumber) + targetNumber = mMaxNumber; - if (mDeltaToCurrentScore) + if (mDeltaToCurrentNumber) { if (!anime) - mTargetScore = targetScore; + mTargetNumber = targetNumber; } else { - // apply to current score - mCurrentScore = targetScore; + // apply to current number + mCurrentNumber = targetNumber; } - DoScoreGUI(targetScore); + DoScoreGUI(targetNumber); // Do if visible on zero effect. - DoVisibleOnZero(targetScore); + DoVisibleOnZero(targetNumber); - DoScoreAlign(targetScore); + DoScoreAlign(targetNumber); } @@ -302,10 +302,10 @@ public void UpdateIntervalForEachDigit() } /// - /// Do the GUI score logic. + /// Do the GUI number logic. /// - /// score to apply. - private void DoScoreGUI(int score) + /// number to apply. + private void DoScoreGUI(int number) { // check the first non zero from the left. bool meetNonZero = false; @@ -319,7 +319,7 @@ private void DoScoreGUI(int score) continue; } - int valDigit = JCS_Mathf.GetSingleDigit(digit + 1, score); + int valDigit = JCS_Mathf.GetSingleDigit(digit + 1, number); mDigitsRendererSlot[digit].LocalSprite = GetSingleDigitSprite(valDigit); @@ -332,50 +332,50 @@ private void DoScoreGUI(int score) meetNonZero = true; if (!meetNonZero) - mDigitsRendererSlot[digit].LocalSprite = mScoreNull; + mDigitsRendererSlot[digit].LocalSprite = mNumberNull; } } } /// - /// Main algorithm to approach to targe score. + /// Main algorithm to approach to targe number. /// - private void DoDeltaCurrentScore() + private void DoDeltaCurrentNumber() { // check if the effect active. - if (!mDeltaToCurrentScore) + if (!mDeltaToCurrentNumber) return; - // if score the same, return. - if (mCurrentScore == mTargetScore) + // if number the same, return. + if (mCurrentNumber == mTargetNumber) return; - mAnimScoreTimer += Time.deltaTime; + mAnimNumberTimer += Time.deltaTime; // check if timer reach the time. - if (mAnimScoreTimer < mAnimScoreTime) + if (mAnimNumberTimer < mAnimNumberTime) return; - // find out to increase/decrease the score. - if (mCurrentScore < mTargetScore) + // find out to increase/decrease the number. + if (mCurrentNumber < mTargetNumber) { - mCurrentScore += mDeltaProduct; + mCurrentNumber += mDeltaProduct; - if (mCurrentScore > mTargetScore) - mCurrentScore = mTargetScore; + if (mCurrentNumber > mTargetNumber) + mCurrentNumber = mTargetNumber; } else { - mCurrentScore -= mDeltaProduct; + mCurrentNumber -= mDeltaProduct; - if (mCurrentScore < mTargetScore) - mCurrentScore = mTargetScore; + if (mCurrentNumber < mTargetNumber) + mCurrentNumber = mTargetNumber; } - UpdateScore(mCurrentScore, true); + UpdateNumber(mCurrentNumber, true); // reset timer - mAnimScoreTimer = 0; + mAnimNumberTimer = 0; } /// @@ -387,24 +387,24 @@ private Sprite GetSingleDigitSprite(int num) { switch (num) { - case 0: return mScoreText0; - case 1: return mScoreText1; - case 2: return mScoreText2; - case 3: return mScoreText3; - case 4: return mScoreText4; - case 5: return mScoreText5; - case 6: return mScoreText6; - case 7: return mScoreText7; - case 8: return mScoreText8; - case 9: return mScoreText9; + case 0: return mNumberText0; + case 1: return mNumberText1; + case 2: return mNumberText2; + case 3: return mNumberText3; + case 4: return mNumberText4; + case 5: return mNumberText5; + case 6: return mNumberText6; + case 7: return mNumberText7; + case 8: return mNumberText8; + case 9: return mNumberText9; } // default return 'zero' sprite. - return mScoreText0; + return mNumberText0; } /// - /// Do visible on zero effect after updating score. + /// Do visible on zero effect after updating number. /// private void DoVisibleOnZero(int targetScore) { @@ -420,9 +420,9 @@ private void DoVisibleOnZero(int targetScore) EnableDigitsRendererSlot(true); } } - + /// - /// Do score align after updating score. + /// Do number align after updating number. /// private void DoScoreAlign(int targetScore) { diff --git a/Assets/JCSUnity/Scripts/UI/JCS_LiquidBarText.cs b/Assets/JCSUnity/Scripts/UI/JCS_LiquidBarText.cs index f54d6283..a8a51d08 100644 --- a/Assets/JCSUnity/Scripts/UI/JCS_LiquidBarText.cs +++ b/Assets/JCSUnity/Scripts/UI/JCS_LiquidBarText.cs @@ -74,12 +74,12 @@ private void DoTextRender() if (mCounterTextSprite != null) { - mCounterTextSprite.UpdateScore((int)mLiquidBar.GetCurrentValue()); + mCounterTextSprite.UpdateNumber((int)mLiquidBar.GetCurrentValue()); } if (mFullTextSprite != null) { - mFullTextSprite.UpdateScore((int)mLiquidBar.MaxValue); + mFullTextSprite.UpdateNumber((int)mLiquidBar.MaxValue); } } } diff --git a/Assets/JCSUnity/Scripts/UI/JCS_TextDeltaNumber.cs b/Assets/JCSUnity/Scripts/UI/JCS_TextDeltaNumber.cs index 06f4efb6..6d19e4c5 100644 --- a/Assets/JCSUnity/Scripts/UI/JCS_TextDeltaNumber.cs +++ b/Assets/JCSUnity/Scripts/UI/JCS_TextDeltaNumber.cs @@ -137,7 +137,7 @@ private void Update() TestInput(); #endif - DoDeltaCurrentScore(); + DoDeltaCurrentNumber(); } #if UNITY_EDITOR @@ -172,9 +172,9 @@ public void UpdateNumber(float targetNumber, bool anime = true) } /// - /// Main algorithm to approach to targe score. + /// Main algorithm to approach to targe number. /// - private void DoDeltaCurrentScore() + private void DoDeltaCurrentNumber() { if (!mActive) return; diff --git a/docs/ScriptReference/UI/JCS_DeltaNumber.md b/docs/ScriptReference/UI/JCS_DeltaNumber.md index bf2be468..f656b92d 100644 --- a/docs/ScriptReference/UI/JCS_DeltaNumber.md +++ b/docs/ScriptReference/UI/JCS_DeltaNumber.md @@ -4,36 +4,36 @@ System that control 0-9 number sprites and create a counter effect. ## Variables -| Name | Description | -|:---------------------|:---------------------------------------------| -| mCurrentScore | Current score rendering. | -| mScoreNull |