コード例 #1
0
    void IExecuteSystem.Execute()
    {
        timer.Tick(Time.deltaTime);

        if (!timer.Done || pool.isActiveTurnBased || indexedEntities.Empty())
        {
            return; // nothing to do
        }

        nextEntity = indexedEntities.Next();
        var baseDelay = nextEntity.turnBased.delay;

        if (nextEntity.isSkipTurn)
        {
            // skip next turn but still fire delay timer to replicate
            // functionality of original game
            nextEntity.isSkipTurn = false;
            nextEntity            = null;
        }

        // delay the next entity becoming active
        bool onlyEntity = turnBasedEntities.Count < 2;
        var  delayTime  = onlyEntity ?  baseDelay * 2 : baseDelay;

        timer.Add(delayTime, () =>
        {
            if (nextEntity != null)
            {
                nextEntity.isActiveTurnBased = true;
                nextEntity = null;
            }
        });
    }