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
void Awake() { dbRoom = new DbRoom(); room = dbRoom.getRoomInfo(); if (room == null) { host.interactable = true; host.enabled = true; startClient.interactable = false; } else { host.interactable = false; startClient.interactable = true; startClient.enabled = true; } }
public void setButtons() { GameObject.Find("StartHost").GetComponent <Button>().onClick.AddListener(StartUpHost); GameObject.Find("StartClient").GetComponent <Button>().onClick.AddListener(StartUpClient); dbRoom = new DbRoom(); room = dbRoom.getRoomInfo(); if (room == null) { GameObject.Find("StartHost").GetComponent <Button>().interactable = true; GameObject.Find("StartClient").GetComponent <Button>().interactable = false; } else { GameObject.Find("StartHost").GetComponent <Button>().interactable = false; GameObject.Find("StartClient").GetComponent <Button>().interactable = true; } }