public JSONAPI(string apiKey, System.Version Version) { this.apiKey = apiKey; this.Version = Version; this.Game = new GameHandle(this); this.Me = new MeHandle(this); this.Bot = new BotHandle(this); this.Chat = new ChatHandle(this); }
//bool buyMode = false; // Start is called before the first frame update private void Awake() { if (instance != null) { Destroy(gameObject); } instance = this; curState = stateSet; }
/// <summary> /// 判断给定数据和图像中的颜色数据是否一样(相似) /// </summary> /// <param name="data">需要判定的数据</param> /// <param name="rin">容许色差阈值(0~441)</param> /// <param name="OffsetX">X坐标偏移</param> /// <param name="OffsetY">Y坐标偏移</param> /// <returns></returns> public static bool Judge(DataJudge data, Bitmap bitmap = null, int rin = 0, int OffsetX = 0, int OffsetY = 0) { if (data == null) { throw new Exceptions.DataErrorException("给定的判定数据为 null !"); } if (GlobalObject.GameHandle.IsSuccess) { if (bitmap == null) { bitmap = GameHandle.GetGameBitmap(); } return(Judge(bitmap, data, rin, OffsetX, OffsetY)); } else { throw new Exceptions.NoGameHandleException(); } }
public override void FindGame(IRpcController controller, FindGameRequest request, Action <FindGameResponse> done) { FindGameResponse.Builder findGameResponse = FindGameResponse.CreateBuilder(); findGameResponse.SetRequestId(12526585062881647236); done(findGameResponse.Build()); client.ListenerId = request.ObjectId; GameFoundNotification.Builder gameFoundNotification = GameFoundNotification.CreateBuilder(); GameHandle.Builder gameHandle = GameHandle.CreateBuilder(); gameHandle.SetFactoryId(request.FactoryId); gameHandle.SetGameId(EntityId.CreateBuilder().SetHigh(433661094641971304).SetLow(11017467167309309688).Build()); ConnectInfo.Builder connectInfo = ConnectInfo.CreateBuilder(); connectInfo.SetToonId(new EntityId.Builder { High = HighId.Toon, Low = 2 }.Build()); connectInfo.SetHost("127.0.0.1"); connectInfo.SetPort(6665); connectInfo.SetToken(ByteString.CopyFrom(new byte[] { 0x07, 0x34, 0x02, 0x60, 0x91, 0x93, 0x76, 0x46, 0x28, 0x84 })); connectInfo.AddAttribute(Attribute .CreateBuilder() .SetName("SGameId") .SetValue(Variant .CreateBuilder() .SetIntValue(2014314530) .Build()) .Build()); gameFoundNotification.SetRequestId(12526585062881647236); gameFoundNotification.SetGameHandle(gameHandle.Build()); gameFoundNotification.AddConnectInfo(connectInfo.Build()); GameFactorySubscriber.CreateStub(client).NotifyGameFound(controller, gameFoundNotification.Build(), r => { }); }
public void GameEntryHandler(bnet.protocol.notification.Notification notification) { base.ApiLog.LogDebug("GAME_ENTRY"); string host = null; int port = 0; string stringValue = null; int intValue = 0; int num3 = 0; string str3 = null; bool boolValue = false; string str4 = null; foreach (bnet.protocol.attribute.Attribute attribute in notification.AttributeList) { if (attribute.Name.Equals("connection_info") && attribute.Value.HasMessageValue) { ConnectInfo info = ConnectInfo.ParseFrom(attribute.Value.MessageValue); host = info.Host; port = info.Port; if (info.HasToken) { str3 = Encoding.UTF8.GetString(info.Token); } foreach (bnet.protocol.attribute.Attribute attribute2 in info.AttributeList) { if (attribute2.Name.Equals("version") && attribute2.Value.HasStringValue) { stringValue = attribute2.Value.StringValue; } else if (attribute2.Name.Equals("game") && attribute2.Value.HasIntValue) { intValue = (int)attribute2.Value.IntValue; } else if (attribute2.Name.Equals("id") && attribute2.Value.HasIntValue) { num3 = (int)attribute2.Value.IntValue; } else if (attribute2.Name.Equals("resumable") && attribute2.Value.HasBoolValue) { boolValue = attribute2.Value.BoolValue; } else if (attribute2.Name.Equals("spectator_password") && attribute2.Value.HasStringValue) { str4 = attribute2.Value.StringValue; } } } else if (attribute.Name.Equals("game_handle") && attribute.Value.HasMessageValue) { GameHandle handle = GameHandle.ParseFrom(attribute.Value.MessageValue); base.m_battleNet.Channel.JoinChannel(handle.GameId, ChannelAPI.ChannelType.GAME_CHANNEL); } else if (attribute.Name.Equals("sender_id") && attribute.Value.HasMessageValue) { base.ApiLog.LogDebug("sender_id"); } } BattleNet.GameServerInfo gsInfo = new BattleNet.GameServerInfo { Address = host, Port = port, AuroraPassword = str3, Version = stringValue, GameHandle = intValue, ClientHandle = num3, Resumable = boolValue, SpectatorPassword = str4 }; this.AddQueueEvent(BattleNet.QueueEvent.Type.QUEUE_GAME_STARTED, 0, 0, 0, gsInfo); }
public void GameEntryHandler(Notification notification) { base.ApiLog.LogDebug("GAME_ENTRY"); string address = null; int port = 0; string version = null; int gameHandle = 0; int num = 0; string auroraPassword = null; bool resumable = false; string spectatorPassword = null; foreach (bnet.protocol.attribute.Attribute attribute in notification.AttributeList) { if (attribute.Name.Equals("connection_info") && attribute.Value.HasMessageValue) { byte[] messageValue = attribute.Value.MessageValue; ConnectInfo connectInfo = ConnectInfo.ParseFrom(messageValue); address = connectInfo.Host; port = connectInfo.Port; if (connectInfo.HasToken) { auroraPassword = Encoding.UTF8.GetString(connectInfo.Token); } foreach (bnet.protocol.attribute.Attribute attribute2 in connectInfo.AttributeList) { if (attribute2.Name.Equals("version") && attribute2.Value.HasStringValue) { version = attribute2.Value.StringValue; } else if (attribute2.Name.Equals("game") && attribute2.Value.HasIntValue) { gameHandle = (int)attribute2.Value.IntValue; } else if (attribute2.Name.Equals("id") && attribute2.Value.HasIntValue) { num = (int)attribute2.Value.IntValue; } else if (attribute2.Name.Equals("resumable") && attribute2.Value.HasBoolValue) { resumable = attribute2.Value.BoolValue; } else if (attribute2.Name.Equals("spectator_password") && attribute2.Value.HasStringValue) { spectatorPassword = attribute2.Value.StringValue; } } } else if (attribute.Name.Equals("game_handle") && attribute.Value.HasMessageValue) { byte[] messageValue2 = attribute.Value.MessageValue; GameHandle gameHandle2 = GameHandle.ParseFrom(messageValue2); this.m_battleNet.Channel.JoinChannel(gameHandle2.GameId, ChannelAPI.ChannelType.GAME_CHANNEL); } else if (attribute.Name.Equals("sender_id") && attribute.Value.HasMessageValue) { base.ApiLog.LogDebug("sender_id"); } } this.AddQueueEvent(QueueEvent.Type.QUEUE_GAME_STARTED, 0, 0, 0, new GameServerInfo { Address = address, Port = port, AuroraPassword = auroraPassword, Version = version, GameHandle = gameHandle, ClientHandle = (long)num, Resumable = resumable, SpectatorPassword = spectatorPassword }); }
public void GameEntryHandler(Notification notification) { base.ApiLog.LogDebug("GAME_ENTRY"); string address = null; int port = 0; string version = null; int gameHandle = 0; int num = 0; string auroraPassword = null; bool resumable = false; string spectatorPassword = null; using (List <Attribute> .Enumerator enumerator = notification.AttributeList.GetEnumerator()) { while (enumerator.MoveNext()) { Attribute current = enumerator.get_Current(); if (current.Name.Equals("connection_info") && current.Value.HasMessageValue) { byte[] messageValue = current.Value.MessageValue; ConnectInfo connectInfo = ConnectInfo.ParseFrom(messageValue); address = connectInfo.Host; port = connectInfo.Port; if (connectInfo.HasToken) { auroraPassword = Encoding.get_UTF8().GetString(connectInfo.Token); } using (List <Attribute> .Enumerator enumerator2 = connectInfo.AttributeList.GetEnumerator()) { while (enumerator2.MoveNext()) { Attribute current2 = enumerator2.get_Current(); if (current2.Name.Equals("version") && current2.Value.HasStringValue) { version = current2.Value.StringValue; } else if (current2.Name.Equals("game") && current2.Value.HasIntValue) { gameHandle = (int)current2.Value.IntValue; } else if (current2.Name.Equals("id") && current2.Value.HasIntValue) { num = (int)current2.Value.IntValue; } else if (current2.Name.Equals("resumable") && current2.Value.HasBoolValue) { resumable = current2.Value.BoolValue; } else if (current2.Name.Equals("spectator_password") && current2.Value.HasStringValue) { spectatorPassword = current2.Value.StringValue; } } } } else if (current.Name.Equals("game_handle") && current.Value.HasMessageValue) { byte[] messageValue2 = current.Value.MessageValue; GameHandle gameHandle2 = GameHandle.ParseFrom(messageValue2); this.m_battleNet.Channel.JoinChannel(gameHandle2.GameId, ChannelAPI.ChannelType.GAME_CHANNEL); } else if (current.Name.Equals("sender_id") && current.Value.HasMessageValue) { base.ApiLog.LogDebug("sender_id"); } } } this.AddQueueEvent(QueueEvent.Type.QUEUE_GAME_STARTED, 0, 0, 0, new GameServerInfo { Address = address, Port = port, AuroraPassword = auroraPassword, Version = version, GameHandle = gameHandle, ClientHandle = (long)num, Resumable = resumable, SpectatorPassword = spectatorPassword }); }
public void PlayerSaveBar(GPlayer player, Packet packet) { Channel Lobby; GameBase GameHandle; PlayerInventory Inventory; Lobby = player.Lobby; GameHandle = Lobby.GetGameHandle(player); Inventory = player.Inventory; packet.ReadByte(out byte action); packet.ReadUInt32(out uint id); try { var Response = new PangyaBinaryWriter(); Response.Write(new byte[] { 0x4B, 0x00 }); Response.WriteUInt32(0); Response.WriteByte(action); Response.WriteUInt32(player.ConnectionID); switch (action) { case 1: // ## caddie { if (!Inventory.SetCaddieIndex(id)) { player.Close(); return; } Response.Write(Inventory.GetCaddieData()); } break; case 2: // ## ball { if (!Inventory.SetBallTypeID(id)) { player.Close(); return; } Response.Write(id); } break; case 3: // ## club { if (!Inventory.SetClubSetIndex(id)) { player.Close(); return; } Response.Write(Inventory.GetClubData()); //clubdata temp } break; case 4: // ## char { if (!Inventory.SetCharIndex(id)) { player.Close(); return; } Response.Write(Inventory.GetCharData()); } break; case 5: // ## mascot { if (!Inventory.SetMascotIndex(id)) { player.Close(); return; } Response.Write(Inventory.GetMascotData()); } break; case 7: // ## start game { if (GameHandle == null) { return; } GameHandle.AcquireData(player); } break; } if (action == 4 && GameHandle != null) { GameHandle.Send(Response); //Atualizar GameHandle.Send(ShowActionGamePlayInfo(player)); if (GameHandle.GameType == GAME_TYPE.CHAT_ROOM) { //GameHandle.Send(ShowRoomEntrance(player.ConnectionID, 15)); } } else { player.SendResponse(Response.GetBytes()); } } catch { player.Close(); } }
// Use this for initialization void Start() { /* 注册请求 */ mGameHandle = new GameHandle(); NetCore.Instance.registHandle(mGameHandle); mGameControler = GetComponent <GameControler>(); mGameControler.mGameHandle = mGameHandle; mButtonControler = GetComponent <ButtonControler>(); mButtonControler.mGameHandle = mGameHandle; mChatControler = GetComponent <ChatControler>(); mChatControler.mGameHandle = mGameHandle; // 初始化房间信息 InitRoomInfo(); // 通知更新牌桌(换桌的时候会通知一次) NetCore.Instance.setActionForever(NetProto.Api.ENetMsgId.room_get_table_ack); NetCore.Instance.RegisterAction(NetProto.Api.ENetMsgId.room_get_table_ack, (roomGetTableAck) => { NetProto.RoomGetTableAck roomGetTableAction = (NetProto.RoomGetTableAck)roomGetTableAck; MainData.Instance().tableInfo = roomGetTableAction.Table; foreach (var playerInfo in roomGetTableAction.Table.Players) { if (UserManager.Instance().authModel.user_id == playerInfo.Id) { MainData.Instance().selfInfo = playerInfo; break; } } // 重置UI mGameControler.ResetUIAfterChangeTable(); // 初始化房间信息 InitRoomInfo(); // 隐藏换桌加载组件 mGameControler.SetChangeTableLoadingActive(false); }); // 玩家加入游戏 NetCore.Instance.setActionForever(NetProto.Api.ENetMsgId.room_player_join_ack); NetCore.Instance.RegisterAction(NetProto.Api.ENetMsgId.room_player_join_ack, (roomPlayerJoinAck) => { RoomPlayerJoinAck roomPlayerJoinAction = (RoomPlayerJoinAck)roomPlayerJoinAck; // 更新玩家信息 mGameControler.UpdateAfterPlayerJoin(roomPlayerJoinAction.Player); }); // 玩家离开游戏 NetCore.Instance.setActionForever(NetProto.Api.ENetMsgId.room_player_gone_ack); NetCore.Instance.RegisterAction(NetProto.Api.ENetMsgId.room_player_gone_ack, (roomPlayerGoneAck) => { RoomPlayerGoneAck roomPlayerGoneAction = (RoomPlayerGoneAck)roomPlayerGoneAck; // 更新玩家信息 mGameControler.UpdateAfterPlayerGone(roomPlayerGoneAction.Player); }); // 通报庄家 NetCore.Instance.setActionForever(NetProto.Api.ENetMsgId.room_button_ack); NetCore.Instance.RegisterAction(NetProto.Api.ENetMsgId.room_button_ack, (roomButtonAck) => { RoomButtonAck roomButtonAction = (RoomButtonAck)roomButtonAck; // 设置庄家 mGameControler.SetDealer(roomButtonAction.ButtonPos); }); // 发牌 NetCore.Instance.setActionForever(NetProto.Api.ENetMsgId.room_deal_ack); NetCore.Instance.RegisterAction(NetProto.Api.ENetMsgId.room_deal_ack, (roomDealAck) => { RoomDealAck roomDealAction = (RoomDealAck)roomDealAck; string cardType = CardInfoUtil.GetCardType(roomDealAction.HandLevel); switch (roomDealAction.Action) { case CardInfoUtil.ACTION_PREFLOP: mGameControler.DealHandCard(roomDealAction.Cards, cardType); break; case CardInfoUtil.ACTION_FLOP: mGameControler.DealPublicCard(roomDealAction.Cards, cardType); break; case CardInfoUtil.ACTION_TURN: mGameControler.DealPublicCard(roomDealAction.Cards, cardType); break; case CardInfoUtil.ACTION_RIVER: mGameControler.DealPublicCard(roomDealAction.Cards, cardType); break; default: break; } }); // 通报当前下注玩家 NetCore.Instance.setActionForever(NetProto.Api.ENetMsgId.room_action_ack); NetCore.Instance.RegisterAction(NetProto.Api.ENetMsgId.room_action_ack, (roomActionAck) => { RoomActionAck roomActionAction = (RoomActionAck)roomActionAck; mGameControler.TurnNext(roomActionAction.Pos, roomActionAction.BaseBet); }); // 玩家押注 NetCore.Instance.setActionForever(NetProto.Api.ENetMsgId.room_player_bet_ack); NetCore.Instance.RegisterAction(NetProto.Api.ENetMsgId.room_player_bet_ack, (roomPlayerBetAck) => { RoomPlayerBetAck roomPlayerBetAction = (RoomPlayerBetAck)roomPlayerBetAck; if (roomPlayerBetAction.Action.Equals(PlayerInfoUtil.ACTION_FLOD)) { mGameControler.Discard(roomPlayerBetAction.Pos); } else { mGameControler.PlayerBetting(roomPlayerBetAction); } }); // 通报底池 NetCore.Instance.setActionForever(NetProto.Api.ENetMsgId.room_pot_ack); NetCore.Instance.RegisterAction(NetProto.Api.ENetMsgId.room_pot_ack, (roomPotAck) => { roomPotAckAction = (RoomPotAck)roomPotAck; Invoke("RoomPot", 0.5f); }); // 摊牌比牌 NetCore.Instance.setActionForever(NetProto.Api.ENetMsgId.room_showdown_ack); NetCore.Instance.RegisterAction(NetProto.Api.ENetMsgId.room_showdown_ack, (roomShowdownAck) => { RoomShowdownAck roomShowdownAction = (RoomShowdownAck)roomShowdownAck; mGameControler.GameOver(roomShowdownAction); }); // 通报玩家站起 NetCore.Instance.setActionForever(NetProto.Api.ENetMsgId.room_player_standup_ack); NetCore.Instance.RegisterAction(NetProto.Api.ENetMsgId.room_player_standup_ack, (roomPlayerStandupAck) => { RoomPlayerStandupAck roomPlayerStandupAction = (RoomPlayerStandupAck)roomPlayerStandupAck; // 更新玩家信息 mGameControler.UpdateAfterPlayerStandUp(roomPlayerStandupAction); }); // 通报玩家坐下 NetCore.Instance.setActionForever(NetProto.Api.ENetMsgId.room_player_sitdown_ack); NetCore.Instance.RegisterAction(NetProto.Api.ENetMsgId.room_player_sitdown_ack, (roomPlayerSitdownAck) => { RoomPlayerSitdownAck roomPlayerSitdownAction = (RoomPlayerSitdownAck)roomPlayerSitdownAck; // 更新玩家信息 mGameControler.UpdateAfterPlayerSitDown(roomPlayerSitdownAction.Player); }); // 自动坐下等待玩家数通报 NetCore.Instance.setActionForever(NetProto.Api.ENetMsgId.room_player_auto_sitdown_ack); NetCore.Instance.RegisterAction(NetProto.Api.ENetMsgId.room_player_auto_sitdown_ack, (roomPlayerAutoSitdownAck) => { RoomPlayerAutoSitdownAck roomPlayerAutoSitdownAction = (RoomPlayerAutoSitdownAck)roomPlayerAutoSitdownAck; mButtonControler.UpdateWaitCount(roomPlayerAutoSitdownAction.Num); }); // 踢出玩家 NetCore.Instance.setActionForever(NetProto.Api.ENetMsgId.room_kicked_outAck); NetCore.Instance.RegisterAction(NetProto.Api.ENetMsgId.room_kicked_outAck, (kickedOutAck) => { KickedOutAck kickedOutAction = (KickedOutAck)kickedOutAck; }); // 关闭牌桌,服务进行维护时通报 NetCore.Instance.setActionForever(NetProto.Api.ENetMsgId.room_shutdown_table_ack); NetCore.Instance.RegisterAction(NetProto.Api.ENetMsgId.room_shutdown_table_ack, (roomShutdownTableAck) => { Application.LoadLevel("main"); }); // 牌桌聊天消息回复 NetCore.Instance.setActionForever(NetProto.Api.ENetMsgId.room_table_chat_ack); NetCore.Instance.RegisterAction(NetProto.Api.ENetMsgId.room_table_chat_ack, (roomTableChatAck) => { RoomTableChatAck roomTableChatAction = (RoomTableChatAck)roomTableChatAck; mChatControler.AddMessage(roomTableChatAction.Body.ToByteArray()); }); }