private void ActivateColorCube(GameEntity cube, int removerId) { var color = cube.color.Value; var cubePos = cube.gridPosition.value; var cellItem = _contexts.game.GetEntityWithCellItemId(new Tuple <int, int>(cubePos.x, cubePos.y)); if (cellItem != null && cellItem.isCanBeActivatedByInnerMatch) { cellItem.isWillBeDestroyed = true; } int x = cubePos.x; int y = cubePos.y; var positions = new[] { new Vector2Int(x - 1, y), new Vector2Int(x + 1, y), new Vector2Int(x, y - 1), new Vector2Int(x, y + 1), }; for (int i = 0; i < positions.Length; i++) { var pos = positions[i]; if (!InBounds(pos)) { continue; } ActivatorHelper.TryActivateItemWithNear(_contexts, pos, removerId, color); } }
private void ActivateColorCube(GameEntity cube) { var color = cube.color.Value; var cubePos = cube.gridPosition.value; var removerId = cube.removerId.Value; var entitySet = _contexts.game.GetEntitiesWithGridPosition(cubePos); GameEntity cellItem = null; foreach (var entity in entitySet) { if (entity.isCellItem) { cellItem = entity; } } if (cellItem != null && cellItem.isCanBeActivatedByInnerMatch) { cellItem.isWillBeDestroyed = true; } int x = cubePos.x; int y = cubePos.y; var positions = new[] { new Vector2Int(x - 1, y), new Vector2Int(x + 1, y), new Vector2Int(x, y - 1), new Vector2Int(x, y + 1), }; for (int i = 0; i < positions.Length; i++) { var pos = positions[i]; if (!InBounds(pos)) { continue; } ActivatorHelper.TryActivateItemWithNear(_contexts, pos, removerId, color); } cube.isWillBeDestroyed = true; }