예제 #1
0
        public void SelectionState()
        {
            if (UiRaycast.IsRaycastingToUi())
            {
                return;
            }
            switch (_currentLayer)
            {
            case Layer.Units:
                SelectUnitHit();
                break;

            case Layer.Interactable:
                SelectBuilding();
                break;

            case Layer.Walkable:
                DeselectAllUnits();
                break;

            default:
                return;
            }
        }
예제 #2
0
        public void SelectUnitsInBox(Rect selectionRect)
        {
            if (UiRaycast.IsRaycastingToUi())
            {
                return;
            }
            DeselectBuilding();
            if (!Input.GetKey(KeyCode.LeftControl) && !_selectedBuilding)
            {
                DeselectAllUnits();
            }

            SelectableUnits.RemoveAll(unit => unit == null);
            foreach (GameObject iUnit in SelectableUnits)
            {
                Vector3 unitVpos     = Camera.main.WorldToViewportPoint(iUnit.transform.position);
                bool    isUnitInRect = selectionRect.Contains(unitVpos, true);
                if (isUnitInRect)
                {
                    SelectUnit(iUnit.GetComponent <Unit>());
                    UpdateSelectedUnits();
                }
            }
        }