Ejemplo n.º 1
0
        public async Task Execute(PlayerStatusModel model)
        {
            int playerId = model.PlayerId;
            var player   = await _playerDomainService.Get(playerId);

            if (player == null)
            {
                _logger.LogDebug($"player == null");
                return;
            }

            var online = await _mudOnlineProvider.GetPlayerOnline(playerId);

            if (online == null)
            {
                //玩家离线后,从队列删除,并且修改状态为空闲
                await _recurringQueue.Remove <PlayerStatusModel>(playerId);

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

                    await _bus.RaiseEvent(new PlayerStatusChangedEvent(player)).ConfigureAwait(false);
                }
                return;
            }

            if (player.Status != model.Status)
            {
                await _recurringQueue.Remove <PlayerStatusModel>(playerId);

                return;
            }


            //TODO
            switch (model.Status)
            {
            case PlayerStatusEnum.伐木:

                break;
            }

            await _mudProvider.ShowMessage(playerId, $"你正在{model.Status}。。。");
        }
Ejemplo n.º 2
0
        public async Task Execute(PlayerStatusModel model)
        {
            int playerId = model.PlayerId;
            var player   = await _playerDomainService.Get(playerId);

            if (player == null)
            {
                _logger.LogDebug($"player == null");
                return;
            }

            var online = await _mudOnlineProvider.GetPlayerOnline(playerId);

            if (online == null)
            {
                //玩家离线后,从队列删除,并且修改状态为空闲
                await _recurringQueue.Remove <PlayerStatusModel>(playerId);

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

                    await _bus.RaiseEvent(new PlayerStatusChangedEvent(player)).ConfigureAwait(false);
                }
                return;
            }

            if (player.Status != model.Status)
            {
                await _recurringQueue.Remove <PlayerStatusModel>(playerId);

                return;
            }


            //TODO
            switch (model.Status)
            {
            case PlayerStatusEnum.伐木:
            case PlayerStatusEnum.挖矿:
            case PlayerStatusEnum.打猎:
            case PlayerStatusEnum.采药:
            case PlayerStatusEnum.钓鱼:
            case PlayerStatusEnum.打工:

                await DoWork(player);

                break;

            case PlayerStatusEnum.疗伤:
                await Heal(player);

                break;

            case PlayerStatusEnum.打坐:
                await Muse(player);

                break;

            case PlayerStatusEnum.战斗:
                await Fighting(player, model.TargetId);

                break;
            }
        }
Ejemplo n.º 3
0
 private async Task StopAction(int npcId)
 {
     await _recurringQueue.Remove <NpcStatusModel>($"npc_{npcId}");
 }
Ejemplo n.º 4
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);
        }