public static async void Start(this TrusteeshipComponent self) { //玩家所在房间 Room room = Game.Scene.GetComponent <RoomComponent>().Get(self.GetParent <Gamer>().RoomID); OrderControllerComponent orderController = room.GetComponent <OrderControllerComponent>(); Gamer gamer = self.GetParent <Gamer>(); bool isStartPlayCard = false; while (true) { await Game.Scene.GetComponent <TimerComponent>().WaitAsync(1000); if (self.IsDisposed) { return; } if (gamer.UserID != orderController?.CurrentAuthority) { continue; } //自动出牌开关,用于托管延迟出牌 isStartPlayCard = !isStartPlayCard; if (isStartPlayCard) { continue; } //出牌 await gamer.GetComponent <HandCardsComponent>().PopCard(); } }
public static async void Start(this TrusteeshipComponent self) { //玩家所在房间 Room room = Game.Scene.GetComponent <RoomComponent>().Get(self.GetParent <Gamer>().RoomID); OrderControllerComponent orderController = room.GetComponent <OrderControllerComponent>(); Gamer gamer = self.GetParent <Gamer>(); bool isStartPlayCard = false; while (true) { await Game.Scene.GetComponent <TimerComponent>().WaitAsync(1000); if (self.IsDisposed) { return; } if (gamer.UserID != orderController?.CurrentAuthority) { continue; } //自动出牌开关,用于托管延迟出牌 isStartPlayCard = !isStartPlayCard; if (isStartPlayCard) { continue; } ActorMessageSender actorProxy = Game.Scene.GetComponent <ActorMessageSenderComponent>().Get(gamer.Id); //当还没抢地主时随机抢地主 if (gamer.GetComponent <HandCardsComponent>().AccessIdentity == Identity.None) { int randomSelect = RandomHelper.RandomNumber(0, 2); actorProxy.Send(new Actor_GamerGrabLandlordSelect_Ntt() { IsGrab = randomSelect == 0 }); self.Playing = false; continue; } //自动提示出牌 Actor_GamerPrompt_Ack response = await actorProxy.Call(new Actor_GamerPrompt_Req()) as Actor_GamerPrompt_Ack; if (response.Error > 0 || response.Cards == null) { actorProxy.Send(new Actor_GamerDontPlay_Ntt()); } else { await actorProxy.Call(new Actor_GamerPlayCard_Req() { Cards = response.Cards }); } } }
public static async void Start(this TrusteeshipComponent self) { //找到玩家所在房间 LandlordsComponent landordsMatchComponent = Game.Scene.GetComponent <LandlordsComponent>(); Gamer gamer = self.GetParent <Gamer>(); LandlordsRoom room = landordsMatchComponent.GetGamingRoom(self.GetParent <Gamer>()); ActorMessageSender actorProxy = Game.Scene.GetComponent <ActorMessageSenderComponent>().Get(gamer.InstanceId); OrderControllerComponent orderController = room.GetComponent <OrderControllerComponent>(); //这个托管组件是通过定时器实现的 while (true) { //延迟1秒 await Game.Scene.GetComponent <TimerComponent>().WaitAsync(3000); if (self.IsDisposed) { return; } if (gamer.UserID != orderController?.CurrentAuthority) { continue; } //给Map上的Gamer发送Actor消息 //自动提示出牌 Actor_GamerPrompt_Back response = (Actor_GamerPrompt_Back)await actorProxy.Call(new Actor_GamerPrompt_Req()); if (response.Error > 0 || response.Cards.Count == 0) { actorProxy.Send(new Actor_GamerDontPlay_Ntt()); } else { await actorProxy.Call(new Actor_GamerPlayCard_Req() { Cards = response.Cards }); } } }