示例#1
0
    protected override void Execute(List <PoolEntity> entities)
    {
        if (pool.isNextTurn)
        {
            pool.isNextTurn = false;
        }

        var turnOrder = pool.turnOrder.value;

        if (turnOrder.Empty())
        {
            return; // nothing to do
        }

        if (pool.hasCurrentTurnNode)
        {
            pool.ReplaceCurrentTurnNode(pool.currentTurnNode.value.NextOrFirst());
        }
        else
        {
            pool.SetCurrentTurnNode(turnOrder.First);
        }

        var nextEntity = pool.currentTurnNode.value.Value;
        // delay the next entity becoming active
        var  baseDelay  = nextEntity.turnBased.delay;
        bool onlyEntity = turnBasedEntities.count < 2;
        var  delayTime  = onlyEntity ? baseDelay * 2 : baseDelay;

        pool.CreateEntity()
        .AddCoroutine(ActivateAfterDelay(delayTime, nextEntity));
    }