Ejemplo n.º 1
0
    private void ClickRequirementUnitContainer(RequirementUnitContainer _container)
    {
        if (selectedUnitList.Count == _container.requirement.dishArr.Length)
        {
            List <int> list = new List <int>();

            for (int i = 0; i < selectedUnitList.Count; i++)
            {
                ControlUnit controlUnit = selectedUnitList[i];

                if (controlUnit is DishResultContainer)
                {
                    DishResultContainer container = controlUnit as DishResultContainer;

                    list.Add(container.index);
                }
                else
                {
                    DishResultBt bt = controlUnit as DishResultBt;

                    list.Add(-bt.dish.index - 1);
                }
            }

            if (client.CheckCanCompleteRequirement(list, _container.requirement))
            {
                //send command
                client.CompleteRequirement(list, _container.requirement.uid);
            }
        }

        ClearSelectedUnitList();
    }
Ejemplo n.º 2
0
    private void ClickDishResultBt(DishResultBt _bt)
    {
        if (_bt.dish.resultUnit != null)
        {
            if (selectedUnitList.Count == 0)
            {
                selectedUnitList.Add(_bt);

                _bt.SetSelected(true);
            }
            else if (selectedUnitList.Count == 1)
            {
                ControlUnit lastSelectedUnit = selectedUnitList[0];

                if (lastSelectedUnit == _bt)
                {
                    ClearSelectedUnitList();
                }
                else
                {
                    if (lastSelectedUnit is DishResultBt || lastSelectedUnit is DishResultContainer)
                    {
                    }
                    else
                    {
                        ClearSelectedUnitList();
                    }

                    selectedUnitList.Add(_bt);

                    _bt.SetSelected(true);
                }
            }
            else
            {
                //ClearSelectedUnitList();

                int index = selectedUnitList.IndexOf(_bt);

                if (index == -1)
                {
                    selectedUnitList.Add(_bt);

                    _bt.SetSelected(true);
                }
                else
                {
                    selectedUnitList.RemoveAt(index);

                    _bt.SetSelected(false);
                }
            }
        }
        else
        {
            ClearSelectedUnitList();
        }
    }
Ejemplo n.º 3
0
    private void DragControlUnit(ControlUnit _startUnit, ControlUnit _endUnit)
    {
        if (_startUnit is SeatUnit)
        {
            SeatUnit unit = _startUnit as SeatUnit;

            if (_endUnit is SeatUnit)
            {
                SeatUnit endUnit = _endUnit as SeatUnit;

                if (endUnit.GetWorker() == null)
                {
                    //send command
                    client.ChangeWorkerPos(unit.GetWorker().index, endUnit.index);
                }
            }
        }
        else if (_startUnit is DishResultContainer)
        {
            DishResultContainer unit = _startUnit as DishResultContainer;

            if (_endUnit is DishResultContainer)
            {
                DishResultContainer endUnit = _endUnit as DishResultContainer;

                //send command
                client.ChangeResultPos(unit.index, endUnit.index);
            }
            else if (_endUnit is TrashContainer)
            {
                //send command
                client.ChangeResultPos(unit.index, -1);
            }
        }
        else
        {
            DishResultBt unit = _startUnit as DishResultBt;

            if (_endUnit is DishResultContainer)
            {
                DishResultContainer endUnit = _endUnit as DishResultContainer;

                if (endUnit.result == null)
                {
                    //send command
                    client.CompleteDish(unit.dish.index, endUnit.index);
                }
            }
            else if (_endUnit is TrashContainer)
            {
                //send command
                client.CompleteDish(unit.dish.index, -1);
            }
        }
    }
Ejemplo n.º 4
0
    private void ClickDishResultContainer(DishResultContainer _dishResultContainer)
    {
        if (selectedUnitList.Count == 0)
        {
            if (_dishResultContainer.result != null)
            {
                selectedUnitList.Add(_dishResultContainer);

                _dishResultContainer.SetSelected(true);
            }
        }
        else if (selectedUnitList.Count == 1)
        {
            ControlUnit lastSelectedUnit = selectedUnitList[0];

            if (lastSelectedUnit is DishResultBt)
            {
                if (_dishResultContainer.result == null)
                {
                    DishResultBt dishResultBt = lastSelectedUnit as DishResultBt;

                    //send command
                    client.CompleteDish(dishResultBt.dish.index, _dishResultContainer.index);

                    ClearSelectedUnitList();
                }
                else
                {
                    //ClearSelectedUnitList();

                    selectedUnitList.Add(_dishResultContainer);

                    _dishResultContainer.SetSelected(true);
                }
            }
            else if (lastSelectedUnit is DishResultContainer)
            {
                if (lastSelectedUnit == _dishResultContainer)
                {
                    ClearSelectedUnitList();
                }
                else
                {
                    if (_dishResultContainer.result == null)
                    {
                        DishResultContainer lastDishResultContainer = lastSelectedUnit as DishResultContainer;

                        //send command
                        client.ChangeResultPos(lastDishResultContainer.index, _dishResultContainer.index);

                        ClearSelectedUnitList();
                    }
                    else
                    {
                        selectedUnitList.Add(_dishResultContainer);

                        _dishResultContainer.SetSelected(true);
                    }
                }
            }
            else
            {
                ClearSelectedUnitList();

                if (_dishResultContainer.result != null)
                {
                    selectedUnitList.Add(_dishResultContainer);

                    _dishResultContainer.SetSelected(true);
                }
            }
        }
        else
        {
            if (_dishResultContainer.result != null)
            {
                int index = selectedUnitList.IndexOf(_dishResultContainer);

                if (index == -1)
                {
                    selectedUnitList.Add(_dishResultContainer);

                    _dishResultContainer.SetSelected(true);
                }
                else
                {
                    selectedUnitList.RemoveAt(index);

                    _dishResultContainer.SetSelected(false);
                }
            }
            else
            {
                ClearSelectedUnitList();
            }
        }
    }