예제 #1
0
    void SelectWolf()
    {
        // raycast from mouse position in camera
        Ray        rayClick = cam.ScreenPointToRay(Input.mousePosition);
        RaycastHit raycastHit;

        if (Physics.Raycast(rayClick, out raycastHit, Mathf.Infinity, selectionLayer.value))
        {
            Debug.DrawRay(rayClick.origin, rayClick.direction * 100, Color.red);

            WolfSelector wolfSelector = raycastHit.transform.GetComponentInChildren <WolfSelector>();

            if (wolfSelector == null)
            {
                Debug.Log("[PointerController] SheepSelector not found in " + raycastHit.transform.name);
            }
            else
            {
                if (currentSelectedWolf != wolfSelector)
                {
                    Debug.Log("[PointerController] Sheep selected: " + raycastHit.transform.name);

                    if (currentSelectedWolf != null)
                    {
                        currentSelectedWolf.Deselect();
                    }

                    currentSelectedWolf = wolfSelector;

                    currentSelectedWolf.Select();
                }
                else
                {
                    Debug.Log("[PointerController] Same sheep selected: " + raycastHit.transform.name);
                }
            }
        }
        else
        {
            /*
             * Debug.DrawRay(rayClick.origin, rayClick.direction * 100, Color.yellow);
             *
             * Debug.Log("[PointerController] No sheep selected");
             *
             * if(currentSelectedWolf != null)
             * {
             *  currentSelectedWolf.Deselect();
             *  currentSelectedWolf = null;
             * }
             */
        }
    }
예제 #2
0
    private void OnWolfDeselected(WolfSelector w)
    {
        if (w == wolfSelector1)
        {
            wolfToggle1.SetIsOnWithoutNotify(false);
            wolfToggle1.interactable = true;
        }

        if (w == wolfSelector2)
        {
            wolfToggle2.SetIsOnWithoutNotify(false);
            wolfToggle2.interactable = true;
        }
    }
예제 #3
0
 void Wolf_OnDeselection(WolfSelector w)
 {
     currentSelectedWolf = null;
 }
예제 #4
0
 void Wolf_OnSelection(WolfSelector w)
 {
     currentSelectedWolf = w;
 }
예제 #5
0
 void WolfSelector_OnDeselection(WolfSelector s)
 {
     Debug.Log("[Wolf] OnDeselection: " + name);
     isSelected = false;
     OnDeselect?.Invoke();
 }
예제 #6
0
 void Wolf_OnDeselection(WolfSelector s)
 {
 }
예제 #7
0
 void Wolf_OnSelection(WolfSelector s)
 {
     currentWolf = s.gameObject;
 }