Exemple #1
0
    IEnumerator PopCandy()
    {
        for (int i = 0; i < LineList.Count; i++)
        {
            Destroy(LineList[i].gameObject);
        }
        LineList.Clear();
        if (candyQueue.Count < 3)
        {
            while (candyQueue.Count > 0)
            {
                Candy pop = candyQueue.Dequeue();
                pop.DeactiveWhite();
            }
            candyQueue.Clear();
            containList.Clear();
            lastCandyType = null;
            yield break;
        }
        int score    = 0;
        int scoreAdd = 10;

        while (candyQueue.Count > 0)
        {
            score    += scoreAdd;
            scoreAdd *= 2;
            Quest.Instance.AddScore(score);
            Candy pop = candyQueue.Dequeue();
            containList.Remove(pop);
            pop.gameObject.SetActive(false);
            Quest.Instance.KillCandy(pop);
            Vector3 position = pop.transform.position;
            position.z = -2;
            int random = Random.Range(0, EffectPool.Length);
            EffectPool[random].ActiveObject(position);
            CurrentCandyCount--;
            yield return(new WaitForSeconds(0.1f));
        }
    }