// ================================================= public Function ===========================================================

    // Displayer 표시
    public void Init(string npcName, Sprite npcSprite, bool disabledPull, bool disabledLook, bool disabledPincer)
    {
        // 현재 대화하고 있는 npc 이름 갱신.
        this.npcName = npcName;

        // 이미지를 지정
        NPCImage.sprite    = npcSprite;
        NPCBigImage.sprite = npcSprite;

        // 각 모드들 준비
        touchMode = PullMode.pullMode;
        touchMode.Init();
        touchMode = LookMode.lookMode;
        touchMode.Init();
        touchMode = PincerMode.pincerMode;
        touchMode.Init();

        // Displayer 우측 버튼 초기화
        observationWayManager.Init(disabledPull, disabledLook, disabledPincer);

        // Displayer 좌측 Text들 초기화
        GottenItemTextInit();
        ChatTextInit();


        // Displayer 화면에 표시
        Displayer.SetActive(true);
    }
Exemplo n.º 2
0
        /// <summary>
        /// Called, when mouse/finger/pen click/touch map
        /// </summary>
        /// <param name="touchPoints">List of all touched points</param>
        private bool OnTouchStart(List <Geometries.Point> touchPoints)
        {
            // Sanity check
            if (touchPoints.Count == 0)
            {
                return(false);
            }

            var args = new TouchedEventArgs(touchPoints);

            TouchStarted?.Invoke(this, args);

            if (args.Handled)
            {
                return(true);
            }

            if (touchPoints.Count == 2)
            {
                (_previousCenter, _previousRadius, _previousAngle) = GetPinchValues(touchPoints);
                _mode          = TouchMode.Zooming;
                _innerRotation = Viewport.Rotation;
            }
            else
            {
                _mode           = TouchMode.Dragging;
                _previousCenter = touchPoints.First();
            }

            return(true);
        }
Exemplo n.º 3
0
 private void SetTouchMode(TouchMode mode)
 {
     Configuration.TouchMode = mode;
     TouchModeItem.Label     = $"Set touch mode [{mode.ToString()}]";
     Menu.RecalculateSpacings();
     Menu.RevertSelection(1);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Called, when mouse/finger/pen click/touch map
        /// </summary>
        /// <param name="touchPoints">List of all touched points</param>
        private bool OnTouchStart(List <Geometries.Point> touchPoints)
        {
            // Sanity check
            if (touchPoints.Count == 0)
            {
                return(false);
            }

            // We have a new interaction with the screen, so stop all navigator animations
            Navigator.StopRunningAnimation();

            var args = new TouchedEventArgs(touchPoints);

            TouchStarted?.Invoke(this, args);

            if (args.Handled)
            {
                return(true);
            }

            if (touchPoints.Count == 2)
            {
                (_previousCenter, _previousRadius, _previousAngle) = GetPinchValues(touchPoints);
                _mode          = TouchMode.Zooming;
                _innerRotation = Viewport.Rotation;
            }
            else
            {
                _mode           = TouchMode.Dragging;
                _previousCenter = touchPoints.First();
            }

            return(true);
        }
    // Displayer 우측 버튼 중 Pincer 버튼 클릭
    public void OnClickPincerBtn()
    {
        /*
         * // 이미지 터치 기준 알파값 지정(터치 지점 알파값이 0.1f 이상인 경우에만 터치로 인정)
         * NPCImage.alphaHitTestMinimumThreshold = 0.1f;
         * NPCImage.raycastTarget = true;
         *
         * // Pull 행동에 대한 Event List 제거
         * pullEvents.SetActive(false);
         *
         * // Look 행동에 대한 Event List 제거
         * lookEvents.SetActive(false);
         *
         * touchMode = PincerMode.pincerMode;
         */

        NPCImage.raycastTarget = false;

        // Pincer 행동에 대한 Event List 표시
        pincerEvents.transform.Find(npcName).gameObject.SetActive(true);
        pincerEvents.SetActive(true);

        // Pull 행동에 대한 Event List 제거
        pullEvents.SetActive(false);

        // Look 행동에 대한 Event List 제거
        lookEvents.SetActive(false);

        touchMode = PincerMode.pincerMode;
        touchMode.Init();
    }
Exemplo n.º 6
0
    public void UpdateTouchMode(PointerEventData pe)
    {
        Invoke(pe, TouchMode.Drag);
        _time++;

        // _acc += (pe.position.x - _beforeTouchPos.x);



        Vector2 dist = (pe.position - _anchorTouchPos);

        if (dist.magnitude > _borderLength && _nowMode == TouchMode.PointerDown)
        {     //ある程度ドラッグ
            if (Mathf.Abs(dist.x) > Mathf.Abs(Mathf.Cos(_arrowHorizontalAngle * Mathf.PI / 180) * dist.magnitude))
            { //横方向への引張り
                _nowMode = TouchMode.HorizontalDrag;
            }
            else
            {//縦方向
                _nowMode = TouchMode.VerticalDrag;
            }
        }

        if (_nowMode != TouchMode.PointerDown)
        {
            Invoke(pe, _nowMode);
        }
        // if (Mathf.Abs(_acc) > 2)

        //_acc *= 0.9f;
        //_beforeTouchPos = pe.position;
    }
Exemplo n.º 7
0
        public MapAction Handle(MotionEvent motionEvent)
        {
            MapAction mapAction = MapAction.None;

            var x = (int)motionEvent.RawX;
            var y = (int)motionEvent.RawY;

            switch (motionEvent.Action)
            {
            case MotionEventActions.Down:
                PreviousTouch = new PointF(x, y);
                Touch         = new PointF(x, y);
                Mode          = TouchMode.Dragging;
                break;

            case MotionEventActions.Up:
                return(MapAction.RefreshData);

            case MotionEventActions.Pointer2Down:
                PreviousTouch = new PointF(x, y);
                Touch         = new PointF(x, y);
                _oldDist      = Spacing(motionEvent);
                MidPoint(Touch, motionEvent);
                PreviousTouch = Touch;
                Mode          = TouchMode.Zooming;
                break;

            case MotionEventActions.Pointer2Up:
                return(MapAction.RefreshData);

            case MotionEventActions.Move:
                switch (Mode)
                {
                case TouchMode.Dragging:
                    Scale         = 1;
                    PreviousTouch = Touch;
                    Touch         = new PointF(x, y);
                    mapAction     = MapAction.RefreshGraphics;
                    break;

                case TouchMode.Zooming:
                    if (motionEvent.PointerCount < 2)
                    {
                        return(MapAction.None);
                    }

                    var newDist = Spacing(motionEvent);
                    Scale = newDist / _oldDist;

                    _oldDist      = Spacing(motionEvent);
                    PreviousTouch = new PointF(Touch.X, Touch.Y);
                    MidPoint(Touch, motionEvent);
                    mapAction = MapAction.RefreshGraphics;
                    break;
                }
                break;
            }
            return(mapAction);
        }
Exemplo n.º 8
0
 public void StartTouchMode(PointerEventData pe)
 {
     Debug.Log("touch");
     //タッチの瞬間
     Invoke(pe, TouchMode.PointerDown);
     _anchorTouchPos = pe.position;
     _nowMode        = TouchMode.PointerDown;
 }
 public TouchModeRecognizer(InkCanvas canvas)
 {
     _PrevTouchMode = TouchMode.None;
     PenDevID       = -1;
     //canvas.PreviewTouchDown += new EventHandler<TouchEventArgs>(canvas_PreviewTouchDown);
     //canvas.PreviewTouchMove += new EventHandler<TouchEventArgs>(canvas_PreviewTouchMove);
     //canvas.PreviewTouchUp += new EventHandler<TouchEventArgs>(canvas_PreviewTouchUp);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Initializes a new Touch class.
 /// </summary>
 /// <param name="id">The Id.</param>
 /// <param name="contact">The ContactSize.</param>
 /// <param name="location">The Location.</param>
 /// <param name="dateTime">The DateTime.</param>
 /// <param name="touchMode">The TouchMode.</param>
 public Touch(int id, Vector2 contact, Vector2 location, DateTime dateTime, TouchMode touchMode)
 {
     Id = id;
     Contact = contact;
     Location = location;
     Time = dateTime;
     TouchMode = touchMode;
     ContactRectangle = new Rectangle(location, contact);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Initializes a new Touch class.
 /// </summary>
 /// <param name="id">The Id.</param>
 /// <param name="contact">The ContactSize.</param>
 /// <param name="location">The Location.</param>
 /// <param name="dateTime">The DateTime.</param>
 /// <param name="touchMode">The TouchMode.</param>
 public Touch(int id, Vector2 contact, Vector2 location, DateTime dateTime, TouchMode touchMode)
 {
     Id               = id;
     Contact          = contact;
     Location         = location;
     Time             = dateTime;
     TouchMode        = touchMode;
     ContactRectangle = new Rectangle(location, contact);
 }
Exemplo n.º 12
0
 public void AddCallback(UnityAction <PointerEventData> cb, TouchMode eid)
 {
     _callBack.Add((e, t) => {
         if (t == eid)
         {
             cb(e);
         }
     });
 }
Exemplo n.º 13
0
 public void EndBuild()
 {
     touchMode = TouchMode.MAIN;
     UIController.SetPanel(UIController.Panel.MAIN);
     CameraController.ZoomOut();
     foreach (BuildingSlot buildingSlot in buildingSlots)
     {
         buildingSlot.HideIndicator();
     }
 }
Exemplo n.º 14
0
        //Initialise class and base
        public Touch(int pTapTimeout = 500, double pThreshold = 4) : base("rMultiplatform.Touch")
        {
            GestureThreshold = pThreshold;
            TapTimeout       = pTapTimeout;

            Mode     = TouchMode.Normal;
            TapTimer = new CancellableTimer(TimeSpan.FromMilliseconds(TapTimeout), TapTimer_Expired);

            PreviousType = TouchPoint.eTouchType.eReleased;
            Cursors      = new Dictionary <uint, TouchCursor>();
        }
Exemplo n.º 15
0
        private bool OnTouchPressed(SKTouchEventArgs e)
        {
            var ticks    = DateTime.Now.Ticks;
            var location = e.Location;

            initialTouch  = location;
            touches[e.Id] = new TouchEvent(e.Id, location, ticks, e.InContact);

            // update the fling tracker
            flingTracker.Clear();

            // if we are in the middle of a multi-tap, then restart with more taps
            if (multiTapTimer != null)
            {
                multiTapTimer.Dispose();
                multiTapTimer = null;
                tapCount++;
            }
            else
            {
                tapCount = 1;
            }

            var handled = false;

            // start detecting once a finger is on the screen
            var touchPoints = GetInContactTouchPoints();

            if (touchPoints.Length > 0)
            {
                // try start a gesture
                var args = new SKGestureEventArgs(touchPoints);
                OnGestureStarted(args);
                handled = args.Handled;

                // if no gesture was detected, then we will handle it
                if (!handled)
                {
                    if (touchPoints.Length == 2)
                    {
                        previousValues = PinchValue.FromLocations(touchPoints);
                        touchMode      = TouchMode.Multiple;
                    }
                    else
                    {
                        previousValues.Center = touchPoints.First();
                        touchMode             = TouchMode.Single;
                    }
                    handled = true;
                }
            }

            return(handled);
        }
Exemplo n.º 16
0
    public void StartBuild()
    {
        touchMode = TouchMode.BUILD;
        UIController.SetPanel(UIController.Panel.BUILD);
        CameraController.ZoomIn();

        foreach (BuildingSlot buildingSlot in buildingSlots)
        {
            buildingSlot.HideIndicator();
        }
    }
Exemplo n.º 17
0
    public void Select(BuildingSlot buildingSlot)
    {
        touchMode            = TouchMode.BUILDING_SELECTED;
        selectedBuildingSlot = buildingSlot;
        foreach (BuildingSlot buildingSlotToHide in buildingSlots)
        {
            buildingSlotToHide.HideIndicator();
        }
        selectedBuildingSlot.ShowIndicator();

        UIController.SetUpgradeButton(selectedBuildingSlot.child);
        UIController.SetPanel(UIController.Panel.BUILDING_SELECTED);
    }
    // 초기 아무런 버튼을 안누른 상태
    public void OnClickDefaultBtn()
    {
        // Pull 행동에 대한 Event List 제거
        pullEvents.SetActive(false);

        // Look 행동에 대한 Event List 제거
        lookEvents.SetActive(false);

        // Pincer 행동에 대한 Event List 제거
        pincerEvents.SetActive(false);

        touchMode = DefaultMode.defaultMode;
    }
Exemplo n.º 19
0
 public void EndTouchMode(PointerEventData pe)
 {
     _time = 0;
     //_acc = 0;
     if (_nowMode == TouchMode.VerticalDrag)
     {
         _nowMode = TouchMode.EndVerticalDrag;
     }
     if (_nowMode == TouchMode.HorizontalDrag)
     {
         _nowMode = TouchMode.EndHorizontalDrag;
     }
     Invoke(pe, _nowMode);
     Invoke(pe, TouchMode.PointerUp);
 }
Exemplo n.º 20
0
        /// <summary>
        /// Called, when mouse/finger/pen anymore click/touch map
        /// </summary>
        /// <param name="touchPoints">List of all touched points</param>
        /// <param name="releasedPoint">Released point, which was touched before</param>
        private bool OnTouchEnd(List <Geometries.Point> touchPoints, Geometries.Point releasedPoint)
        {
            var args = new TouchedEventArgs(touchPoints);

            TouchEnded?.Invoke(this, args);

            // Last touch released
            if (touchPoints.Count == 0)
            {
                _mode = TouchMode.None;
                _map.RefreshData(_viewport.Extent, _viewport.Resolution, true);
            }

            return(args.Handled);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Called, when mouse/finger/pen anymore click/touch map
        /// </summary>
        /// <param name="touchPoints">List of all touched points</param>
        /// <param name="releasedPoint">Released point, which was touched before</param>
        private bool OnTouchEnd(List <Geometries.Point> touchPoints, Geometries.Point releasedPoint)
        {
            var args = new TouchedEventArgs(touchPoints);

            TouchEnded?.Invoke(this, args);

            // Last touch released
            if (touchPoints.Count == 0)
            {
                InvalidateCanvas();
                _mode = TouchMode.None;
                _map.ViewChanged(true);
            }

            return(args.Handled);
        }
Exemplo n.º 22
0
        void RemoveCursor(TouchActionEventArgs args)
        {
            Cursors.Remove(args.ID);
            if (Mode == TouchMode.Pinch)
            {
                PinchProcessor.Clear();

                if (Cursors.Count == 1)
                {
                    Mode = TouchMode.Pan;
                }
            }
            if (Cursors.Count == 0)
            {
                Mode = TouchMode.Normal;
            }
        }
    // Displayer 우측 버튼 중 Look 버튼 클릭
    public void OnClickLookBtn()
    {
        // 이미지 터치 기준 알파값 지정(터치 지점 알파값이 0.1f 이상인 경우에만 터치로 인정)
        NPCImage.raycastTarget = true;

        // Look 행동에 대한 Event List 표시
        lookEvents.transform.Find(npcName).gameObject.SetActive(true);
        lookEvents.SetActive(true);

        // Pull 행동에 대한 Event List 제거
        pullEvents.SetActive(false);

        // Pincer 행동에 대한 Event List 제거
        pincerEvents.SetActive(false);

        touchMode = LookMode.lookMode;
    }
Exemplo n.º 24
0
    public void StartBuildPlace(int buildingIndex)
    {
        touchMode          = TouchMode.BUILD_PLACE;
        buildingPlaceIndex = buildingIndex;

        UIController.SetPanel(UIController.Panel.BUILD_PLACE);
        foreach (BuildingSlot buildingSlot in buildingSlots)
        {
            if (buildingSlot.IsAvailable())
            {
                buildingSlot.ShowIndicator();
            }
            else
            {
                buildingSlot.HideIndicator();
            }
        }
    }
Exemplo n.º 25
0
//METHODS//////////////////////////////////////////////////////////////////////////////////////////
    void SwitchBetweenModes(TouchMode Mode, TouchEvent touchEvent, PointerEventData eventData)
    {
        switch (Mode)
        {
        case TouchMode.ModeA:   ModeA(touchEvent, eventData); break;

        case TouchMode.ModeB:   ModeB(touchEvent, eventData); break;

        case TouchMode.ModeC:   ModeC(touchEvent, eventData); break;

        case TouchMode.ModeD:   ModeD(touchEvent, eventData); break;

        default:
            Debug.LogError("TouchMode Enum has returned a velue greater than what is considering the Switch statement. Please check the TouchMode declaration or the switch cases");
            /*If TouchMode enum list gets bigger, default should cover that case with an error*/
            break;
        }
    }
        private void MoveToNext(TouchMode state)
        {
            System.Diagnostics.Debug.WriteLine(string.Format("현재터치모드 : {0}", state));

            if (_PrevTouchMode != state)
            {
                _PrevTouchMode = state;

                if (state == TouchMode.Multi)
                {
                    this.IsMultiTouch = true;
                    System.Diagnostics.Debug.WriteLine(string.Format("Multitouch"));
                }
                else
                {
                    this.IsMultiTouch = false;
                    System.Diagnostics.Debug.WriteLine(string.Format("Singletouch"));
                }
            }
        }
		/// <summary>
		/// Initializes a new instance of the <see cref="MonoBrick.EV3.TouchSensor"/> class.
		/// </summary>
		/// <param name="mode">Mode.</param>
		public TouchSensor (TouchMode mode) :  base((SensorMode)mode)
		{
		
		}
Exemplo n.º 28
0
        public void MapView_Touch(object sender, TouchEventArgs args)
        {
            if (_gestureDetector.OnTouchEvent(args.Event))
            {
                return;
            }

            var touchPoints = GetScreenPositions(args.Event, this);

            switch (args.Event.Action)
            {
            case MotionEventActions.Up:
                RefreshGraphics();
                _mode = TouchMode.None;
                RefreshData();
                break;

            case MotionEventActions.Down:
            case MotionEventActions.Pointer1Down:
            case MotionEventActions.Pointer2Down:
            case MotionEventActions.Pointer3Down:
                if (touchPoints.Count >= 2)
                {
                    (_previousCenter, _previousRadius, _previousAngle) = GetPinchValues(touchPoints);
                    _mode          = TouchMode.Zooming;
                    _innerRotation = Viewport.Rotation;
                }
                else
                {
                    _mode           = TouchMode.Dragging;
                    _previousCenter = touchPoints.First();
                }
                break;

            case MotionEventActions.Pointer1Up:
            case MotionEventActions.Pointer2Up:
            case MotionEventActions.Pointer3Up:
                // Remove the touchPoint that was released from the locations to reset the
                // starting points of the move and rotation
                touchPoints.RemoveAt(args.Event.ActionIndex);

                if (touchPoints.Count >= 2)
                {
                    (_previousCenter, _previousRadius, _previousAngle) = GetPinchValues(touchPoints);
                    _mode          = TouchMode.Zooming;
                    _innerRotation = Viewport.Rotation;
                }
                else
                {
                    _mode           = TouchMode.Dragging;
                    _previousCenter = touchPoints.First();
                }
                break;

            case MotionEventActions.Move:
                switch (_mode)
                {
                case TouchMode.Dragging:
                {
                    if (touchPoints.Count != 1)
                    {
                        return;
                    }

                    var touchPosition = touchPoints.First();
                    if (_previousCenter != null && !_previousCenter.IsEmpty())
                    {
                        _viewport.Transform(touchPosition.X, touchPosition.Y, _previousCenter.X, _previousCenter.Y);

                        ViewportLimiter.LimitExtent(_viewport, _map.Limits.PanMode, _map.Limits.PanLimits, _map.Envelope);

                        RefreshGraphics();
                    }
                    _previousCenter = touchPosition;
                }
                break;

                case TouchMode.Zooming:
                {
                    if (touchPoints.Count < 2)
                    {
                        return;
                    }

                    var(prevCenter, prevRadius, prevAngle) = (_previousCenter, _previousRadius, _previousAngle);
                    var(center, radius, angle)             = GetPinchValues(touchPoints);

                    double rotationDelta = 0;

                    if (!RotationLock)
                    {
                        _innerRotation += angle - prevAngle;
                        _innerRotation %= 360;

                        if (_innerRotation > 180)
                        {
                            _innerRotation -= 360;
                        }
                        else if (_innerRotation < -180)
                        {
                            _innerRotation += 360;
                        }

                        if (Viewport.Rotation == 0 && Math.Abs(_innerRotation) >= Math.Abs(UnSnapRotationDegrees))
                        {
                            rotationDelta = _innerRotation;
                        }
                        else if (Viewport.Rotation != 0)
                        {
                            if (Math.Abs(_innerRotation) <= Math.Abs(ReSnapRotationDegrees))
                            {
                                rotationDelta = -Viewport.Rotation;
                            }
                            else
                            {
                                rotationDelta = _innerRotation - Viewport.Rotation;
                            }
                        }
                    }

                    _viewport.Transform(center.X, center.Y, prevCenter.X, prevCenter.Y, radius / prevRadius, rotationDelta);

                    (_previousCenter, _previousRadius, _previousAngle) = (center, radius, angle);

                    ViewportLimiter.Limit(_viewport,
                                          _map.Limits.ZoomMode, _map.Limits.ZoomLimits, _map.Resolutions,
                                          _map.Limits.PanMode, _map.Limits.PanLimits, _map.Envelope);

                    RefreshGraphics();
                }
                break;
                }
                break;
            }
        }
Exemplo n.º 29
0
        void ProcessCursor(TouchActionEventArgs args)
        {
            if (!Cursors.ContainsKey(args.ID))
            {
                Cursors.Add(args.ID, new TouchCursor(args.Location));
                if (Cursors.Count >= 2)
                {
                    Mode = TouchMode.Pinch;
                }
            }
            else
            {
                var         item1 = Cursors[args.ID];
                TouchCursor item2 = item1;
                foreach (var cursor in Cursors)
                {
                    if (cursor.Key != args.ID)
                    {
                        item2 = cursor.Value;
                    }
                }

                var dx = args.Location.Position.X - item1.Position.X;
                var dy = args.Location.Position.Y - item1.Position.Y;

                item1.Position = args.Location.Position;
                switch (Cursors.Count)
                {
                case 0:
                    Mode = TouchMode.Normal;
                    break;

                case 1:
                {
                    var temp = new TouchPanActionEventArgs(dx, dy);
                    var dist = temp.Distance;
                    if (dist > 0)
                    {
                        if (Mode == TouchMode.Pan || temp.Distance > GestureThreshold)
                        {
                            TapCancel();
                            Debug.WriteLine("Pan Enabled");
                            Mode = TouchMode.Pan;
                            Pan?.Invoke(this, temp);
                        }
                    }
                }   break;

                case 2:
                {
                    var temp = new TouchPinchActionEventArgs(PinchProcessor);
                    if (temp.Pinch.DistanceDelta >= 0)
                    {
                        Mode = TouchMode.Pinch;
                        if (PinchProcessor.Set(item1.Position, item2.Position))
                        {
                            TapCancel();
                            Pinch?.Invoke(this, temp);
                        }
                    }
                }   break;

                default:
                    Debug.WriteLine("To many cursors.");
                    break;
                }
            }
        }
Exemplo n.º 30
0
        private void BeginMulti()
        {
            Mode = TouchMode.PanZoomRotate;

            if (BeginCapture != null)
            {
                BeginCapture(this, EventArgs.Empty);
            }

            _multiOneStart = GetTouchPosition(_primaryDeviceId);
            _multiTwoStart = GetTouchPosition(_secondaryDeviceId);
        }
Exemplo n.º 31
0
        private void EndCurrentAction()
        {
            switch (Mode)
            {
                case TouchMode.Pan:
                    EndPan();
                    break;
                case TouchMode.PanZoomRotate:
                    EndMulti();
                    break;
            }

            Mode = TouchMode.None;
        }
Exemplo n.º 32
0
        private void BeginPan()
        {
            Mode = TouchMode.Pan;

            if (BeginCapture != null)
            {
                BeginCapture(this, EventArgs.Empty);
            }

            _panStart = GetTouchPosition(_primaryDeviceId);
        }
Exemplo n.º 33
0
		/// <summary>
		/// Set the connected sensor's mode
		/// </summary>
		/// <param name="mode">The requested mode.</param>
		public void SetMode(TouchMode mode)
		{
			Mode = (byte)mode;
		}
Exemplo n.º 34
0
    void OnPostSolve(FluvioTimeStep timeStep)
    {
        if (sleep)
        {
            sleep = false;
            return;
        }

        fluid.GetParticles(ref particles);

#if !(UNITY_IPHONE || UNITY_ANDROID) || UNITY_EDITOR
        bool doTouch = !requireClick ? true : (Input.GetMouseButton(0) || Input.GetMouseButton(1));
        if (doTouch)
        {
            if (Input.GetMouseButton(0) || !requireClick)
            {
                touchMode = invert ? TouchMode.Push : TouchMode.Pull;
            }
            else
            {
                touchMode = invert ? TouchMode.Pull : TouchMode.Push;
            }
            Vector3 point = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, z));
            float   f     = (int)touchMode * force;
            for (int i = 0; i < particles.Length; i++)
            {
                FluidParticle p = particles[i];

                if (!p.enabled)
                {
                    continue;
                }

                float dist = (p.position - point).sqrMagnitude;
                if (dist <= maxDistance * maxDistance)
                {
                    p.AddForce((point - p.position).normalized * f);
                }

                particles[i] = p;
            }
        }
#else
        foreach (Touch t in Input.touches)
        {
            Vector3 point = Camera.main.ScreenToWorldPoint(new Vector3(t.position.x, t.position.y, z));
            float   f     = force * (int)touchMode / (Input.touchCount * .5f);
            for (int i = 0; i < particles.Length; i++)
            {
                FluidParticle p = particles[i];

                if (!p.enabled)
                {
                    continue;
                }

                float dist = (p.position - point).sqrMagnitude;
                if (dist <= maxDistance * maxDistance)
                {
                    p.AddForce((point - p.position).normalized * f);
                }

                particles[i] = p;
            }
        }
#endif
        fluid.SetParticles(particles, particles.Length);
    }
Exemplo n.º 35
0
    void OnPostSolve(FluvioTimeStep timeStep)
    {
        if (sleep)
        {
            sleep = false;
            return;
        }

        fluid.GetParticles(ref particles);

        #if !(UNITY_IPHONE || UNITY_ANDROID) || UNITY_EDITOR
        bool doTouch = !requireClick ? true : (Input.GetMouseButton(0) || Input.GetMouseButton(1));
        if (doTouch)
        {
            if (Input.GetMouseButton(0) || !requireClick)
            {
                touchMode = invert ? TouchMode.Push : TouchMode.Pull;
            }
            else
            {
                touchMode = invert ? TouchMode.Pull : TouchMode.Push;
            }
            Vector3 point = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, z));
            float f = (int)touchMode * force;
            for(int i = 0; i < particles.Length; i++)
            {
                FluidParticle p = particles[i];

                if (!p.enabled)
                    continue;

                float dist = (p.position - point).sqrMagnitude;
                if (dist <= maxDistance *  maxDistance)
                {
                    p.AddForce((point - p.position).normalized * f);
                }

                particles[i] = p;
            }
        }
        #else
        foreach(Touch t in Input.touches)
        {
            Vector3 point = Camera.main.ScreenToWorldPoint(new Vector3(t.position.x, t.position.y, z));
            float f = force * (int)touchMode / (Input.touchCount * .5f);
            for(int i = 0; i < particles.Length; i++)
            {
                FluidParticle p = particles[i];

                if (!p.enabled)
                    continue;

                float dist = (p.position - point).sqrMagnitude;
                if (dist <=  maxDistance * maxDistance)
                {
                    p.AddForce((point - p.position).normalized * f);
                }

                particles[i] = p;
            }
        }
        #endif
        fluid.SetParticles(particles, particles.Length);
    }
Exemplo n.º 36
0
 /// <summary>
 /// Set the connected sensor's mode
 /// </summary>
 /// <param name="mode">The requested mode.</param>
 public void SetMode(TouchMode mode)
 {
     Mode = (byte)mode;
 }
Exemplo n.º 37
0
    // Update is called once per frame
    void Update()
    {
        if (Input.touchCount > 0)
        {
            Touch touch = Input.GetTouch(0);

            Vector2 touchPosition = mainCamera.ScreenToWorldPoint(touch.position);
            switch (touch.phase)
            {
            case TouchPhase.Began:
                Debug.Log(Vector2.Distance(touch.position, joystickOutline.transform.position));
                Debug.Log(JoystickSize);
                if (Vector2.Distance(touchPosition, slave.transform.position) <= itemDetectionDistance)
                {
                    touchRatioPos = slave.transform.position - (Vector3)touchPosition;
                    mode          = TouchMode.Drag;
                }
                else
                {
                    mode             = TouchMode.Joystick;
                    joystickPosition = touch.position;
                    virtualJoystick.transform.position = joystickPosition;
                    virtualJoystick.SetActive(true);
                }
                break;

            case TouchPhase.Moved:
                if (mode == TouchMode.Drag)
                {
                    slave.transform.position = (Vector3)touchPosition + touchRatioPos;
                }
                else if (mode == TouchMode.Joystick)
                {
                    joystickVector = touch.position - joystickPosition;
                    if (joystickVector.magnitude <= 20)
                    {
                        joystickVector = Vector2.zero;
                    }
                    if (joystickVector.magnitude >= JoystickSize / 2)
                    {
                        joystickVector = joystickVector.normalized * JoystickSize / 2;
                    }
                    knob.transform.position = joystickPosition + joystickVector;
                }

                MoveObject(joystickVector);



                break;

            case TouchPhase.Stationary:
                MoveObject(joystickVector);
                break;

            case TouchPhase.Ended:
                mode = TouchMode.None;
                ResetJoystick();
                break;

            case TouchPhase.Canceled:
                mode = TouchMode.None;
                ResetJoystick();
                break;
            }
        }
    }