コード例 #1
0
        private IEnumerator AccumulateImpl(int count)
        {
            OnAccumulationStateChanged(true);
            isNoCollectionProcess = false;
            int          index       = 0;
            IBankService bankService = Services.GetService <IBankService>();

            for (int i = 0; i < count; i++)
            {
                if (index < 6)
                {
                    GameObject obj = Instantiate <GameObject>(accumulatedCoinPrefab);
                    obj.transform.SetParent(transform, false);
                    obj.GetComponent <AccumulatedCoin>().StartMoving((coinObj) => {
                        bankService.CollectAccumulated(1);
                        Services.GetService <ISoundService>().PlayOneShot(SoundName.buyCoinUpgrade);
                        Destroy(coinObj);
                        UpdateViews();
                    });
                    index++;
                    yield return(new WaitForSeconds(0.15f));
                }
                else
                {
                    int cnt = count - index;
                    if (cnt > 0)
                    {
                        bankService.CollectAccumulated(cnt);
                        break;
                    }
                    //yield return new WaitForSeconds(0.05f);
                    //yield return new WaitForEndOfFrame();
                }
            }

            isNoCollectionProcess = true;
            UpdateViews();
            OnAccumulationStateChanged(false);
        }