protected virtual void ExecuteTailCommand(CommandData commandData, Vector3 executePos, GameEntity cell, GameEntity trigger = null) { factoryEntity.CreateVFX(commandData.vfx, executePos); if (!string.IsNullOrEmpty(commandData.chainedCommand)) { commandSystem.Execute(commandData.chainedCommand, executePos, cell, trigger); } }
public bool HandleDragEnd(Vector3 screenPos) { if (dragged != null && dragged.hasGameObject) { var gridPos = Utils.GetPlaneTouchPos(screenPos, cameraService.activeCamera); var cell = gridService.GetCell(gridPos); if (gridService.IsOccupied(cell)) { var occupant = cell.cell.occupant; var mergeComboData = dataProvider.GetMergeComboDataForInput(dragged.objectId); var canMerge = occupant != dragged && mergeComboData != null && dragged.objectId.Equals(occupant.objectId); if (canMerge) { Utils.SetSortingLayer(dragged, Constants.SORTING_LAYER_DEFAULT); var spawnPos = occupant.position; dragged.isDraggable = false; occupant.isDraggable = false; // destroy the entities gridService.DeAttach(dragged); gridService.DeAttach(occupant); dragged.Destroy(); occupant.Destroy(); // spawn the output entity var command = new CommandData(); command.type = Constants.COMMAND_SPAWN_OBJ; command.output = mergeComboData.output; command.count = 1; commandSystem.Execute(command, spawnPos, cell); factoryEntity.CreateVFX(mergeComboData.vfx, spawnPos); // execute the merge complete command commandSystem.Execute(mergeComboData.mergeCompleteCommand, spawnPos, cell); // consume the gesture event return(true); } } } return(false); }