コード例 #1
0
    /**
     * Delete the subspace or no , depends the parameter answer
     **/
    public void Delete(bool answer)
    {
        if (!answer && m_currentDialog)
        {
            DisableToDelete();
            m_deletedCanceled++;
            return;
        }

        if (m_otherHand.m_ContactInteractables.Contains(dataToDelete))
        {
            m_otherHand.OnTriggerExit(dataToDelete.GetComponent <Collider>());
        }

        m_ContactInteractables.Remove(dataToDelete);
        m_CurrentTakedSubspace = null;
        Destroy(dataToDelete.gameObject);
        Destroy(m_currentDialog);
        if (m_currentIndexSelected > m_ContactInteractables.Count - 1)
        {
            m_currentIndexSelected = m_ContactInteractables.Count - 1;
        }
        DetectTypeHand();
        m_myHand.ShowHand();
        if (!m_custonStatusFingerOtherHand)
        {
            m_otherHand.GetComponent <Hand>().DesactivateFingerHand();
        }
        m_otherHand.GetComponent <Hand>().modeAnswer = false;
        m_deletedAcepted++;
    }
コード例 #2
0
    public void Drop()
    {
        if (m_TypeHand == Constants.HAND_PRIMARY_USE)
        {
            m_isPressedPrimaryPickup = false;
        }
        if (m_TypeHand == Constants.HAND_SECONDARY_USE)
        {
            m_isPressedSecundaryPickup = false;
        }

        if (m_TypeHand == Constants.HAND_NONE_USE)
        {
            m_isPressedPrimaryPickup   = false;
            m_isPressedSecundaryPickup = false;
        }

        if (m_currentIndexSelected < 0)
        {
            return;
        }

        if (!m_CurrentTakedSubspace)
        {
            return;
        }
        if (m_TypeHand == Constants.HAND_PRIMARY_USE)
        {
            if (m_CurrentTakedSubspace.m_PrimaryHand && !m_CurrentTakedSubspace.m_SecondaryHand)
            {
                Rigidbody targetBody = m_CurrentTakedSubspace.GetComponent <Rigidbody>();
                targetBody.velocity                  = Vector3.zero;
                targetBody.angularVelocity           = Vector3.zero;
                m_Joint.connectedBody                = null;
                m_CurrentTakedSubspace.m_PrimaryHand = null;
                m_CurrentTakedSubspace               = null;
            }
            else if (m_CurrentTakedSubspace.m_PrimaryHand && m_CurrentTakedSubspace.m_SecondaryHand)
            {
                m_CurrentTakedSubspace.ResetDistanceInitialForScale();
                m_CurrentTakedSubspace.m_PrimaryHand   = m_CurrentTakedSubspace.m_SecondaryHand;
                m_CurrentTakedSubspace.m_SecondaryHand = null;
                m_CurrentTakedSubspace = null;
                m_otherHand.m_isPressedPrimaryPickup   = true;
                m_otherHand.m_isPressedSecundaryPickup = false;
                m_otherHand.DetectTypeHand();
                m_otherHand.JoiningSubspace();
            }
        }

        else if (m_TypeHand == Constants.HAND_SECONDARY_USE)
        {
            m_CurrentTakedSubspace.ResetDistanceInitialForScale();
            m_CurrentTakedSubspace.m_SecondaryHand = null;
            m_CurrentTakedSubspace = null;
            JoiningSubspace();
        }
        DetectTypeHand();
    }
コード例 #3
0
    private void StopScaleBothHands(Subspace subspace)
    {
        subspace.ResetDistanceInitialForScale();
        subspace.m_PrimaryHand     = null;
        subspace.m_SecondaryHand   = null;
        m_CurrentTakedSubspace     = null;
        m_isPressedPrimaryPickup   = false;
        m_isPressedSecundaryPickup = false;
        Rigidbody targetBody = subspace.GetComponent <Rigidbody>();

        targetBody.velocity        = Vector3.zero;
        targetBody.angularVelocity = Vector3.zero;
        m_Joint.connectedBody      = null;
        m_otherHand.DetectTypeHand();
    }
コード例 #4
0
    public void Pickup()
    {
        if (m_TypeHand == Constants.HAND_PRIMARY_USE)
        {
            m_isPressedPrimaryPickup = true;
        }
        if (m_TypeHand == Constants.HAND_SECONDARY_USE)
        {
            m_isPressedSecundaryPickup = true;
        }
        if (m_TypeHand == Constants.HAND_NONE_USE)
        {
            m_isPressedPrimaryPickup   = false;
            m_isPressedSecundaryPickup = false;
        }

        if (m_CurrentTakedSubspace || m_currentIndexSelected < 0)
        {
            return;
        }
        m_CurrentTakedSubspace = m_ContactInteractables[m_currentIndexSelected];
        if (!m_CurrentTakedSubspace)
        {
            return;
        }
        DetectTypeHand();
        if (m_TypeHand == Constants.HAND_PRIMARY_USE)
        {
            Rigidbody targetBody = m_CurrentTakedSubspace.GetComponent <Rigidbody>();
            m_Joint.connectedBody = targetBody;
            m_CurrentTakedSubspace.m_PrimaryHand   = this;
            m_CurrentTakedSubspace.m_SecondaryHand = null;
            m_selectSubspaces++;
            if (m_consoleLeft)
            {
                m_consoleLeft.AddText("m_selectSubspaces: " + m_selectSubspaces);
            }
        }
        if (m_TypeHand == Constants.HAND_SECONDARY_USE)
        {
            m_CurrentTakedSubspace.m_SecondaryHand = this;
            StopJoiningSubspace();
            m_CurrentTakedSubspace.m_distanceInitialForScale = Vector3.Distance(m_CurrentTakedSubspace.m_PrimaryHand.transform.position, transform.position);
            m_CurrentTakedSubspace.m_modeScale = true;
        }
        DetectTypeHand();
    }
コード例 #5
0
 /**
  * Prepare to Subspace to Delete coloring and displying confirmation dialog
  **/
 private void EnableToDelete()
 {
     if (m_currentIndexSelected < 0 && !m_ContactInteractables[m_currentIndexSelected])
     {
         return;
     }
     if (m_ContactInteractables[m_currentIndexSelected].isOriginal)
     {
         return;
     }
     dataToDelete = m_ContactInteractables[m_currentIndexSelected];
     dataToDelete.m_modePrepareToDelete = true;
     dataToDelete.GetComponent <Renderer>().material.color = Constants.SPACE_COLOR_PREPARE_TO_DELETE;
     m_myHand.HideHand();
     m_currentDialog = Instantiate(dialogCommon);
     m_currentDialog.transform.SetParent(transform);
     m_custonStatusFingerOtherHand = m_otherHand.GetComponent <Hand>().getStatusFingerHand();
     m_otherHand.GetComponent <Hand>().ActivateFingerHand();
     m_otherHand.GetComponent <Hand>().modeAnswer = true;
 }
コード例 #6
0
    /**
     * void OnGUI()
     * {
     *  //Press this button to lock the Cursor
     *  if (GUI.Button(new Rect(0, 0, 100, 50), "Lock Cursor"))
     *  {
     *      Cursor.lockState = CursorLockMode.Locked;
     *  }
     *
     *  //Press this button to confine the Cursor within the screen
     *  if (GUI.Button(new Rect(125, 0, 100, 50), "Confine Cursor"))
     *  {
     *      Cursor.lockState = CursorLockMode.Confined;
     *  }
     * }
     **/
    void Update()
    {
        if (!isReady && Input.GetMouseButtonUp(0))
        {
            Cursor.lockState = CursorLockMode.Confined;
            Cursor.lockState = CursorLockMode.Locked;

            isReady = true;
            GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CamMouseLook>().mouselooked = false;
        }

        if (!isReady)
        {
            return;
        }

        m_totalTime += Time.deltaTime;
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        RaycastHit[] f = Physics.RaycastAll(ray, Mathf.Infinity);

        if (Input.GetKeyDown(KeyCode.Return))
        {
            GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CamMouseLook>().mouselooked = true;
            Cursor.lockState = CursorLockMode.None;
            dialogConfirmationF.SetActive(true);
            return;
        }

        if (Input.GetMouseButtonDown(1))
        {
            Collider collision = GetNearestCollider(f, LayerMask.NameToLayer("Subspace"));

            if (collision)
            {
                subspaceNearest = collision.GetComponent <Subspace>();
                GetComponent <MovementFPS>().stopMovement = true;
                CreatePivot();
                subspaceNearest.GetComponent <Renderer>().material.color = Constants.SPACE_COLOR_WITH_CONTROLLER;
                //subspaceNearest.GetComponent<Subspace>().m_letRotate = false;
                subspaceNearest.GetComponent <Subspace>().m_letRotate = true;
                cachedPosition = transform.position;
                m_dragging     = true;
                GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CamMouseLook>().mouselooked = true;
                m_selectSubspaces++;
                Cursor.lockState = CursorLockMode.None;
            }
            return;
        }

        if (Input.GetMouseButtonUp(1) && !m_modeDelete)
        {
            GetComponent <MovementFPS>().stopMovement = false;
            if (subspaceNearest)
            {
                subspaceNearest.GetComponent <Renderer>().material.color = Constants.SPACE_COLOR_WITHOUT_CONTROLLER;
                subspaceNearest.GetComponent <Subspace>().m_letRotate    = false;
            }
            cachedPosition = Vector3.zero;
            m_dragging     = false;
            DeletePivot();
            GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CamMouseLook>().mouselooked = false;
            Cursor.lockState = CursorLockMode.Locked;
            return;
        }

        if (subspaceNearest && Input.GetMouseButton(1))//macro
        {
            m_pickupTime += Time.deltaTime;

            /**if (Input.GetMouseButtonDown(0))
             * {
             *  m_dragging = true;
             *  DeletePivot();
             *  CreatePivot();
             *  subspaceNearest.GetComponent<Subspace>().m_letRotate = true;
             *  return;
             * }
             * if (m_dragging && (Input.GetMouseButtonUp(1)))
             * {
             *  GameObject.FindGameObjectWithTag("MainCamera").GetComponent<CamMouseLook>().mouselooked = false;
             *  m_dragging = false;
             *  DeletePivot();
             *  subspaceNearest.GetComponent<Subspace>().m_letRotate = false;
             *  return;
             * }**/


            if (m_dragging)
            {
                float rotX = Input.GetAxis("Mouse X") * rotationSpeed;
                float rotY = Input.GetAxis("Mouse Y") * rotationSpeed;

                subspaceNearest.transform.parent.Rotate(Vector3.up, -rotX);
                subspaceNearest.transform.parent.Rotate(Vector3.right, rotY);

                m_rotationTime += Time.deltaTime;
                if (subspaceNearest.m_letRotate && subspaceNearest.subspacesChild.Count > 0)
                {
                    m_navSlaving += Time.deltaTime;
                }

                //print("m_rotationTime " + m_rotationTime);
                //print("m_navSlaving " + m_navSlaving);
            }

            if (Input.GetAxisRaw("Vertical") != 0 || Input.GetAxisRaw("Horizontal") != 0 ||
                Input.GetKey(KeyCode.E) || Input.GetKey(KeyCode.Q))
            {
                if (m_isAxisInUse == false)
                {
                    cachedPosition = transform.position;
                    float translation = Input.GetAxis("Vertical") * 10f;
                    float straffe     = Input.GetAxis("Horizontal") * 10f;
                    float high        = 0f;
                    if (Input.GetKey(KeyCode.E))
                    {
                        high = 0.005f;
                    }
                    if (Input.GetKey(KeyCode.Q))
                    {
                        high = -0.005f;
                    }
                    translation *= Time.deltaTime;
                    straffe     *= Time.deltaTime;
                    DeletePivot();
                    CreatePivot();
                    Vector3 newPos = subspacePivot.transform.position + subspacePivot.transform.TransformDirection(straffe, high, translation);
                    if (newPos.x < 2.7f && newPos.x > -1.7f &&
                        newPos.z < 1.9f && newPos.z > -1.74f &&
                        newPos.y < 4f && newPos.y > 1f)
                    {
                        subspacePivot.transform.Translate(straffe, high, translation);
                    }
                    m_traslationTime += Time.deltaTime;
                    //print("m_traslationTime " + m_traslationTime);
                    m_isAxisInUse = true;
                }

                if (Input.GetAxisRaw("Vertical") == 0 || Input.GetAxisRaw("Horizontal") == 0)
                {
                    m_isAxisInUse = false;
                }
            }

            if (Input.GetAxis("Mouse ScrollWheel") != 0f) // forward
            {
                subspaceNearest.ChangeScaleScroll(Input.GetAxis("Mouse ScrollWheel"));
                m_scaleTime += Time.deltaTime;
                print("m_scaleTime " + m_scaleTime);
            }

            if (Input.GetKeyDown(KeyCode.Space))
            {
                Clone(subspaceNearest);
                m_clones++;
            }

            if (Input.GetKeyDown(KeyCode.Delete) && !subspaceNearest.isOriginal)
            {
                GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CamMouseLook>().mouselooked = true;
                Cursor.lockState = CursorLockMode.None;
                m_modeDelete     = true;
                subspaceNearest.GetComponent <Renderer>().material.color = Constants.SPACE_COLOR_PREPARE_TO_DELETE;
                dialogConfirmation.SetActive(true);
            }
        }

        bool     existData   = false;
        Collider dataNearest = GetNearestCollider(f, LayerMask.NameToLayer("Data"));

        if (dataNearest)
        {
            existData = true;
            if (currentHit != dataNearest.gameObject.GetInstanceID())
            {
                Destroy(highlightHolder);
                currentHit = dataNearest.gameObject.GetInstanceID();
                Interactable interactable = dataNearest.gameObject.GetComponent <Interactable>();
                CreateHighlightRenderers(interactable);
                if (text1)
                {
                    text1.text = dataNearest.GetComponent <Data>().Name_1;
                }
                if (text2)
                {
                    text2.text = dataNearest.GetComponent <Data>().Name_2;
                }
                if (text3)
                {
                    text3.text = dataNearest.GetComponent <Data>().Name_3;
                }
                if (text4)
                {
                    text4.text = dataNearest.GetComponent <Data>().Name_4;
                }
            }
        }

        if (!existData)
        {
            currentHit = 0;
            Destroy(highlightHolder);
            CleanTextCanvas();
        }
        UpdateHighlightRenderers(false);

        if (m_modeDelete)
        {
            return;
        }

        if (!m_dragging && existData && Input.GetMouseButtonUp(0) && m_interaction)// micro
        {
            m_interaction.FilterData(dataNearest.GetComponent <Data>());
            return;
        }
    }