コード例 #1
0
ファイル: MainGame.cs プロジェクト: dev4robi/portfolio
    // 점수 연산
    public void UpdateScore()
    {
        if (selectedDotList.Count < 2)
        {
            return;
        }

        // 연산
        int iLinked      = selectedDotList.Count - 1;
        int iGottenScore = (iLinked * iLinked) * iScoreBase;

        iScore   += iGottenScore;
        iLinkCnt += iLinked;
        if (iMaxLink < iLinked)
        {
            iMaxLink = iLinked;
        }

        // UI 수정
        Transform scoreTextTrans = uiobjScoreBoard.transform.FindChild("Score Text");

        scoreTextTrans.GetComponent <Text>().text = iScore.ToString();
        scoreTextTrans.GetComponent <ScoreText>().DoDynamicEffect();
        uiobjScoreBoard.transform.FindChild("Max Link Text").GetComponent <Text>().text   = "Max Link : " + iMaxLink.ToString();
        uiobjScoreBoard.transform.FindChild("Total Link Text").GetComponent <Text>().text = "Total Link : " + iLinkCnt.ToString();

        // UI 생성
        if (iGottenScore > 500)
        {
            GameObject objDynamicScoreText = Instantiate(GameData.pfabScoreTextUI, Camera.main.WorldToScreenPoint(
                                                             selectedDotList[iLinked].transform.position), Quaternion.identity, uiobjUI.transform);
            Text   dsText    = objDynamicScoreText.GetComponent <Text>();
            string strTail   = "";
            float  fDuration = 0.75f;

            if (iGottenScore > 10000)
            {
                dsText.fontSize = 70;
                strTail         = "!!!";
                fDuration       = 1.50f;
            }
            else if (iGottenScore > 7000)
            {
                dsText.fontSize = 65;
                strTail         = "!!";
                fDuration       = 1.25f;
            }
            else if (iGottenScore > 2000)
            {
                dsText.fontSize = 60;
                strTail         = "!";
                fDuration       = 1.00f;
            }
            else if (iGottenScore > 500)
            {
                dsText.fontSize = 50;
                strTail         = "";
                fDuration       = 0.75f;
            }

            dsText.text  = "+" + iGottenScore + strTail;
            dsText.color = selectedDotList[iLinked].GetComponent <DotObject>().GetDotColor();
            objDynamicScoreText.GetComponent <DynamicText>().SetDynamicText(fDuration, Vector3.up);
        }

        // 이벤트 함수 수행
        if (OnScoreUpdate != null)
        {
            OnScoreUpdate();
        }

        // Normal Mode시 시간초 증가
        if (gameMode.GetType() == typeof(ModeNormal))
        {
            ModeNormal mode = gameMode as ModeNormal;
            mode.AddTimeLeft(iLinked);
        }
    }