Пример #1
0
        public bool HandleDragEnd(Vector3 screenPos)
        {
            if (dragged != null && dragged.hasGameObject)
            {
                var gridPos = Utils.GetPlaneTouchPos(screenPos, cameraService.activeCamera);
                var cell    = gridService.GetCell(gridPos);

                if (cell != null && gridService.IsOccupied(cell) && cell.cell.occupant.hasOrderList)
                {
                    foreach (var order in cell.cell.occupant.orderList.orderList)
                    {
                        bool isObjectOrder = string.Equals(dragged.objectId, order.id);
                        bool isTypeOrder   = string.Equals(dragged.typeId, order.id);

                        if (cell.cell.occupant.hasGameObject &&
                            (isObjectOrder || isTypeOrder) &&
                            !cell.cell.occupant.orderList.Filled())
                        {
                            float animationLength = 0.3f;
                            var   orderId         = isObjectOrder ? dragged.objectId : dragged.typeId;
                            if (!cell.cell.occupant.orderList.HasFilledOrder(orderId))
                            {
                                AddOrder(orderId, cell.cell.occupant);
                                SceneAttachment.AttachCoroutine(TryCompleteOrderAfterAnimation(dragged, orderId, cell, animationLength));
                                return(true);
                            }
                        }
                    }
                }

                dragged = null;
            }

            return(false);
        }
Пример #2
0
 public static void DelayedCall(float time, Action callback, bool ignoreTimeScale = false)
 {
     if (ignoreTimeScale)
     {
         SceneAttachment.AttachCoroutine(WaitForRealSeconds(time, callback));
     }
     else
     {
         SceneAttachment.AttachCoroutine(WaitForUnitySeconds(time, callback));
     }
 }