Esempio n. 1
0
 private void Awake()
 {
     _inputHandler                = GetComponent <InputHandler>();
     _selectionResponse           = GetComponent <ISelectionResponse>();
     _inputHandler.pressDelegate += ButtonPressed;
     _camera = GetComponentInChildren <Camera>();
 }
Esempio n. 2
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();
        }
    }
Esempio n. 3
0
 private void Awake()
 {
     _selectionResponse    = GetComponent <ISelectionResponse>();
     _selector             = GetComponent <ISelector>();
     _rayProvider          = GetComponent <IRayProvider>();
     _CombinableSelections = new List <Transform>();
 }
Esempio n. 4
0
 private void Awake()
 {
     _rayProvider       = GetComponent <IRayProvider>();
     _selector          = GetComponent <ISelector>();
     _selectionResponse = GetComponent <ISelectionResponse>();
     _clickResponse     = GetComponent <IClickResponse>();
     _hoverResponse     = GetComponent <IHoverResponse>();
 }
Esempio n. 5
0
    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
        }
    }
Esempio n. 6
0
    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
        }
    }
Esempio n. 7
0
    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);
        }
    }
Esempio n. 8
0
 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
         }
     }
 }
Esempio n. 9
0
    //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);
            }
        }
    }
Esempio n. 10
0
 private void Awake()
 {
     _selectionResponse = GetComponent <ISelectionResponse>();
 }
 private void Awake()
 {
     _selectionResponse = GetComponent <ISelectionResponse>();
     _rayProvider       = GetComponent <IRayProvider>();
     _selector          = GetComponent <ISelector>();
 }
Esempio n. 12
0
 protected virtual void Awake()
 {
     Item = info.GetNewItem();
     selectionResponse = GetComponent <ISelectionResponse>();
 }
Esempio n. 13
0
 private void Awake()
 {
     _selectionResponse = GetComponent <ISelectionResponse>();
     _objectSelector    = GetComponent <IObjectSelector>();
 }