Example #1
0
    void TickSLA()
    {
        foreach (var block in board.GetBlocks())
        {
            block.Satisfied = false;
        }
        BlockMap blocks           = new BlockMap(board.GetBlocks());
        bool     everythingIsFine = true;

        foreach (var feature in featureManager.GetFeatures())
        {
            var satisfied = feature.CheckSatisfied(blocks);
            if (!satisfied)
            {
                if (!feature.Beta)
                {
                    sla -= feature.SLAEffect;
                    everythingIsFine = false;
                }
                feature.MarkAsUnSatisfied();
            }
            else
            {
                if (feature.Beta)
                {
                    feature.Beta = false;
                }
                money += feature.Income;
                if (!feature.LastSatisfied)
                {
                    feature.MarkAsSatisfied();
                    tadaSound.Play();
                }
            }
            feature.LastSatisfied = satisfied;
        }
        if (everythingIsFine)
        {
            sla += slaRecoverSpeed;
        }
        sla = Mathf.Clamp(sla, 0, maxSLA);
        var slaPercent = 100 * sla / maxSLA;

        slaPercentText.text = string.Format("{0}%", slaPercent);

        var blockCount = blocks.Count();

        if (state == State.Begun)
        {
            blockCount--;
        }
        money -= blockCount;
        if (money < 0)
        {
            money = 0;
        }
        moneyText.text = string.Format("${0}", money);
    }