/// <summary> /// This function helper for set Slot Controller. /// </summary> /// <returns></returns> public void SetSlotController(SlotController slotController) { this.slotController = slotController; hexagon.SetSlot(slotController.GetSlot()); slotController.SetHexagonController(this); SlotChanged?.Invoke(slotController); }
/// <summary> /// This function helper for shift some hexagons like gravity.. /// </summary> /// <returns></returns> public async UniTask Gravity() { isGravity = true; Debug.Log("Gravity Progress Started."); foreach (List <SlotController> verticalSlots in seperateSlotControllers) { int emptyCount = 0; int interactedCount = 1; foreach (SlotController slotController in verticalSlots.AsEnumerable().Reverse().ToList()) { if (slotController.GetHexagonController() == null) { emptyCount++; continue; } if (emptyCount == 0) { continue; } HexagonController hexagonController = slotController.GetHexagonController(); SlotController oldSlotController = hexagonController.GetSlotController(); SlotController targetSlotController = GetSlotControllerByCoordinate(new Coordinate(hexagonController.GetCoordinate().x, hexagonController.GetCoordinate().y + emptyCount)); if (targetSlotController == null) { continue; } oldSlotController.SetHexagonController(null); hexagonController.SetSlotController(targetSlotController); ((HexagonView)hexagonController.GetView()).DrawDefaultLayer(true, (float)interactedCount / 10); interactedCount++; } } await UniTask.WaitUntil(() => !DOTween.IsTweening(CommonTypes.HEXAGON_GRAVITY_TWEEN_KEY)); FillEmptySlots(); await UniTask.WaitUntil(() => !DOTween.IsTweening(CommonTypes.HEXAGON_GRAVITY_TWEEN_KEY)); await CheckHexagons(hexagonControllers); await CheckGameOver(); isGravity = false; Debug.Log("Gravity Progress Completed."); }