Ejemplo n.º 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;
                    }
                }
            }
        }
Ejemplo n.º 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);
            }
        }
        protected virtual void OnEnable()
        {
            P3dInputManager.EnsureThisComponentExists();

            P3dInputManager.OnFingerDown += HandleFingerDown;
            P3dInputManager.OnFingerUp   += HandleFingerUp;
        }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
0
        protected virtual void OnEnable()
        {
            P3dInputManager.EnsureThisComponentExists();

            P3dInputManager.OnFingerDown += HandleFingerDown;

            foreach (var finger in P3dInputManager.Fingers)
            {
                HandleFingerDown(finger);
            }
        }
Ejemplo n.º 6
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);
            }
        }
		private bool Pressing()
		{
			var fingers = P3dInputManager.GetFingers();

			for (var i = 0; i < fingers.Count; i++)
			{
				var finger = fingers[i];

				if (finger.Index >= 0 || finger.Index == -1) // Touch or left click
				{
					return true;
				}
			}

			return false;
		}
Ejemplo n.º 8
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);
        }
        protected virtual void LateUpdate()
        {
            if (target != null)
            {
                if (P3dInputManager.IsPressed(key) == true)
                {
                    if (storeStates == true && target.isPlaying == false)
                    {
                        P3dStateManager.StoreAllStates();
                    }

                    target.Play();
                }
                else
                {
                    target.Stop();
                }
            }
        }
        protected virtual void Update()
        {
            if (target != null)
            {
                if (P3dInputManager.IsPressed(key) == true)
                {
                    if (storeStates == true && target.enabled == false)
                    {
                        P3dStateManager.StoreAllStates();
                    }

                    target.enabled = true;
                }
                else
                {
                    target.enabled = false;
                }
            }
        }
        protected virtual void Update()
        {
            // Calculate delta
            if (CanRotate == true && Application.isPlaying == true)
            {
                var delta = P3dInputManager.GetAverageDeltaScaled(fingers);

                pitch -= delta.y * pitchSensitivity;
                yaw   += delta.x * yawSensitivity;
            }

            pitch = Mathf.Clamp(pitch, pitchMin, pitchMax);

            // Smoothly dampen values
            var factor = P3dHelper.DampenFactor(dampening, Time.deltaTime);

            currentPitch = Mathf.Lerp(currentPitch, pitch, factor);
            currentYaw   = Mathf.Lerp(currentYaw, yaw, factor);

            // Apply new rotation
            transform.localRotation = Quaternion.Euler(currentPitch, currentYaw, 0.0f);
        }
Ejemplo n.º 12
0
        protected virtual void Update()
        {
            // Calculate delta
            if (isolate == null || isolate.Isolated == false || Input.GetMouseButton(1) == true)
            {
                var fingers = P3dInputManager.GetFingers(true);
                var delta   = P3dInputManager.GetScaledDelta(fingers);

                pitch -= delta.y * pitchSensitivity;
                yaw   += delta.x * yawSensitivity;
            }

            pitch = Mathf.Clamp(pitch, pitchMin, pitchMax);

            // Smoothly dampen values
            var factor = P3dHelper.DampenFactor(dampening, Time.deltaTime);

            currentPitch = Mathf.Lerp(currentPitch, pitch, factor);
            currentYaw   = Mathf.Lerp(currentYaw, yaw, factor);

            // Apply new rotation
            transform.localRotation = Quaternion.Euler(currentPitch, currentYaw, 0.0f);
        }
Ejemplo n.º 13
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);
                }
            }
        }
Ejemplo n.º 14
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();
            //}
        }
Ejemplo n.º 15
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);
                }
            }
        }