コード例 #1
0
    private IEnumerator Tick()
    {
        if (!_tickStarted) // Throw it away if there's  already a Tick going. Just to be sure we don't end up with multiples per generator.
        {
            float timer = 0.0f;
            _tickStarted = true;
            while (generatorType == GeneratorType.Tick)
            {
                if (_debugPrintTick)
                {
                    print(name + " -> TICK (" + tickDurationInSeconds + "s) for $" + TotalAmountPerClick(currentLevel));
                }

                while (timer < tickDurationInSeconds)
                {
                    timer   += Time.deltaTime;
                    progress = timer / tickDurationInSeconds;
                    yield return(new WaitForEndOfFrame());
                }//while
                timer = 0;
                currency.AddAmount(TotalAmountPerClick(currentLevel));

                //yield return new WaitForSeconds(generateAfterSeconds);
                yield return(new WaitForEndOfFrame());
            } //while
            _tickStarted = false;
        }     //if
        else
        {
            Debug.LogWarning(this.GetType() + " is trying to start multiple Tick() coroutines");
        } //else
    }     //Tick
コード例 #2
0
    }     //Start

    public void OnClick()
    {
        currency.AddAmount(Value);
        //print(currency.ClickRate);
    } //OnClick