Example #1
0
        public async Task StopAction()
        {
            var result = await DoCommand(async() => {
                var playerId = _account.PlayerId;

                var command = new StopActionCommand(playerId);
                await _bus.SendCommand(command);
            });
        }
Example #2
0
        public async Task <Unit> Handle(StopActionCommand command, CancellationToken cancellationToken)
        {
            //await _bus.RaiseEvent(new DomainNotification("功能暂时未实现"));

            var playerId = command.PlayerId;
            var player   = await _playerDomainService.Get(playerId);

            if (player == null)
            {
                await _bus.RaiseEvent(new DomainNotification($"角色不存在!"));

                return(Unit.Value);
            }
            var status = player.Status;

            if (status == PlayerStatusEnum.空闲)
            {
                return(Unit.Value);
            }


            player.Status = PlayerStatusEnum.空闲;
            await _playerDomainService.Update(player);

            switch (status)
            {
            case PlayerStatusEnum.打坐:
                await _mudProvider.ShowMessage(playerId, "你停止了打坐。。。");

                break;

            case PlayerStatusEnum.打工:
                await _mudProvider.ShowMessage(playerId, "你停止了打工。。。");

                break;

            case PlayerStatusEnum.伐木:
                await _mudProvider.ShowMessage(playerId, "你停止了伐木。。。");

                break;

            case PlayerStatusEnum.打猎:
                await _mudProvider.ShowMessage(playerId, "你停止了打猎。。。");

                break;

            case PlayerStatusEnum.挖矿:
                await _mudProvider.ShowMessage(playerId, "你停止了挖矿。。。");

                break;

            case PlayerStatusEnum.疗伤:
                await _mudProvider.ShowMessage(playerId, "你停止了疗伤。。。");

                break;

            case PlayerStatusEnum.采药:
                await _mudProvider.ShowMessage(playerId, "你停止了采药。。。");

                break;

            case PlayerStatusEnum.钓鱼:
                await _mudProvider.ShowMessage(playerId, "你停止了钓鱼。。。");

                break;

            default:
                await _mudProvider.ShowMessage(playerId, $"你停止了{status}。。。");

                break;
            }

            await _recurringQueue.Remove <PlayerStatusModel>($"player_{playerId}");

            if (await Commit())
            {
                await _bus.RaiseEvent(new PlayerStatusChangedEvent(player)).ConfigureAwait(false);
            }
            return(Unit.Value);
        }