Ejemplo n.º 1
0
        /// This checks whether the Examine button is pressed, and (if so) whether
        /// the cursor has moved significantly since last check. If it has, it will
        /// recalculate what it is looking at.
        private void Update()
        {
            if (!isClient)
            {
                return;
            }

            if (Input.GetButton("Examine"))
            {
                Vector3    mousePosition = Input.mousePosition;
                Vector2    position      = new Vector2(mousePosition.x, mousePosition.y);
                Vector3    cameraPos     = camera.transform.position;
                Quaternion rotation      = camera.transform.rotation;

                if (Vector2.Distance(position, lastMousePosition) > 1 ||
                    Vector3.Distance(cameraPos, lastCameraPosition) > 0.05 ||
                    Quaternion.Angle(rotation, lastCameraRotation) > 0.1)
                {
                    lastMousePosition  = position;
                    lastCameraPosition = cameraPos;
                    lastCameraRotation = rotation;
                    CalculateExamine();
                }
            }
            else if (!float.IsNegativeInfinity(lastMousePosition.x))
            {
                lastMousePosition = Vector2.negativeInfinity;
                if (selector == null)
                {
                    selector = camera.GetComponent <CompositeItemSelector>();
                }
                selector.DisableCamera();
            }
        }
Ejemplo n.º 2
0
        private void Start()
        {
            // Mirror is kinda whack
            if (!hasAuthority)
            {
                Destroy(this);
            }

            camera   = CameraManager.singleton.examineCamera;
            selector = camera.GetComponent <CompositeItemSelector>();

            Assert.IsNotNull(UiPrefab);
            uiInstance = Instantiate(UiPrefab);
            examineUi  = uiInstance.GetComponent <ExamineUI>();
        }
Ejemplo n.º 3
0
        private void Start()
        {
            // Mirror is kinda whack
            if (!hasAuthority)
            {
                Destroy(this);
            }

            // Establish our minimum frequency timer. This is used to ensure
            // that objects moving into our cursor are detected.
            updateFrequency = 1f / MIN_UPDATES_PER_SECOND;
            updateTimer     = 0f;

            camera   = CameraManager.singleton.examineCamera;
            selector = camera.GetComponent <CompositeItemSelector>();

            Assert.IsNotNull(UiPrefab);
            uiInstance = Instantiate(UiPrefab);
            examineUi  = uiInstance.GetComponent <ExamineUI>();
        }
Ejemplo n.º 4
0
        private void Start()
        {
            // Prevent duplicate examinators from being in the scene in multiplayer.
            if (!isLocalPlayer)
            {
                Destroy(this);
                return;
            }

            // Establish our minimum frequency timer. This is used to ensure
            // that objects moving into our cursor are detected.
            updateFrequency = 1f / MIN_UPDATES_PER_SECOND;
            updateTimer     = 0f;

            camera   = CameraManager.singleton.examineCamera;
            selector = camera.GetComponent <CompositeItemSelector>();

            Assert.IsNotNull(UiPrefab);
            uiInstance = Instantiate(UiPrefab);
            examineUi  = uiInstance.GetComponent <ExamineUI>();
        }