private IEnumerator ActivatePositiveItemsSequentially(List <int> ids)
    {
        //activate positive items sequentially
        foreach (var id in ids)
        {
            if (Contexts.sharedInstance.game.GetEntityWithId(id) == null)
            {
                continue;
            }

            yield return(DoWait.WaitSeconds(0.08f));

            var posItem = Contexts.sharedInstance.game.GetEntityWithId(id);
            if (posItem == null)
            {
                continue;
            }

            var cellItem = _contexts.game.GetEntityWithCellItemId(
                new Tuple <int, int>(posItem.gridPosition.value.x, posItem.gridPosition.value.y));
            if (cellItem != null && cellItem.isCanBeActivatedByInnerMatch)
            {
                cellItem.isWillBeDestroyed = true;
            }

            ActivatorHelper.ActivateItem(posItem, ActivationReason.Tnt);
        }
    }
Beispiel #2
0
    private IEnumerator ActivatePuzzlePuzzle(GameEntity entity)
    {
        WaitHelper.Increase(WaitType.Input, WaitType.Fall, WaitType.Turn, WaitType.CriticalAnimation);

        yield return(DoWait.WaitWhile(() => entity.isCreatedFromMatch));

        var width  = _contexts.game.board.Size.x;
        var height = _contexts.game.board.Size.y;

        var pos         = entity.gridPosition.value;
        var removerId   = IdHelper.GetNewRemoverId();
        var radius      = 0;
        var radiusLimit = (int)Mathf.Sqrt(width * width + height * height) + 1;

        var visited = new bool[width, height];

        while (radius < radiusLimit)
        {
            ProcessPuzzlePuzzle(pos, radius, removerId, visited);
            radius++;

            yield return(DoWait.WaitSeconds(0.07f));
        }

        entity.isWillBeDestroyed = true;

        WaitHelper.Reduce(WaitType.Input, WaitType.Fall, WaitType.Turn, WaitType.CriticalAnimation);
    }
Beispiel #3
0
    public void PlayAndDie()
    {
        Refresh();
        particle.Play(true);

        DoWait.WaitWhile(() => particle.isPlaying, this.Destroy);
    }
    private IEnumerator ActivatePositiveItemMatch(GameEntity touchedItem)
    {
        WaitHelper.Increase(WaitType.Input, WaitType.CriticalAnimation);

        TryDestroyBubbleOnTop(touchedItem);

        touchedItem.isMergeMaster = true;

        var pos      = touchedItem.gridPosition.value;
        var matchId  = touchedItem.matchGroup.Id;
        var posItems = _contexts.game.GetEntitiesWithMatchGroup(matchId);

        var rotorCount  = 0;
        var tntCount    = 0;
        var puzzleCount = 0;
        var puzzleColor = Color.Blue;

        var posItemIds = new List <int>();

        foreach (var posItem in posItems)
        {
            if (Equals(posItem.itemType.Value, ItemType.Rotor))
            {
                rotorCount++;
            }

            if (Equals(posItem.itemType.Value, ItemType.Tnt))
            {
                tntCount++;
            }

            if (Equals(posItem.itemType.Value, ItemType.Puzzle))
            {
                puzzleColor = posItem.color.Value;
                puzzleCount++;
            }

            posItemIds.Add(posItem.id.Value);
            posItem.AddMerging(touchedItem.gridPosition.value);
            posItem.isCanFall         = false;
            posItem.isCantBeActivated = true;
            TryDestroyBubbleOnTop(posItem);
        }

        yield return(DoWait.WaitWhile(() => touchedItem.isMergeMaster));

        foreach (var id in posItemIds)
        {
            var posItem = _contexts.game.GetEntityWithId(id);
            posItem.isWillBeDestroyed = true;
        }

        CreateCombo(pos, rotorCount, tntCount, puzzleCount, puzzleColor);
        WaitHelper.Reduce(WaitType.Input, WaitType.CriticalAnimation);
    }
Beispiel #5
0
        public void OnMergeTo(GameEntity entity, AxialCoord spot, Action callback)
        {
            var movement = transform.DOMove(HexHelperService.HexToPoint(spot), MergeDuration);

            DoWait.WaitSeconds(0.05f, () =>
                               CreateBubbleParticle(transform.position, spriteRenderer.color, mergeParticle));
            var seq = DOTween.Sequence();

            seq.AppendInterval(0.05f);
            seq.Append(movement);
            seq.onComplete += () => callback();
        }
Beispiel #6
0
        public void OnExploded(GameEntity entity, Action callback, bool isMaster)
        {
            if (!isMaster)
            {
                DoWait.WaitSeconds(0.05f, () =>
                {
                    CreateBubbleParticle(transform.position, spriteRenderer.color, dropParticle);
                    callback();
                });
                return;
            }

            DoWait.WaitSeconds(0.05f, () =>
            {
                CreateBubbleParticle(transform.position, spriteRenderer.color, explodeParticle);
                callback();
            });
        }
    private IEnumerator ActivatePuzzle(GameEntity puzzle)
    {
        yield return(DoWait.WaitUntil(() => !WaitHelper.Has(WaitType.FallingItem)));

        WaitHelper.Increase(WaitType.Input, WaitType.Fall, WaitType.Turn, WaitType.CriticalAnimation);

        TryDestroyBubbleOnTop(puzzle);

        var cubes = GetColorCubes(puzzle.color.Value);

        puzzle.AddPuzzleTargetedCubes(cubes);

        yield return(DoWait.WaitWhile(() => puzzle.hasPuzzleTargetedCubes));

        ActivateColorCubes(cubes);

        puzzle.isWillBeDestroyed = true;

        WaitHelper.Reduce(WaitType.Input, WaitType.Fall, WaitType.Turn, WaitType.CriticalAnimation);
    }
Beispiel #8
0
    private IEnumerator ActivateSpecialColorMatch(GameEntity touchedCube, IEnumerable <GameEntity> cubes, int removerId)
    {
        WaitHelper.Increase(WaitType.Turn, WaitType.Input, WaitType.CriticalAnimation);

        touchedCube.isMergeMaster = true;

        var cubeIds = new List <int>();

        foreach (var cube in cubes)
        {
            cubeIds.Add(cube.id.Value);

            ActivateColorCube(cube, removerId);

            cube.AddMerging(touchedCube.gridPosition.value);
            cube.isCanFall         = false;
            cube.isCantBeActivated = true;
        }

        var touchedCubeId = touchedCube.id.Value;

        yield return(DoWait.WaitWhile(() => touchedCube.isMergeMaster));

        CreatePositiveItem(touchedCubeId);

        foreach (var id in cubeIds)
        {
            var cube = _contexts.game.GetEntityWithId(id);

            if (cube == null)
            {
                continue;
            }

            cube.isWillBeDestroyed = true;
        }

        WaitHelper.Reduce(WaitType.Input, WaitType.Turn, WaitType.CriticalAnimation);
    }
Beispiel #9
0
 private void RemoveCreatedFromMatch(GameEntity entity)
 {
     DoWait.WaitSeconds(0.35f, () => entity.isCreatedFromMatch = false);
 }
        public void PlayAndDie()
        {
            particle.Play(true);

            DoWait.WaitWhile(() => particle.isPlaying, () => Destroy(gameObject));
        }