public void exitRoom() { buttonSound.Play(); if (isServer && players.Count > 1) { return; } DbPlayer db = new DbPlayer(); PlayerData Info = db.GetPlayerByUserName(localPlayer.playerPanel.userNameText.text); Info.Money += localPlayer.money; db.UpdatePlayer(Info); RemovePlayer(localPlayer); if (isServer) { LobbyScene.singleton.StopHost(); Destroy(LobbyScene.singleton.gameObject); return; } if (isClient) { LobbyScene.singleton.StopClient(); Destroy(localPlayer); return; } }//exit the room after saving the player new score in the data base to the lobby scene
}//a function that remove a player from the room public override void OnServerDisconnect(NetworkConnection conn) { foreach (var playerController in conn.playerControllers) { var player = playerController.gameObject.GetComponent <texasPlayer>(); playerSlots[player.playerId] = null; PlayerData playerData = db.GetPlayerByUserName(player.name); playerData.Money = player.money; db.UpdatePlayer(playerData); RoomManager.singleton.RemovePlayer(player); } base.OnServerDisconnect(conn); }//a function for the case that server disconnect
public void exitRoom() { buttonSound.Play(); DbRoom dbRoom = new DbRoom(); Room room = dbRoom.getRoomInfo(); if (isServer && players.Count > 1) { return; } DbPlayer db = new DbPlayer(); PlayerData Info = db.GetPlayerByUserName(localPlayer.playerPanel.userNameText.text); Info.Money += localPlayer.money - 1000; db.UpdatePlayer(Info); RemovePlayer(localPlayer); room.amountOfPlayers--; dbRoom.UpdateRoom(room); if (isServer) { dbRoom.deleteRoom(room); NetworkManager.singleton.StopHost(); RemovePlayer(localPlayer); //Destroy(LobbyScene.singleton.gameObject); NetworkManager.singleton.StopClient(); Destroy(localPlayer); NetworkManager.Shutdown(); //Debug.Log("after destroying the local player"); return; } if (!isServer && isClient) { RemovePlayer(localPlayer); NetworkManager.singleton.StopClient(); Destroy(localPlayer); return; } }//exit the room after saving the player new score in the data base to the lobby scene
public void ServerNextHand()//the Game restart { nextHandWaiting = true; MainPot = 0; ServerClearHands(); ServerEnterGameState(CardConstants.GameTurnState.ShufflingDeck, "Start Game", MainPot); if (localPlayer.money == 0) { DbPlayer db = new DbPlayer(); PlayerData Info = db.GetPlayerByUserName(localPlayer.playerPanel.userNameText.text); localPlayer.money += 1000; Info.Money -= 1000; db.UpdatePlayer(Info); } ServerNextState("ServerState_StartDeck"); }//stating the game after show down function