示例#1
0
 internal void GetCommandCompleteDish(CommandCompleteDish _command)
 {
     if (_command.isMine)
     {
         GetCommandCompleteDishReal(_command, mData);
     }
     else
     {
         GetCommandCompleteDishReal(_command, oData);
     }
 }
示例#2
0
        private void ServerGetCommand(bool _isMine, BinaryReader _br)
        {
            ICommand command;

            CommandType commandType = (CommandType)_br.ReadByte();

            switch (commandType)
            {
            case CommandType.CHANGE_WORKER_POS:

                command = new CommandChangeWorkerPos();

                break;

            case CommandType.CHANGE_RESULT_POS:

                command = new CommandChangeResultPos();

                break;

            case CommandType.COMPLETE_DISH:

                command = new CommandCompleteDish();

                break;

            default:

                command = new CommandCompleteRequirement();

                break;
            }

            command.FromBytes(_br);

            command.SetIsMine(_isMine);

            commandList.Add(command);
        }
示例#3
0
        private void GetCommandCompleteDishReal(CommandCompleteDish _command, PlayerData _playerData)
        {
            if (_command.pos > -1 && _command.pos < _playerData.dish.Count)
            {
                DishData dish = _playerData.dish[_command.pos];

                if (dish.result != null)
                {
                    if (_command.targetPos > -1 && _command.targetPos < _playerData.result.Length && _playerData.result[_command.targetPos] == null)
                    {
                        _playerData.result[_command.targetPos] = dish.result;
                    }

                    dish.result = null;

                    dish.state = DishState.NULL;

                    dish.time = 0;

                    eventCallBack?.Invoke(_command);
                }
            }
        }
示例#4
0
        private void Update(BinaryReader _br)
        {
            ushort tick = _br.ReadUInt16();

            if (tick != main.tick)
            {
                throw new Exception("tick is not match!  client:" + main.tick + "   server:" + tick);
            }

            if (tick % CookConst.REQUIRE_PRODUCE_TIME == 0)
            {
                ushort randomSeed = _br.ReadUInt16();

                main.SetSeed(randomSeed);
            }

            main.Update();

            ushort num = _br.ReadUInt16();

            for (int i = 0; i < num; i++)
            {
                CommandType commandType = (CommandType)_br.ReadByte();

                switch (commandType)
                {
                case CommandType.CHANGE_RESULT_POS:

                    CommandChangeResultPos commandChangeResultPos = new CommandChangeResultPos();

                    commandChangeResultPos.FromBytes(_br);

                    main.GetCommandChangeResultPos(commandChangeResultPos);

                    break;

                case CommandType.CHANGE_WORKER_POS:

                    CommandChangeWorkerPos commandChangeWorkerPos = new CommandChangeWorkerPos();

                    commandChangeWorkerPos.FromBytes(_br);

                    main.GetCommandChangeWorkerPos(commandChangeWorkerPos);

                    break;

                case CommandType.COMPLETE_DISH:

                    CommandCompleteDish commandCompleteDish = new CommandCompleteDish();

                    commandCompleteDish.FromBytes(_br);

                    main.GetCommandCompleteDish(commandCompleteDish);

                    break;

                default:

                    CommandCompleteRequirement commandCompleteRequirement = new CommandCompleteRequirement();

                    commandCompleteRequirement.FromBytes(_br);

                    main.GetCommandCompleteRequirement(commandCompleteRequirement);

                    break;
                }
            }

            if (num > 0)
            {
                CheckSync();
            }

            GameResult gameResult;

            if (main.tick > CookConst.MAX_TIME * CookConst.TICK_NUM_PER_SECOND)
            {
                gameResult = main.GetGameResult();
            }
            else
            {
                gameResult = GameResult.NOT_OVER;
            }

            client.UpdateCallBack(gameResult);
        }
示例#5
0
        public void CompleteDish(int _pos, int _targetPos)
        {
            CommandCompleteDish command = new CommandCompleteDish(clientIsMine, _pos, _targetPos);

            SendCommand(command);
        }