protected void Process(PointerEventArgs pointerEvent)
        {
            PointerPoint point = pointerEvent.CurrentPoint;

            switch (point.EventType)
            {
            case PointerEventType.CaptureLost:
                break;

            case PointerEventType.Entered:
                break;

            case PointerEventType.Exited:
                break;

            case PointerEventType.Moved:
                CurrentOverlay.ProcessPointerMovement(pointerEvent);
                break;

            case PointerEventType.Pressed:
                CurrentOverlay.ProcessPointerPress(pointerEvent);
                break;

            case PointerEventType.Released:
                CurrentOverlay.ProcessPointerRelease(pointerEvent);
                break;

            case PointerEventType.WheelChanged:
                break;

            default:
                throw new ArgumentOutOfRangeException("point");
            }
        }
示例#2
0
 private void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         RaycastHit touchBox;
         Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out touchBox);
         if (!NeedsMoving && BuildingClickedProduction != null && IsProductionOverlayActive &&
             CurrentOverlay.GetComponentsInChildren <ProductionScript>().All(x => x.collider != touchBox.collider))
         {
             InitiateMoving(true);
         }
     }
     PositionOverlay();
 }
示例#3
0
        /// <summary>
        /// This method is executed when an clicked on building event is fired.
        /// </summary>
        /// <param Name="evt"></param>
        private void OnBuildingClick(OnBuildingClick evt)
        {
            if (evt.building != null)
            {
                if (!IsProductionOverlayActive && evt.building.BuildingGame.CanProduce)
                {
                    BuildingClickedProduction         = evt.building;
                    CurrentOverlay                    = CreatorFactoryProductionOverlay.CreateProductionOverlay(BuildingClickedProduction.type);
                    CurrentOverlay.transform.position = GetBelowScreenPosition();
                    CurrentOverlay.transform.parent   = Camera.main.transform;

                    CurrentOverlay.GetComponentsInChildren <ProductionScript>().ToList().ForEach(x => x.ParentProduction = this);
                    InitiateMoving(false);
                    IsProductionOverlayActive = true;
                }
            }
        }
示例#4
0
        /// <summary>
        /// Move the overlay from the bottom of the screen to just above.
        /// </summary>
        public void PositionOverlay()
        {
            if (NeedsMoving)
            {
                float time = GetTimePassed();
                CurrentOverlay.transform.position = Vector2.Lerp(startPosition, targetPosition, time);

                if (time >= 1f)
                {
                    if (EndOfMovingDestroyed)
                    {
                        DestroyAndStopOverlay();
                    }
                    else
                    {
                        NeedsMoving = false;
                        CurrentOverlay.GetComponentsInChildren <ProductionScript>()
                        .ToList().ForEach(x => x.CanClick = true);
                    }
                }
            }
        }