private async void OnGUI() { GUILayout.BeginVertical(GUI.skin.box); { GUILayout.Label("Debug Menu"); GUILayout.BeginHorizontal(); { GUILayout.Label("Player " + Array.IndexOf(this.clients, this.debugClient)); for (int i = 0; i < this.clients.Length; i++) { if (GUILayout.Button(i.ToString())) { this.debugClient = this.clients[i]; } } } GUILayout.EndHorizontal(); if (GUILayout.Button("Join Room")) { await this.debugClient.Room.JoinRoom(this.currentRoomId); } if (GUILayout.Button("Bet 100")) { await this.debugClient.Game.PlaceBet(this.currentRoomId, new BigInteger(100)); } if (GUILayout.Button("Start Game")) { await this.debugClient.Room.StartGame(this.currentRoomId); } if (GUILayout.Button("Leave Room")) { await this.debugClient.Room.LeaveRoom(this.currentRoomId); } if (GUILayout.Button("Hit")) { await this.debugClient.Game.PlayerDecision(this.currentRoomId, PlayerDecision.Hit); } if (GUILayout.Button("Stand")) { await this.debugClient.Game.PlayerDecision(this.currentRoomId, PlayerDecision.Stand); } if (GUILayout.Button("Update")) { await UpdateGameState(); } if (GUILayout.Button("Create room")) { await this.debugClient.Room.CreateRoom("test " + Random.Range(100, 1000)); } } GUILayout.EndVertical(); }
private async void Start() { // Load private & public key from storage, if possible const string privateKeyKey = "blackjack_privateKey"; const string publicKeyKey = "blackjack_publicKey"; byte[] privateKey; byte[] publicKey; if (PlayerPrefs.HasKey(privateKeyKey) && PlayerPrefs.HasKey(publicKeyKey)) { privateKey = CryptoUtils.HexStringToBytes(PlayerPrefs.GetString(privateKeyKey)); publicKey = CryptoUtils.HexStringToBytes(PlayerPrefs.GetString(publicKeyKey)); } else { privateKey = CryptoUtils.GeneratePrivateKey(); publicKey = CryptoUtils.PublicKeyFromPrivateKey(privateKey); PlayerPrefs.SetString(privateKeyKey, CryptoUtils.BytesToHexString(privateKey)); PlayerPrefs.SetString(publicKeyKey, CryptoUtils.BytesToHexString(publicKey)); } this.client = new BlackjackContractClient(this.BackendHost, this.ContractAbi.text, privateKey, publicKey, NullLogger.Instance); this.client.RoomCreated += ClientOnRoomCreated; this.client.PlayerJoined += ClientOnPlayerJoined; this.client.PlayerLeft += ClientOnPlayerLeft; this.client.PlayerBetted += ClientOnPlayerBetted; this.client.PlayerReadyForNextRoundChanged += ClientOnPlayerReadyForNextRoundChanged; this.client.GameStageChanged += ClientOnGameStageChanged; this.client.GameRoundResultsAnnounced += ClientOnGameRoundResultsAnnounced; this.client.CurrentPlayerIndexChanged += ClientOnCurrentPlayerIndexChanged; this.client.PlayerDecisionReceived += ClientOnPlayerDecisionReceived; await UpdateRoomList(); }
private void Start() { this.debugUIEnabled = Application.isEditor; for (int i = 0; i < this.clients.Length; i++) { byte[] privateKey = CryptoUtils.GeneratePrivateKey(); byte[] publicKey = CryptoUtils.PublicKeyFromPrivateKey(privateKey); this.clients[i] = new BlackjackContractClient(this.GameStateController.BackendHost, this.GameStateController.ContractAbi.text, privateKey, publicKey, NullLogger.Instance); } this.currentClient = this.clients[0]; }
private async void Start() { SetScreen(Screen.RoomList); for (int i = 0; i < this.clients.Length; i++) { var privateKey = CryptoUtils.GeneratePrivateKey(); var publicKey = CryptoUtils.PublicKeyFromPrivateKey(privateKey); this.clients[i] = new BlackjackContractClient(BackendHost, this.ContractAbi.text, privateKey, publicKey, Debug.unityLogger); } this.client = this.clients[0]; this.client.RoomCreated += ClientOnRoomCreated; this.client.PlayerJoined += ClientOnPlayerJoined; this.client.GameStageChanged += ClientOnGameStageChanged; this.client.CurrentPlayerIndexChanged += ClientOnCurrentPlayerIndexChanged; this.client.PlayerDecisionReceived += ClientOnPlayerDecisionReceived; this.debugClient = this.clients[1]; await RefreshRoomList(); }
public RoomObject(BlackjackContractClient client) : base(client) { }
public GameObject(BlackjackContractClient client) : base(client) { }
protected LogicObject(BlackjackContractClient client) { this.Client = client; }
public CommonObject(BlackjackContractClient client) : base(client) { }
private async void OnGUI() { if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.PageDown) { this.debugUIEnabled = !this.debugUIEnabled; } if (!this.debugUIEnabled) { return; } try { GUILayout.BeginVertical(GUI.skin.box); { GUILayout.Label("Debug Menu (PageDown)"); GUILayout.BeginHorizontal(); { GUILayout.Label("Player " + (Array.IndexOf((Array)this.clients, this.currentClient) + 1)); for (int i = 0; i < this.clients.Length; i++) { if (GUILayout.Button((i + 1).ToString())) { this.currentClient = this.clients[i]; } } } GUILayout.EndHorizontal(); if (GUILayout.Button("Join Room")) { await this.currentClient.Room.JoinRoom(this.GameStateController.GameState.RoomId); } if (GUILayout.Button("Bet 100")) { await this.currentClient.Game.PlaceBet(this.GameStateController.GameState.RoomId, new BigInteger(100)); } if (GUILayout.Button("Start Game")) { await this.currentClient.Game.StartGame(this.GameStateController.GameState.RoomId); } if (GUILayout.Button("Leave Room")) { await this.currentClient.Room.LeaveRoom(this.GameStateController.GameState.RoomId); } if (GUILayout.Button("Hit")) { await this.currentClient.Game.PlayerDecision(this.GameStateController.GameState.RoomId, PlayerDecision.Hit); } if (GUILayout.Button("Stand")) { await this.currentClient.Game.PlayerDecision(this.GameStateController.GameState.RoomId, PlayerDecision.Stand); } if (GUILayout.Button("Want next round")) { await this.currentClient.Game.SetPlayerReadyForNextRound(this.GameStateController.GameState.RoomId, true); } if (GUILayout.Button("Next round")) { await this.currentClient.Game.NextRound(this.GameStateController.GameState.RoomId); } if (GUILayout.Button("Create room")) { await this.currentClient.Room.CreateRoom("test " + Random.Range(100, 1000)); } } GUILayout.EndVertical(); } catch (ArgumentException) { } catch (NullReferenceException) { } }