Exemplo n.º 1
0
        void TrySelectMultipleUnits(SelectBox selectBox)
        {
            if (!_selectableTeam)
            {
                return;
            }

            foreach (var unit in RBTUnit.ActiveUnitsPerTeam[_selectableTeam])
            {
                if (!unit.Alive)
                {
                    continue;
                }

                var  pointOnScreen = Camera.main.WorldToScreenPoint(unit.Bounds.Center);
                bool selected      = selectBox.IsWithinBox(pointOnScreen);
                foreach (var point in unit.Bounds.Corners)
                {
                    if (selected)
                    {
                        _selectedUnits.Add(unit);
                        break;
                    }
                    pointOnScreen = Camera.main.WorldToScreenPoint(point);
                    selected      = selectBox.IsWithinBox(pointOnScreen);
                }
                unit.Selected = selected;
            }
        }