private void Awake() { _inputHandler = GetComponent <InputHandler>(); _selectionResponse = GetComponent <ISelectionResponse>(); _inputHandler.pressDelegate += ButtonPressed; _camera = GetComponentInChildren <Camera>(); }
// 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 Awake() { _selectionResponse = GetComponent <ISelectionResponse>(); _selector = GetComponent <ISelector>(); _rayProvider = GetComponent <IRayProvider>(); _CombinableSelections = new List <Transform>(); }
private void Awake() { _rayProvider = GetComponent <IRayProvider>(); _selector = GetComponent <ISelector>(); _selectionResponse = GetComponent <ISelectionResponse>(); _clickResponse = GetComponent <IClickResponse>(); _hoverResponse = GetComponent <IHoverResponse>(); }
public void OnSelectionConfirm(GameObject gameObject, Vector3 inputPosition, List <GameObject> wasSelectedGameObjects) { //check if it has its own selection response ISelectionResponse selectionResponse = gameObject.GetComponent <ISelectionResponse>(); if (selectionResponse != null) { selectionResponse.OnSelectionConfirm(gameObject, inputPosition, wasSelectedGameObjects); } else { //use default implementation //no implementation yet } }
public virtual void IsSelectedUnique(GameObject gameObject, Vector3 inputPosition) { //check if it has its own selection response ISelectionResponse selectionResponse = gameObject.GetComponent <ISelectionResponse>(); if (selectionResponse != null) { selectionResponse.IsSelectedUnique(gameObject, inputPosition); } else { //use default implementation //no implementation yet } }
public virtual void OnHoverSelected(GameObject gameObject, Vector3 inputPosition) { //check if it has its own selection response ISelectionResponse selectionResponse = gameObject.GetComponent <ISelectionResponse>(); if (selectionResponse != null) { selectionResponse.OnHoverSelected(gameObject, inputPosition); } else { //use default implementation //just follow is selected method and drag object to touch location //this.IsSelected(gameObject, inputPosition); } }
public virtual void Deselected(GameObject gameObject, Vector3 inputPosition) { //return to original location if (gameObject) { //check if it has its own selection response ISelectionResponse selectionResponse = gameObject.GetComponent <ISelectionResponse>(); if (selectionResponse != null) { selectionResponse.Deselected(gameObject, inputPosition); } else { //use default implementation //no implementation yet } } }
//public virtual GameObject DetermineSelection(Vector3 inputPosition) //{ // //create ray // Ray ray = Camera.main.ScreenPointToRay(inputPosition); // //draw raycast // Debug.DrawLine(ray.origin, ray.direction, Color.red); // RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction); // //check that it hit something // if (!hit) // return null; // return hit.collider.gameObject; //} public virtual void IsSelected(GameObject gameObject, Vector3 inputPosition) { //check it exists if (gameObject) { //check if it has its own selection response ISelectionResponse selectionResponse = gameObject.GetComponent <ISelectionResponse>(); if (selectionResponse != null) { selectionResponse.IsSelected(gameObject, inputPosition); } else { //use default implementation //follow input position //var position = Camera.main.ScreenToWorldPoint(inputPosition); //gameObject.transform.position = new Vector2(position.x, position.y); } } }
private void Awake() { _selectionResponse = GetComponent <ISelectionResponse>(); }
private void Awake() { _selectionResponse = GetComponent <ISelectionResponse>(); _rayProvider = GetComponent <IRayProvider>(); _selector = GetComponent <ISelector>(); }
protected virtual void Awake() { Item = info.GetNewItem(); selectionResponse = GetComponent <ISelectionResponse>(); }
private void Awake() { _selectionResponse = GetComponent <ISelectionResponse>(); _objectSelector = GetComponent <IObjectSelector>(); }