Example #1
0
    /// <summary>
    /// cast a ray 1 unit behind mousePos to 1 unit forward
    /// that state sprite will be in between
    /// </summary>
    /// <returns></returns>
    public static GameObject DetectStateObject(int layerMask)
    {
        var mousePos = MousePosition.GetCamera().ScreenToWorldPoint(Input.mousePosition);

        mousePos = new Vector3(mousePos.x, mousePos.y, 0);
        //Debug.Log(statesLayer.value);
        RaycastHit2D hit = Physics2D.Raycast(mousePos + Vector3.back, mousePos + Vector3.zero, 1.5f, layerMask);

        if (!hit)
        {
            return(null);
        }
        return(hit.collider.gameObject);
    }
Example #2
0
    private void Start()
    {
        /// when a state created
        /// automata class makes one state with {AutomataManager.CurrentStateId}
        /// then in next frame Start method of this object calls
        /// so -1 turn it back to it should be
        ID = AutomataManager.CurrentStateId - 1;

        stateName.SetParent(UIManager.Instance.transform, false);
        stateName.position = MousePosition.GetCamera().WorldToScreenPoint(transform.position);

        _spriteRenderer = GetComponent <SpriteRenderer>();

        if (sprites.Length < 4)
        {
            Debug.LogError("Set State Colors");
        }

        BuildStateEvents.Instance.OnChangeStatus += SetSprite;
        BuildStateEvents.Instance.OnDeleteState  += DestroyThis;
    }
Example #3
0
 public void SetPosition(Vector2 position)
 {
     _tagHandlerRect.transform.position = MousePosition.GetCamera().WorldToScreenPoint(position);
 }
Example #4
0
 private void OnMouseDrag()
 {
     transform.position = MousePosition.GetMousePosition() + _offset;
     stateName.position = MousePosition.GetCamera().WorldToScreenPoint(transform.position);
 }