void setPlayerCustomProperties(CHARACTER_CLASS newClass, TEAM newTeam) { PhotonNetwork.player.SetCustomProperties(new ExitGames.Client.Photon.Hashtable() { { RoomLevelHelper.CUSTOM_PLAYER_PROPERTY_CLASS, newClass }, { RoomLevelHelper.CUSTOM_PLAYER_PROPERTY_TEAM, newTeam }, { RoomLevelHelper.CUSTOM_PLAYER_PROPERTY_HEALTH, 0 } }); }
/// <summary> /// Select a class by interacting with UI(button for instance) /// </summary> /// <param name="newClass">New class.</param> public void SetSelectedClass(CHARACTER_CLASS newClass, TEAM team) { //todo: maybe not here, but add a feature that continuesly check if the certain character is not taken(by another player joining and selecting simultaniously). // _selectedClass = newClass; //Save the selected class RoomLevelHelper.PLAYER_CLASS = newClass; RoomLevelHelper.PLAYER_TEAM = team; setPlayerCustomProperties(newClass, team); RoomLevelHelper.SetRoomCustomPropertyPlayerClass(RoomLevelHelper.PLAYER_CLASS, false, RoomLevelHelper.PLAYER_TEAM); if ((bool)PhotonNetwork.room.CustomProperties [RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_MASTER_IN_GAME] || PhotonNetwork.isMasterClient) { //enable loading a scene since class has been selected _playButton.interactable = true; } }
void slowUpdate() { if (PhotonNetwork.isMasterClient) { // #if UNITY_EDITOR // // #else if (_game.State == GameCapturePoints.STATE.IN_PROGRESS) { //Round over check TEAM winner = roundWinnerCheck(); if (winner != TEAM.NULL) { roundOver(winner); } else if (_game.GetCurrentRound().Timer < 0f) { roundOver(TEAM.NULL); } } else if (_game.State == GameCapturePoints.STATE.ROUND_READY_WAITING) { if (!isTeamEmpty() && isTeamBalanced()) { PrepRound(); } } //update availability in lobby bool warriorAvail = true; bool tankAvail = true; bool archerAvail = true; bool warriorAvail_Team2 = true; bool tankAvail_Team2 = true; bool archerAvail_Team2 = true; foreach (PhotonPlayer pp in PhotonNetwork.playerList) { CHARACTER_CLASS c = (CHARACTER_CLASS)pp.CustomProperties [RoomLevelHelper.CUSTOM_PLAYER_PROPERTY_CLASS]; TEAM t = (TEAM)pp.CustomProperties [RoomLevelHelper.CUSTOM_PLAYER_PROPERTY_TEAM]; switch (c) { case CHARACTER_CLASS.ARCHER: if (t == TEAM.ONE) { archerAvail = false; } else { archerAvail_Team2 = false; } break; case CHARACTER_CLASS.WARRIOR: if (t == TEAM.ONE) { warriorAvail = false; } else { warriorAvail_Team2 = false; } break; case CHARACTER_CLASS.TANK: if (t == TEAM.ONE) { tankAvail = false; } else { tankAvail_Team2 = false; } break; default: break; } } PhotonNetwork.room.SetCustomProperties(new ExitGames.Client.Photon.Hashtable() { { RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_WARRIOR_AVAILABLE, warriorAvail }, { RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_TANK_AVAILABLE, tankAvail }, { RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_ARCHER_AVAILABLE, archerAvail }, { RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_WARRIOR_AVAILABLE_TEAM_2, warriorAvail_Team2 }, { RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_TANK_AVAILABLE_TEAM_2, tankAvail_Team2 }, { RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_ARCHER_AVAILABLE_TEAM_2, archerAvail_Team2 }, }); // #endif } else { if (_game.State == GameCapturePoints.STATE.NOT_STARTED) { UIController.SINGLETON.MasterGameControlText.text = "Waiting for host to start..."; UIController.SINGLETON.MasterGameControlText.gameObject.SetActive(true); } else if (_game.State == GameCapturePoints.STATE.ROUND_READY_WAITING) { UIController.SINGLETON.MasterGameControlText.text = "Waiting for players..."; UIController.SINGLETON.MasterGameControlText.gameObject.SetActive(true); } else { UIController.SINGLETON.MasterGameControlText.text = ""; UIController.SINGLETON.MasterGameControlText.gameObject.SetActive(false); } } }
/// <summary> /// Sets custom property that represent usage of certain class /// </summary> /// <param name="myClass">My class.</param> /// <param name="InUse">If set to <c>true</c> in use.</param> public static void SetRoomCustomPropertyPlayerClass(CHARACTER_CLASS myClass, bool available, TEAM team = TEAM.ONE) { //must be connected(in a room) if (PhotonNetwork.room == null) { Debug.LogWarning("WARNING : Must be in a room to chagne custom properties"); return; } if (team == TEAM.ONE) { switch (myClass) { case CHARACTER_CLASS.WARRIOR: PhotonNetwork.room.SetCustomProperties(new ExitGames.Client.Photon.Hashtable() { { RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_WARRIOR_AVAILABLE, available } }); break; case CHARACTER_CLASS.TANK: PhotonNetwork.room.SetCustomProperties(new ExitGames.Client.Photon.Hashtable() { { RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_TANK_AVAILABLE, available } }); break; case CHARACTER_CLASS.ARCHER: PhotonNetwork.room.SetCustomProperties(new ExitGames.Client.Photon.Hashtable() { { RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_ARCHER_AVAILABLE, available } }); break; default: Debug.LogWarning("WARNING : CLASS BUTTON WITH UNKNOWN CLASS"); break; } } else if (team == TEAM.TWO) { switch (myClass) { case CHARACTER_CLASS.WARRIOR: PhotonNetwork.room.SetCustomProperties(new ExitGames.Client.Photon.Hashtable() { { RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_WARRIOR_AVAILABLE_TEAM_2, available } }); break; case CHARACTER_CLASS.TANK: PhotonNetwork.room.SetCustomProperties(new ExitGames.Client.Photon.Hashtable() { { RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_TANK_AVAILABLE_TEAM_2, available } }); break; case CHARACTER_CLASS.ARCHER: PhotonNetwork.room.SetCustomProperties(new ExitGames.Client.Photon.Hashtable() { { RoomLevelHelper.CUSTOM_ROOM_PROPERTY_IS_ARCHER_AVAILABLE_TEAM_2, available } }); break; default: Debug.LogWarning("WARNING : CLASS BUTTON WITH UNKNOWN CLASS"); break; } } else { Debug.LogWarning("WARNING : This team is not used for players"); } }