//
    void SetUpgradeState(ENUM_UPGRADE_STATE state, int iIndex, int iOption)
    {
        switch (state)
        {
        case ENUM_UPGRADE_STATE.NONE: break;

        case ENUM_UPGRADE_STATE.EXPERIENCE:
        {
            if ((iIndex > 9999) || (iIndex < 0))
            {
                iIndex = 0;                                                      //out of range
            }
            string sResult   = Convert.ToString(iIndex);
            int    iMaxDigit = 4;                  //位數上限
            for (int i = 0; i < iMaxDigit; i++)
            {
                UpgradeExp[i].SetActive(true);                                                      //reset
            }
            int iCount = 0;
            for (int i = 0; i < sResult.Length; i++)
            {
                string s    = "" + sResult[sResult.Length - 1 - i];                  //從此字串個位數開始
                int    vOut = int.Parse(s);
                if (i >= iMaxDigit)
                {
                    break;                                                                                                         //防當
                }
                UpgradeExp[iMaxDigit - 1 - i].GetComponent <JSK_MenuObject>().setMenuState(JSK_MenuState.ENUM_SPRITE_INDEX, vOut); //從畫面上的個位數開始
                iCount++;
            }
            for (/*    */; iCount < iMaxDigit; iCount++)
            {
                UpgradeExp[iMaxDigit - 1 - iCount].GetComponent <JSK_MenuObject>().setMenuState(JSK_MenuState.ENUM_SPRITE_INDEX, 0);                   //從畫面上的個位數開始補0
            }
            break;
        }

        case ENUM_UPGRADE_STATE.LEVEL:
        {
            if ((iIndex > 9999) || (iIndex < 0))
            {
                iIndex = 0;                                                      //out of range
            }
            string sResult   = Convert.ToString(iIndex);
            int    iMaxDigit = 4;                  //位數上限
            for (int i = 0; i < iMaxDigit; i++)
            {
                UpgradeLevel[i].SetActive(true);                                                      //reset
            }
            int iCount = 0;
            for (int i = 0; i < sResult.Length; i++)
            {
                string s    = "" + sResult[i];                      //從此字串最高位數開始
                int    vOut = int.Parse(s);
                if (i >= iMaxDigit)
                {
                    break;                                                                                           //防當
                }
                UpgradeLevel[i].GetComponent <JSK_MenuObject>().setMenuState(JSK_MenuState.ENUM_SPRITE_INDEX, vOut); //從畫面上的最高位數開始
                iCount++;
            }
            for (/*    */; iCount < iMaxDigit; iCount++)
            {
                UpgradeLevel[iCount].SetActive(false);                        //把未顯示的位數Hide
            }
            break;
        }

        case ENUM_UPGRADE_STATE.MONEY:
        {
            if ((iIndex > 9999) || (iIndex < 0))
            {
                iIndex = 0;                                                      //out of range
            }
            string sResult   = Convert.ToString(iIndex);
            int    iMaxDigit = 4;                  //位數上限
            for (int i = 0; i < iMaxDigit; i++)
            {
                UpgradeMoney[i].SetActive(true);                                                      //reset
            }
            int iCount = 0;
            for (int i = 0; i < sResult.Length; i++)
            {
                string s    = "" + sResult[sResult.Length - 1 - i];                  //從此字串個位數開始
                int    vOut = int.Parse(s);
                if (i >= iMaxDigit)
                {
                    break;                                                                                                           //防當
                }
                UpgradeMoney[iMaxDigit - 1 - i].GetComponent <JSK_MenuObject>().setMenuState(JSK_MenuState.ENUM_SPRITE_INDEX, vOut); //從畫面上的個位數開始
                iCount++;
            }
            for (/*    */; iCount < iMaxDigit; iCount++)
            {
                UpgradeMoney[iMaxDigit - 1 - iCount].SetActive(false);                    //把未顯示的位數Hide
            }
            break;
        }

        case ENUM_UPGRADE_STATE.RATIO:
        {
            if ((iIndex > 9999) || (iIndex < 0))
            {
                iIndex = 0;                                                      //out of range
            }
            string sResult   = Convert.ToString(iIndex);
            int    iMaxDigit = 4;                  //位數上限
            for (int i = 0; i < iMaxDigit; i++)
            {
                UpgradeRatio[i].SetActive(true);                                                      //reset
            }
            int iCount = 0;
            for (int i = 0; i < sResult.Length; i++)
            {
                string s    = "" + sResult[sResult.Length - 1 - i];                  //從此字串個位數開始
                int    vOut = int.Parse(s);
                if (i >= iMaxDigit)
                {
                    break;                                         //防當
                }
                SpriteRendererUtility.Instance().SetGameObjectSprite(UpgradeRatio[iMaxDigit - 1 - i], vOut, iOption);
                iCount++;
            }
            for (/*    */; iCount < iMaxDigit; iCount++)
            {
                UpgradeRatio[iMaxDigit - 1 - iCount].SetActive(false);                    //把未顯示的位數Hide
            }
            break;
        }

        case ENUM_UPGRADE_STATE.EMPTY:
        {
            int iRandomBehaviour = UnityEngine.Random.Range(0, 3);
            SpriteRendererUtility.Instance().SetGameObjectNumber(UpgradeEmpty, 359, 4, iOption, iRandomBehaviour);
            break;
        }

        default: break;
        }
    }
示例#2
0
 // Use this for initialization
 void Start()
 {
     Self = this;
 }