예제 #1
0
        protected virtual void Update()
        {
            if (prefab != null && Input.GetMouseButtonDown(0) == true && P3dInputManager.PointOverGui(Input.mousePosition) == false)
            {
                var camera = P3dHelper.GetCamera();

                if (camera != null)
                {
                    if (storeStates == true)
                    {
                        P3dStateManager.StoreAllStates();
                    }

                    // Find the ray for this screen position
                    var ray      = camera.ScreenPointToRay(Input.mousePosition);
                    var rotation = Quaternion.LookRotation(ray.direction);

                    // Loop through all prefabs and spawn them
                    var clone = Instantiate(prefab, ray.origin, rotation);

                    // Throw with velocity?
                    var cloneRigidbody = clone.GetComponent <Rigidbody>();

                    if (cloneRigidbody != null)
                    {
                        cloneRigidbody.velocity = clone.transform.forward * Speed;
                    }
                }
            }
        }
예제 #2
0
        protected void LateUpdate()
        {
            inputManager.Update(key);

            // Use mouse hover preview?
            if (showPreview == true)
            {
                if (Input.touchCount == 0 && Input.GetKey(key) == false && P3dInputManager.PointOverGui(Input.mousePosition) == false)
                {
                    PaintAt(Input.mousePosition, true, 1.0f, this);
                }
                else
                {
                    BreakHits(this);
                }
            }

            for (var i = inputManager.Fingers.Count - 1; i >= 0; i--)
            {
                var finger = inputManager.Fingers[i];
                var down   = finger.Down;
                var up     = finger.Up;

                Paint(finger, down, up);
            }
        }
예제 #3
0
        protected virtual void LateUpdate()
        {
            if (particles != null)
            {
                var mousePosition = (Vector2)Input.mousePosition;

                if (Input.GetMouseButton(0) == true && P3dInputManager.PointOverGui(mousePosition) == false)
                {
                    if (storeStates == true && particles.isPlaying == false)
                    {
                        P3dStateManager.StoreAllStates();
                    }

                    particles.Play();
                }
                else
                {
                    particles.Stop();
                }
            }

            if (aimSensitivity != 0.0f)
            {
                var sensitivity = AimSensitivity / Screen.width;
                var aimX        = (Input.mousePosition.y - Screen.width * 0.5f) * sensitivity;
                var aimY        = (Input.mousePosition.x - Screen.height * 0.5f) * sensitivity;

                transform.localRotation = Quaternion.Euler(-aimX, aimY, 0.0f);
            }
        }
예제 #4
0
        protected void LateUpdate()
        {
#if USE_LEAN_TOUCH
            var fingers = Use.GetFingers();
#else
            inputManager.Update(key);

            var fingers = inputManager.Fingers;

            if (Input.touchCount <= 0)
            {
                fingers.Clear();
                canPaint = true;
            }

            if (Input.touchCount >= 2)
            {
                canPaint = false;
            }
            fings = fingers;
#endif

            // Use mouse hover preview?
            if (showPreview == true)
            {
                if (P3dInputManager.MouseExists == true && fingers.Count == 0 && P3dInputManager.PointOverGui(P3dInputManager.MousePosition) == false)
                {
                    PaintAt(null, P3dInputManager.MousePosition, true, 1.0f, this);
                }
                else
                {
                    BreakHits(this);
                }
            }

            for (var i = fingers.Count - 1; i >= 0; i--)
            {
                var finger = fingers[i];

#if !USE_LEAN_TOUCH
                if (finger.StartedOverGui == true)
                {
                    continue;
                }
#endif

                Paint(finger, finger.Down, finger.Up);
            }
        }
예제 #5
0
        private void HandleFingerDown(P3dInputManager.Finger finger)
        {
            if (finger.Index != P3dInputManager.HOVER_FINGER_INDEX)
            {
                if (P3dInputManager.PointOverGui(finger.ScreenPosition, guiLayers) == true)
                {
                    return;
                }

                if (key != KeyCode.None && P3dInputManager.IsDown(key) == false)
                {
                    return;
                }
            }

            fingers.Add(finger);
        }
예제 #6
0
        protected virtual void Update()
        {
            if (IsSimulation == true)
            {
                LeftTrigger  = P3dInputManager.IsPressed(simulatedLeftTrigger);
                LeftGrip     = P3dInputManager.IsPressed(simulatedLeftGrip);
                RightTrigger = P3dInputManager.IsPressed(simulatedRightTrigger);
                RightGrip    = P3dInputManager.IsPressed(simulatedRightGrip);

                if (P3dInputManager.PointOverGui(P3dInputManager.MousePosition) == true)
                {
                    LeftTrigger  = false;
                    LeftGrip     = false;
                    RightTrigger = false;
                    RightGrip    = false;
                }
            }

            //if (P3dInputManager.IsPressed(recenterKey) == true)
            //{
            //	Recenter();
            //}
        }
예제 #7
0
        protected void LateUpdate()
        {
            // Use mouse hover preview?
            if (showPreview == true)
            {
                if (Input.touchCount == 0 && P3dInputManager.AnyMouseButtonSet == false && P3dInputManager.PointOverGui(Input.mousePosition) == false)
                {
                    PaintAt(Input.mousePosition, true, 1.0f, this);
                }
            }

            var fingers = P3dInputManager.GetFingers();

            for (var i = fingers.Count - 1; i >= 0; i--)
            {
                var finger = fingers[i];

                if (finger.Index >= 0 || finger.Index == -1)                 // Touch or left click
                {
                    Paint(finger);
                }
            }
        }
예제 #8
0
        protected void LateUpdate()
        {
            inputManager.Update(key);

            // Use mouse hover preview?
            if (showPreview == true)
            {
                if (P3dInputManager.MouseExists == true && inputManager.Fingers.Count == 0 && P3dInputManager.PointOverGui(P3dInputManager.MousePosition) == false)
                {
                    PaintAt(null, P3dInputManager.MousePosition, true, 1.0f, this);
                }
                else
                {
                    BreakHits(this);
                }
            }

            for (var i = inputManager.Fingers.Count - 1; i >= 0; i--)
            {
                var finger = inputManager.Fingers[i];

                if (finger.StartedOverGui == false)
                {
                    Paint(finger, finger.Down, finger.Up);
                }
            }
        }