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); }
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); }
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); }
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); }
public void PlayAndDie() { particle.Play(true); DoWait.WaitWhile(() => particle.isPlaying, () => Destroy(gameObject)); }