示例#1
0
        internal void GetCommandCompleteRequirement(CommandCompleteRequirement _command)
        {
            for (int i = 0; i < require.Count; i++)
            {
                DishRequirement requirement = require[i];

                if (requirement.uid == _command.requirementUid)
                {
                    PlayerData playerData = _command.isMine ? mData : oData;

                    if (CheckCanCompleteRequirement(_command.resultList, playerData, requirement, true))
                    {
                        AddReward(_command.resultList, playerData, requirement);

                        require.RemoveAt(i);

                        for (int m = 0; m < _command.resultList.Count; m++)
                        {
                            int index = _command.resultList[m];

                            if (index > -1)
                            {
                                playerData.result[index] = null;
                            }
                            else
                            {
                                DishData dish = playerData.dish[-index - 1];

                                dish.result = null;

                                dish.state = DishState.NULL;

                                dish.time = 0;
                            }
                        }

                        eventCallBack?.Invoke(_command);
                    }

                    break;
                }
            }
        }
示例#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 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);
        }
示例#4
0
        public void CompleteRequirement(List <int> _resultList, int _requirementUid)
        {
            CommandCompleteRequirement command = new CommandCompleteRequirement(clientIsMine, _resultList, _requirementUid);

            SendCommand(command);
        }