Example #1
0
 public void DeleteSelections()
 {
     foreach (Transform t in _CombinableSelections)
     {
         //_selections.Remove(t);
         _selectionResponse.OnDeselect(t);
         //Destroy(t.gameObject);
     }
     _CombinableSelections = new List <Transform>();
 }
    // Update is called once per frame
    void Update()
    {
        //deselection  response
        if (_currentSelection != null)
        {
            _selectionResponse.OnDeselect(_currentSelection);
        }


        _selector.Check(_rayProvider.CreateRay());

        _currentSelection = _selector.GetSelection();;

        //selection response
        if (_currentSelection != null)
        {
            //if object has prerequisite and is not complete, do nothing
            if (_currentSelection.GetComponent <Prerequisite>() && !_currentSelection.GetComponent <Prerequisite>().Complete)
            {
                return;
            }


            _selectionResponse.OnSelect(_currentSelection);
        }
    }
    // Update is called once per frame
    private void Update()
    {
        // selection and deselection response
        if (_selection != null)
        {
            _selectionResponse.OnDeselect(_selection);
        }

        #region MyRegion
        //creates the ray
        var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        //selection determination
        _selection = null;
        if (Physics.Raycast(ray, out var hit))
        {
            var selection = hit.transform;
            if (selection.CompareTag(selectableTag) || selection.CompareTag(otherTag))
            {
                _selection = selection;
            }
        }
        #endregion

        // selection and deselection response
        if (_selection != null)
        {
            _selectionResponse.OnSelect(_selection);
        }
    }
Example #4
0
    // Update is called once per frame
    void Update()
    {
        //Deselection Response
        if (_selectionResponse != null)
        {
            _selectionResponse.OnDeselect();
        }

        #region Selection Determination

        //Cast ray
        var        ray = _camera.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        //Selection determination
        _selectionResponse = null;
        if (Physics.Raycast(ray, out hit))
        {
            var selection = hit.transform;
            if (selection.CompareTag(selectableTag))
            {
                _selectionResponse = selection.GetComponent <ISelectionResponse>();
            }
        }

        #endregion

        //Selection Response
        if (_selectionResponse != null)
        {
            _selectionResponse.OnSelect();
        }
    }
    private void Update()
    {
        if (_currentselection != null)
            _selectionResponse.OnDeselect(_currentselection);

        _selector.Check(_rayProvider.CreateRay());
        _currentselection = _selector.GetSelection();

        if (_currentselection != null)
            _selectionResponse.OnSelect(_currentselection);
    }
Example #6
0
    void LateUpdate()
    {
        if (_currentSelection != null)
        {
            _selectionResponse.OnDeselect(_currentSelection);
        }

        _selector.Check(_rayProvider.CreateRay());
        _currentSelection = _selector.GetSelection();

        if (_currentSelection != null)
        {
            _selectionResponse.OnHover(_currentSelection);
        }
    }
        // Update is called once per frame
        private void Update()
        {
            if (currectSelection != null)
            {
                selectionResponse.OnDeselect(currectSelection);
            }

            selector.Check(rayProvider.CreateRay());
            currectSelection = selector.GetSelection();

            if (currectSelection != null)
            {
                selectionResponse.OnSelect(currectSelection);
            }
        }
    private void Update()
    {
        //selection
        if (_currentSelection != null)
        {
            _selectionResponse.OnDeselect(_currentSelection);
        }

        //determineSeelection
        _selector.Check(_rayProvider.CreateRay());
        _currentSelection = _selector.GetSelection();

        //selection
        if (_currentSelection != null)
        {
            _selectionResponse.OnSelect(_currentSelection);
        }
    }
Example #9
0
    void Update()
    {
        if (_currentSelection != null)
        {
            _selectionResponse.OnDeselect(_currentSelection);
        }

        var        ray = _rayProvider.CreateRay();
        RaycastHit hit;

        _selector.Check(ray);

        _currentSelection = _selector.GetSelection();
        if (_currentSelection != null)
        {
            _selectionResponse.OnSelect(_currentSelection);
        }
    }
    private void Update()
    {
        #region Raycast & Select
        _selector.Check(_rayProvider.CreateRay());
        var selection = _selector.GetSelection();
        #endregion
        if (IsNewSelection(selection))
        {
            if (_currentSelection != null)
            {
                _selectionResponse.OnDeselect(_currentSelection);
            }
            if (selection != null)
            {
                _selectionResponse.OnSelect(selection);
            }
        }

        _currentSelection = selection;
    }
        // Update is called once per frame
        void Update()
        {
            selectionResponse.OnDeselect(transform);

            // get new selection
            var        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hitInfo;

            if (Physics.Raycast(ray, out hitInfo))
            {
                var currentSelection = hitInfo.transform;
                if (currentSelection.CompareTag(selectableTag))
                {
                    selection     = currentSelection;
                    originalColor = selection.GetComponent <Renderer>().material.color;
                }
            }

            // set color of new selection
            selectionResponse.OnSelect(transform);
        }
Example #12
0
    private void Update()
    {
        if (_currentSelection != null)
        {
            _selectionResponse.OnDeselect(_currentSelection);
            _hoverResponse.OnDeselect(_currentSelection);
        }

        _selector.Check(_rayProvider.CreateRay());
        _currentSelection = _selector.GetSelection();

        if (_currentSelection != null)
        {
            _selectionResponse.OnSelect(_currentSelection);
            if (_currentSelection.CompareTag("Selectable"))
            {
                if (pointer != null)
                {
                    pointer.GetComponent <Image>().enabled = true;

                    //When click, execute the action on IClickResponse
                    if (Input.GetKeyDown(action))
                    {
                        _clickResponse.OnClick(_currentSelection);
                    }
                }
            }
            else if (_currentSelection.CompareTag("Hoverable"))
            {
                _hoverResponse.OnSelect(_currentSelection);
            }
        }
        else
        {
            if (pointer != null)
            {
                pointer.GetComponent <Image>().enabled = false;
            }
        }
    }
Example #13
0
    // Update object selection each frame
    private void Update()
    {
        //  deselection/selection response
        // first checking whether selection field is null
        if (_selection != null)
        {
            //var selection = _selection;
            _selectionResponse.OnDeselect(_selection);
            //Debug.Log("selected");
        }

        #region MyRegion
        // Creating a ray. variable that represents ray cast in the game. Mouse position is the input.
        var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        //RaycastHit hit;

        // Selection determination: check if the  ray is colliding with an object
        _selection = null;
        if (Physics.Raycast(ray, out var hit))
        {
            // if object is hit is True
            var selection = hit.transform;
            if (selection.CompareTag(selectableTag))
            {
                _selection = selection;
            }
        }
        #endregion

        // deselection/selection response
        if (_selection != null)
        {
            //var selection = _selection;
            _selectionResponse.OnSelect(_selection);
        }
    }
Example #14
0
 public void Deselect()
 {
     selectionResponse?.OnDeselect();
 }