Exemplo n.º 1
0
    public long CheckDices(int x, int y)
    {
        long    score   = 0;
        DiceSet diceSet = GetDice(x, y);

        if (diceSet == null)
        {
            return(0);
        }

        int direction = diceSet.script.GetDirection();

        if (direction > 1)
        {
            diceSet.checking = true;
            m_aCheckDice.Add(diceSet);

            //주사위 기준으로 4방향을 재귀로 검사한다.
            CheckDiceSide(x + 1, y, direction);
            CheckDiceSide(x - 1, y, direction);
            CheckDiceSide(x, y + 1, direction);
            CheckDiceSide(x, y - 1, direction);

            //인접한 모든 같은 방향 주사위 정보 m_aCheckDice
            int defaultCount = 0;
            int bonusCount   = 0;
            int nCount       = 0;
            int nMaxChain    = 0;

            for (int i = 0; i < m_aCheckDice.Count; i++)
            {
                DiceSet ds = (DiceSet)m_aCheckDice[i];
                if (m_aCheckDice.Count >= direction)
                {
                    if (ds.script.GetState() == GameData.OBJECT_STATE_DISAPPEAR)
                    {
                        bonusCount++;
                        ds.script.PlusDisappearTime();
                    }
                    else
                    {
                        defaultCount++;
                        ds.script.DisappearDice();
                    }
                    nCount++;
                }
                //검사된 모든 주사위의 체크를 풀어준다.
                ds.checking = false;
            }

            if (defaultCount != 0 || bonusCount != 0)
            {
                if (defaultCount != 0 && bonusCount == 0)
                {
                    //처음 주사위 맞출때
                    SoundManager.g_Instance.PlayEffectSound("dice_clear_01");
                    result_DiceN[direction] += direction;
                }
                else if (defaultCount != 0 && bonusCount != 0)
                {
                    //체인 으로 맞출때
                    SoundManager.g_Instance.PlayEffectSound("chain_success_01");
                    string strName = "chain_random";
                    strName += "_";
                    strName += Random.Range(1, 7);
                    SoundManager.g_Instance.PlayEffectSound(strName);

                    for (int i = 0; i < m_aCheckDice.Count; ++i)
                    {
                        DiceSet ds = (DiceSet)m_aCheckDice[i];
                        ds.nChain++;
                        if (ds.nChain > nMaxChain)
                        {
                            nMaxChain = ds.nChain;
                        }
                    }

                    for (int i = 0; i < m_aCheckDice.Count; ++i)
                    {
                        DiceSet ds = (DiceSet)m_aCheckDice[i];
                        ds.nChain = nMaxChain;
                    }

                    ClearWaveEffect();

                    diceSet.nEmitterType   = DiceSet.EMITTER_TYPE_CURRENT;
                    m_aWaveEffectCheckDice = new ArrayList(m_aCheckDice);
                    ChainEffect(nMaxChain);

                    if (nMaxChain > CScoreManager.m_nMaxChain)
                    {
                        CScoreManager.m_nMaxChain = nMaxChain;
                    }

                    result_DiceN[direction] += 1;
                }

                score = CScoreManager.GetScore(direction, defaultCount, bonusCount, nMaxChain);

                //Debug.Log("? : " + result_DiceN.Length);

                if (ScoreLabelObj.instance != null)
                {
                    ScoreLabelObj.instance.createScoreLabel(score);
                }

                //result_DiceN[0] += 1;
                //result_DiceN[direction] += 1;
                if (nMaxChain > result_maxChain)
                {
                    result_maxChain = nMaxChain;
                }
                if (nMaxChain > 0 && score > result_maxChainScore)
                {
                    result_maxChainScore = score;
                }


                //Debug.Log("TEST !!!");
                //for(int i = 0 ; i < result_DiceN.Length; i++)
                //{
                //    Debug.Log(i + " : " + result_DiceN[i]);
                //}
                //Debug.Log("maxChain : " + result_maxChain);
                //Debug.Log("maxChainScore : " + result_maxChainScore);
            }

            m_aCheckDice.Clear();
        }

        return(score);
    }