예제 #1
0
    private void DeterminationState()
    {
        var goalCompleted  = GoalHelper.IsGoalComplete();
        var movesLeft      = _contexts.game.remainingMoves.Amount > 0;
        var cantBeShuffled = _contexts.game.isCantBeShuffled;

        if (goalCompleted)
        {
            _contexts.game.ReplaceGameplayState(GameplayState.Win);
        }

        else if (!movesLeft)
        {
            _contexts.game.ReplaceGameplayState(GameplayState.Lose);
        }

        else if (cantBeShuffled)
        {
            _contexts.game.ReplaceGameplayState(GameplayState.ShuffleLose);
        }
        else
        {
            _contexts.game.ReplaceGameplayState(GameplayState.Play);
        }
    }
 protected override void Execute(List <GameEntity> entities)
 {
     foreach (var entity in entities)
     {
         GoalHelper.AddToProgress(entity.collectionEnded.GoalType, entity.collectionEnded.Amount);
         entity.isWillBeDestroyed = true;
         WaitHelper.Reduce(WaitType.CollectAnimation);
     }
 }
예제 #3
0
    private void PlayState()
    {
        var movesLeft      = _contexts.game.remainingMoves.Amount > 0;
        var goalCompleted  = GoalHelper.IsGoalComplete();
        var cantBeShuffled = _contexts.game.isCantBeShuffled;

        if (!movesLeft || goalCompleted || cantBeShuffled)
        {
            _contexts.game.ReplaceGameplayState(GameplayState.Waiting);
            WaitHelper.Increase(WaitType.Input);
        }
    }
    protected override void Execute(List <GameEntity> entities)
    {
        foreach (var entity in entities)
        {
            if (!GoalHelper.IsInGoal(entity.goalType.Value))
            {
                continue;
            }

            entity.AddCollectionStarted(1);
            WaitHelper.Increase(WaitType.CollectAnimation);
        }
    }
    protected override void Execute(List <GameEntity> entities)
    {
        foreach (var entity in entities)
        {
            if (!GoalHelper.IsInGoal(entity.goalType.Value))
            {
                continue;
            }

            var layerCount    = entity.layer.Value + 1;
            var explodeAmount = entity.willExplode.Count;
            var collectAmount = Mathf.Min(layerCount, explodeAmount);
            entity.AddCollectionStarted(collectAmount);
            WaitHelper.Increase(WaitType.CollectAnimation);
        }
    }
예제 #6
0
    private void GenerateCellItem(GameEntity generator, int defaultAmount, CellItemTypeInBoard type,
                                  GeneratorRadius generatorRadius)
    {
        var generationAmount = generator.goalEffectType.Type == GoalEffectType.Decrease
            ? CalculateGenerationAmountForCellItem(type, defaultAmount)
            : defaultAmount;

        var positionsToCheck = GetPositionsToCheck(generator.gridPosition.value, generatorRadius);

        var cellItemIds = SelectSuitableCellItems(positionsToCheck).Shuffle().Take(generationAmount).ToList();

        var reservations = new List <int>();

        foreach (var id in cellItemIds)
        {
            var reservationId = IdHelper.GetNewReservationId();
            var cell          = _contexts.game.GetEntityWithCellId(id);
            cell.AddCellItemReservation(reservationId, type);
            reservations.Add(reservationId);
            WaitHelper.Increase(WaitType.CriticalAnimation);
        }

        generator.AddReservedCells(reservations);

        if (generator.goalEffectType.Type == GoalEffectType.Decrease)
        {
            _contexts.game.goalForGenerators.Goals[type.GoalType] -= generationAmount;

            if (CalculateCellItemLeftToGenerate(type) == 0)
            {
                CloseGenerators(generator);
            }
        }
        else
        {
            GoalHelper.AddToGoal(type.GoalType, reservations.Count);
        }
    }