Exemplo n.º 1
0
 public void SelectUnit(BaseUnit unit)
 {
     SelectedUnit?.OnUnBeSelected();
     if (unit)
     {
         unit?.OnBeSelected();
         SelectedUnit = unit;
     }
     else
     {
         SelectedUnit = null;
     }
 }
Exemplo n.º 2
0
        public static void SelectUnit(BaseUnit unit)
        {
            if (IsBlockSelectUnit)
            {
                return;
            }
            //选择一个单位后无法再次选择
            if (IsInSelectUnitTime())
            {
                return;
            }
            if (unit)
            {
                //检测这个是否可以被选择
                if (!Ins.IsCanSelectUnit(unit))
                {
                    return;
                }
            }

            //检测是否重复选择
            bool isRepeat = false;

            if (SelectedUnit == unit)
            {
                isRepeat = true;
            }
            else
            {
                SelectedUnit?.OnUnBeSelected();
            }

            if (unit)
            {
                unit?.OnBeSelected(isRepeat);
                SelectedUnit = unit;
            }
            else
            {
                SelectedUnit = null;
            }
            SelectUnitTimer.Restart();
            Ins?.OnSelectedUnit(SelectedUnit, isRepeat);
        }