void AddScore_RPC(string fragger, string fragged) { //If I'm the killer, add to my frags, call AddMessage and say how many opponents I've defeated if(fragger == playerMe) { PhotonHashtable PlayerCustomProps = new PhotonHashtable(); PlayerCustomProps["kills"] = ((playerFrag + 1).ToString()); PhotonNetwork.player.SetCustomProperties(PlayerCustomProps); playerFrag = (float.Parse(PlayerCustomProps["kills"].ToString())); AddMessage (fragger + " has defeated " + playerFrag + " opponents."); } if(fragged == playerMe) { PhotonHashtable PlayerCustomProps = new PhotonHashtable(); PlayerCustomProps["Deaths"] = ((playerDeath + 1).ToString()); PhotonNetwork.player.SetCustomProperties(PlayerCustomProps); playerDeath = (float.Parse(PlayerCustomProps["Deaths"].ToString())); AddMessage (fragged + " has perished " + playerDeath + " times."); } scoreManager.ChangeScore(fragger, "kills", 1); scoreManager.ChangeScore(fragged, "deaths", 1); }
public void SettingPropiertis() { //Initialize new properties where the information will stay Room if (PhotonNetwork.isMasterClient) { Hashtable setTeamScore = new Hashtable(); setTeamScore.Add(PropiertiesKeys.Team1Score, 0); PhotonNetwork.room.SetCustomProperties(setTeamScore); Hashtable setTeam2Score = new Hashtable(); setTeam2Score.Add(PropiertiesKeys.Team2Score, 0); PhotonNetwork.room.SetCustomProperties(setTeam2Score); } //Initialize new properties where the information will stay Players Hashtable PlayerTeam = new Hashtable(); PlayerTeam.Add(PropiertiesKeys.TeamKey, Team.All.ToString()); PhotonNetwork.player.SetCustomProperties(PlayerTeam); Hashtable PlayerKills = new Hashtable(); PlayerKills.Add(PropiertiesKeys.KillsKey, 0); PhotonNetwork.player.SetCustomProperties(PlayerKills); Hashtable PlayerDeaths = new Hashtable(); PlayerDeaths.Add(PropiertiesKeys.DeathsKey, 0); PhotonNetwork.player.SetCustomProperties(PlayerDeaths); Hashtable PlayerScore = new Hashtable(); PlayerScore.Add(PropiertiesKeys.ScoreKey, 0); PhotonNetwork.player.SetCustomProperties(PlayerScore); Hashtable PlayerPing = new Hashtable(); PlayerPing.Add("Ping", 0); PhotonNetwork.player.SetCustomProperties(PlayerPing); }
/// <summary> /// This method is storing PhotonNetwork.time in the rooms custom properties /// Since PhotonNetwork.time is synchronized between all players, we can use this to /// share time information between all players /// </summary> protected void SetRoundStartTime() { ExitGames.Client.Photon.Hashtable newProperties = new ExitGames.Client.Photon.Hashtable(); newProperties.Add( RoomProperty.StartTime, PhotonNetwork.time ); PhotonNetwork.room.SetCustomProperties( newProperties ); }
public override Hashtable Encode() { Hashtable hash = new Hashtable(); Hashtable decksHash = new Hashtable(); foreach (NWPlayerDeckDataObject deck in PlayersDecks) { Hashtable deckData = deck.Encode(); string playerId = deckData[ePlayerDeckDataObjectKeys.PlayerId].ToString(); decksHash.Add(playerId, (Hashtable)deckData[ePlayerDeckDataObjectKeys.DeckCards]); } Hashtable[] zonesHash = new Hashtable[PlayersZones.Count]; for (int i = 0; i< PlayersZones.Count; i++) { zonesHash[i] = PlayersZones[i].Encode(); } hash.Add(eGameSetupKeys.Decks.ToString(), decksHash); hash.Add(eGameSetupKeys.PlayersZones.ToString(), zonesHash); Debug.Log( ">>>> " + Utils.HashToString(hash)); return hash; }
public static void SetKill(this PhotonPlayer player, int newKill) { Hashtable hkill = new Hashtable(); // using PUN's implementation of Hashtable hkill[PlayerKill.PlayerKillProp] = newKill; player.SetCustomProperties(hkill); // this locally sets the score and will sync it in-game asap. }
public Hashtable Encode() { Hashtable hash = new Hashtable(); hash.Add((int)eServerActionKey.ActionType, ActionType); hash.Add((int)eServerActionKey.ActionParams, ActionsParams); return hash; }
private void TABGUI () { ExitGames.Client.Photon.Hashtable props = new ExitGames.Client.Photon.Hashtable(); props.Add("Team", 1); props.Add("Score", 0); props.Add("Kills", Kills); props.Add("death", 666); PhotonNetwork.player.SetCustomProperties(props); // Spieler Scores Human foreach (PhotonPlayer player in PhotonNetwork.playerList) { HumanStatsCanvas.GetComponent<Text>().text = "Team: " + player.customProperties["Team"].ToString() + " | Score: " + player.customProperties["Score"].ToString() + " | Kills: " + player.customProperties["Kills"].ToString() + " | Deaths: " + player.customProperties["death"].ToString() + " | Ping: " + PhotonNetwork.networkingPeer.RoundTripTime.ToString(); } // Spieler Scores Alien AlienStatsCanvas.GetComponent<Text>().text = "Team: " + PhotonNetwork.player.customProperties["Team"].ToString() + " | Score: " + PhotonNetwork.player.customProperties["Score"].ToString() + " | Kills: " + PhotonNetwork.player.customProperties["Kills"].ToString() + " | Deaths: " + PhotonNetwork.player.customProperties["death"].ToString() + " | Ping: " + PhotonNetwork.networkingPeer.RoundTripTime.ToString(); }
public static void SetScore(this PhotonPlayer player, int newScore) { Hashtable score = new Hashtable(); // using PUN's implementation of Hashtable score[PunPlayerScores.PlayerScoreProp] = newScore; player.SetCustomProperties(score); // this locally sets the score and will sync it in-game asap. }
public override void OnEnter() { string _roomName = null; if ( ! string.IsNullOrEmpty(roomName.Value) ) { _roomName = roomName.Value; } ExitGames.Client.Photon.Hashtable _props = new ExitGames.Client.Photon.Hashtable(); int i = 0; foreach(FsmString _prop in customPropertyKey) { _props[_prop.Value] = PlayMakerPhotonProxy.GetValueFromFsmVar(this.Fsm,customPropertyValue[i]); i++; } string[] lobbyProps = new string[lobbyCustomProperties.Length]; int j = 0; foreach(FsmString _visibleProp in lobbyCustomProperties) { lobbyProps[j] = _visibleProp.Value; j++; } PhotonNetwork.CreateRoom(_roomName,isVisible.Value,isOpen.Value,maxNumberOfPLayers.Value,_props,lobbyProps); Finish(); }
public void SetGameEndTime() { if (PhotonNetwork.isMasterClient) { ExitGames.Client.Photon.Hashtable endTime = new ExitGames.Client.Photon.Hashtable (); endTime.Add (RoomPropertyType.EndTime, PhotonNetwork.time + timeAfterLastCandy); PhotonNetwork.room.SetCustomProperties (endTime); } }
public override Hashtable Encode() { Hashtable hash = new Hashtable(); hash.Add((int)eZoneDataKeys.PlayerId, PlayerId); hash.Add((int)eZoneDataKeys.ZoneType, (int)ZoneType); hash.Add((int)eZoneDataKeys.ZoneId, ZoneId); return hash; }
/// <summary> /// Internally used to create players from event Join /// </summary> protected internal PhotonPlayer(bool isLocal, int actorID, Hashtable properties) { this.customProperties = new Hashtable(); this.isLocal = isLocal; this.actorID = actorID; this.InternalCacheProperties(properties); }
void OnJoinedRoom() { PhotonHashtable table = new PhotonHashtable(); // 변수만드는 부분 table.Add("aimKill", aimKill); PhotonNetwork.room.SetCustomProperties(table); PhotonNetwork.isMessageQueueRunning = false; PhotonNetwork.LoadLevel("Field"); //씬 로딩 }
public virtual void OnPhotonRandomJoinFailed() { Debug.Log("OnPhotonRandomJoinFailed() was called by PUN. No random room available, so we create one. Calling: PhotonNetwork.CreateRoom(null, new RoomOptions() {maxPlayers = 4}, null);"); Hashtable customRoomProperties = new Hashtable() { {"map", 1}, {"started", false} }; PhotonNetwork.CreateRoom(null, true, true, 6, customRoomProperties, roomPropsInLobby); Debug.Log (customRoomProperties ["map"]); setPlayerProperties (); PhotonNetwork.LoadLevel ((int)customRoomProperties["map"]); }
void Start() { // 初期配置ゲームオブジェクトの親オブジェクトを取得 unitPlaceBeforeBattleParentGO = this.transform.FindChild("Parent").gameObject; // ルームCP取得 roomCP = PhotonNetwork.room.customProperties; if (null == roomCP) Debug.Log("ルームCPを取得できません@StartUpActiveManager.cs"); return; }
PhotonHashtable InitRoomSettings() { //set the table with players and their charactes customSettings = new PhotonHashtable (); foreach (string name in playerPrefabs) { customSettings.Add (name, false); } return customSettings; }
public static PlayerAction GetActionFromProps(Hashtable ht) { Actions act = (Actions)ht["Act"]; int iChId = (int)ht["iCharacter"]; int iChTeam = (int)ht["iCharacterTeam"]; Cell tcell = Grid_Setup.Instance.GetCellByID((int)ht["tCell"]); Cell fcell = Grid_Setup.Instance.GetCellByID((int)ht["fCell"]); return new PlayerAction(act,MainGame.Instance.GetCharacter(iChTeam,iChId),tcell, fcell); }
//Создание комноты (+) public void CreateNewRoom() { ExitGames.Client.Photon.Hashtable customProps = new ExitGames.Client.Photon.Hashtable(); customProps["MapName"] = "kaspi_map_c_2_test"; string[] exposedProps = new string[customProps.Count]; exposedProps[0] = "MapName"; PhotonNetwork.CreateRoom(newRoomName, true, true, newRoomMaxPlayers, customProps, exposedProps); }
void Awake() { PhotonNetwork.ConnectUsingSettings (version); playerPropertyHashtable = new ExitGames.Client.Photon.Hashtable (); roomPropertyHashtable = new ExitGames.Client.Photon.Hashtable (); #if UNITY_ANDROID androidJavaClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); currentActivity = androidJavaClass.GetStatic<AndroidJavaObject>("currentActivity"); #endif }
public static void AddDeath(this PhotonPlayer player, int deathToAddToCurrent) { int current = player.GetDeath(); current = current + deathToAddToCurrent; Hashtable hdeath = new Hashtable(); // using PUN's implementation of Hashtable hdeath[PlayerDeath.PlayerDeathProp] = current; player.SetCustomProperties(hdeath); // this locally sets the score and will sync it in-game asap. }
/// <summary> /// Creates the room. /// </summary> /// <param name="roomName">Room name.</param> public void CreateRoom( string roomName, int mapIndex, int maxPlayer ) { ExitGames.Client.Photon.Hashtable toSet = new ExitGames.Client.Photon.Hashtable(); toSet.Add("index", mapIndex); string[] forLobby = new string[1]; forLobby[0] = "index"; PhotonNetwork.CreateRoom ( roomName, true, true, maxPlayer, toSet, forLobby); }
public void UpdatePlayerScore(int playerIndex, int scoreIncrement) { thisPlayersScore = thisPlayersScore + scoreIncrement; photonView.RPC ("UpdatePlayerScore_RPC", PhotonTargets.AllBuffered, playerIndex, thisPlayersScore); ExitGames.Client.Photon.Hashtable playerScore = new ExitGames.Client.Photon.Hashtable (); playerScore.Add (RoomPropertyType.PlayerScores [playerIndex], thisPlayersScore); PhotonNetwork.room.SetCustomProperties (playerScore); }
public static void AddScore(this PhotonPlayer player, int scoreToAddToCurrent) { int current = player.GetScore(); current = current + scoreToAddToCurrent; Hashtable score = new Hashtable(); // using PUN's implementation of Hashtable score[PunPlayerScores.PlayerScoreProp] = current; player.SetCustomProperties(score); // this locally sets the score and will sync it in-game asap. }
// Use this for initialization void Start () { PhotonNetwork.JoinRoom(PlayerPrefs.GetString("Room")); props = new ExitGames.Client.Photon.Hashtable(); props.Add("Pseudo", pseudo); width = 100; height = 100; }
public static void PostKill(this PhotonPlayer p, int kills) { int current = p.GetKills(); current = current + kills; Hashtable score = new Hashtable(); // using PUN's implementation of Hashtable score[PropiertiesKeys.KillsKey] = current; p.SetCustomProperties(score); // this locally sets the score and will sync it in-game asap. }
public static void PostScore(this PhotonPlayer player, int ScoreToAdd = 0) { int current = player.GetPlayerScore(); current = current + ScoreToAdd; Hashtable score = new Hashtable(); // using PUN's implementation of Hashtable score[PropiertiesKeys.ScoreKey] = current; player.SetCustomProperties(score); // this locally sets the score and will sync it in-game asap. }
public override void Decode(Hashtable data) { Cards = new List<NWCardDataObject>(); PlayerId = int.Parse(data[ePlayerDeckDataObjectKeys.PlayerId].ToString()); Hashtable deckData = (Hashtable)data[ePlayerDeckDataObjectKeys.DeckCards]; foreach (int cardKey in deckData.Keys) { NWCardDataObject card = new NWCardDataObject(cardKey, int.Parse(deckData[cardKey].ToString())); Cards.Add(card); } }
// Use this for initialization void Start () { photonView = GetComponent<PhotonView> (); messages = new Queue<string> (messageCount); // queue capacity passed as parameter customPlayerPrefs = new ExitGames.Client.Photon.Hashtable(); customRoomPrefs = new ExitGames.Client.Photon.Hashtable(); //PhotonNetwork.logLevel = PhotonLogLevel.Full; // verbose logging for debuggin purposes PhotonNetwork.ConnectUsingSettings ("0.1"); // takes version number as argument, developer set - stops users from playing the same game but different version StartCoroutine ("UpdateConnectionString"); }
/// <summary> /// 玩家屬性已更新 /// </summary> /// <param name="targetPlayer"></param> /// <param name="changedProps"></param> public override void OnPlayerPropertiesUpdate(Player targetPlayer, ExitGames.Client.Photon.Hashtable changedProps) { string strtargetPlayer = string.Format( "ActorNumber:{0}, \n" + "IsLocal:{1}, \n" + "HasRejoined:{2}, \n" + "NickName:{3}, \n" + "UserId{4}, \n" + "IsMasterClient:{5}, \n" + "IsInactive:{6}, \n" + "CustomProperties:{7}, \n" + "TagObject:{8}, \n" + "ToStringFull():{9}", targetPlayer.ActorNumber, targetPlayer.IsLocal, targetPlayer.HasRejoined, targetPlayer.NickName, targetPlayer.UserId, targetPlayer.IsMasterClient, targetPlayer.IsInactive, targetPlayer.CustomProperties, targetPlayer.TagObject, targetPlayer.ToStringFull() ); string strchangedProps = ""; foreach (var item in changedProps) { strchangedProps += string.Format("Key:{0}, Value:{1},\n", item.Key, item.Value); } Debug.Log(string.Format("Photon.Realtime.IInRoomCallbacks - OnPlayerPropertiesUpdate()<玩家屬性已更新 - \n" + "targetPlayer:{0},\n" + "changedProps:{1}>", strtargetPlayer, strchangedProps)); }
public override void OnJoinedLobby() { PhotonPlayer player = PhotonNetwork.player; ExitGames.Client.Photon.Hashtable properties = new ExitGames.Client.Photon.Hashtable(); properties[PlayerStateContainer.TEAM_SELECTION] = PlayerStateContainer.Instance.TeamSelection; PlayerStateContainer.Instance.IsReady = PlayerStateContainer.STATUS_NOT_READY; properties[PlayerStateContainer.IS_READY] = PlayerStateContainer.Instance.IsReady; player.SetCustomProperties(properties); if (isPrivate) { RoomOptions options = new RoomOptions(); options.IsOpen = true; options.IsVisible = false; options.MaxPlayers = 0; options.PublishUserId = true; options.CustomRoomPropertiesForLobby = new string[] { "C0", "C1" }; options.CustomRoomProperties = new ExitGames.Client.Photon.Hashtable() { { "C0", 1 }, { "C1", 1 } }; PhotonNetwork.JoinOrCreateRoom(lobbyName, options, new TypedLobby(Constants.LOBBY_NAME, LobbyType.SqlLobby)); } else if (PlayerStateContainer.Instance.TeamSelection == PlayerStateContainer.EXPLORER) { string filter = "C0 = 1"; PhotonNetwork.JoinRandomRoom(null, 0, MatchmakingMode.FillRoom, new TypedLobby(Constants.LOBBY_NAME, LobbyType.SqlLobby), filter); } else if (PlayerStateContainer.Instance.TeamSelection == PlayerStateContainer.NIGHTMARE) { string filter = "C1 = 1"; PhotonNetwork.JoinRandomRoom(null, 0, MatchmakingMode.FillRoom, new TypedLobby(Constants.LOBBY_NAME, LobbyType.SqlLobby), filter); } else { PhotonNetwork.JoinRandomRoom(); } }
void Start() { isGameOver = false; int tempPosition = Random.Range(0, spawnPlayer.Length); GameObject playerTemp = PhotonNetwork.Instantiate(myPlayer.name, spawnPlayer[tempPosition].position, spawnPlayer[tempPosition].rotation, 0) as GameObject; //Iniciando Countdownendgame if (playerTemp.GetComponent <PhotonView>().Owner.IsMasterClient) { ExitGames.Client.Photon.Hashtable myProps = new ExitGames.Client.Photon.Hashtable { { CountdownEndGame.CountdownStartTime, (float)PhotonNetwork.Time } }; PhotonNetwork.CurrentRoom.SetCustomProperties(myProps); } CheckPlayers(); if (canvasCountdown && !canvasCountdown.gameObject.activeInHierarchy) { canvasCountdown.gameObject.SetActive(true); } } //Start
public override void MatchBegan(PlayerViewModel viewModel) { base.MatchBegan(viewModel); viewModel.HandCards.Clear(); Hashtable ht = new Hashtable(); ht.Add("is_ready", false); Publish(new NetSetPlayerProperties() { ActorId = viewModel.ActorId, PropertiesToSet = ht }); string hand_cards_str = Convert.ToString(viewModel.LBPlayer.CustomProperties ["hand_cards"]); List <CardInfo> card_info_list = JsonConvert.DeserializeObject <List <CardInfo> > (hand_cards_str); viewModel.Execute(new AddCardsCommand() { CardInfos = card_info_list }); }
/// <summary> /// @brief 自身が部屋に入ることに成功したらシーンを移動させる /// </summary> public override void OnJoinedRoom() { //一番初めに入った場合、カスタムプロパティにスタートまでの時間をセットする if (PhotonNetwork.CurrentRoom.PlayerCount == 1) { //GameStartCountというプロパティに設定 var properties = new ExitGames.Client.Photon.Hashtable { { RoomPropertyKey.InRoomLimitTime, PhotonNetwork.Time } }; PhotonNetwork.CurrentRoom.SetCustomProperties(properties); } Debug.Log("制限時間をセットしました"); //メッセージ処理の実行を一時停止 PhotonNetwork.IsMessageQueueRunning = false; //シーンを移動させる SceneSwitch(SceneNameString.MatchingRoom); Debug.Log("部屋の入室に成功しました"); }
public Hashtable SerializeAttachments() { if (characterAttachments == null) { #if UNITY_EDITOR Debug.LogWarning("Character Attachments has not been initialized yet.", gameObject); #endif return(new Hashtable()); } Hashtable atts = new Hashtable(characterAttachments.attachments.Count); foreach (var att in characterAttachments.attachments) { List <CharacterAttachments.Attachment> attachments = att.Value; HumanBodyBones bone = att.Key; Hashtable atts2 = new Hashtable(attachments.Count); for (int i = 0; i < attachments.Count; i++) { var attachment = attachments[i]; string key = attachment.prefab.name;// + attachment.prefab.GetInstanceID(); if (!atts2.ContainsKey(key)) { //GameObject go = attachments[i].prefab; //Transform tr = go.transform; //atts2.Add(go.name.Replace(CLONE, string.Empty), string.Format(ATTACHMENT_FORMAT, attachment.locPosition, attachment.locRotation)); atts2.Add(attachment.prefab.name, string.Format(ATTACHMENT_FORMAT, attachment.locPosition, attachment.locRotation)); } } atts.Add((int)bone, atts2); } return(atts); }
private void HandleSyncSceneEvent(ExitGames.Client.Photon.Hashtable eventData) { int targetPlayerID = (int)eventData[(byte)0]; if (PhotonNetwork.player.ID == targetPlayerID) { string prefabName = (string)eventData[(byte)1]; Vector3 position = Vector3.zero; Vector3 scale = Vector3.one; if (eventData.ContainsKey((byte)2)) { position = (Vector3)eventData[(byte)2]; } Quaternion rotation = Quaternion.identity; if (eventData.ContainsKey((byte)3)) { rotation = (Quaternion)eventData[(byte)3]; } scale = (Vector3)eventData[(byte)4]; int[] viewIDs = (int[])eventData[(byte)5]; if (eventData.ContainsKey((byte)6)) { uint currentLevelPrefix = (uint)eventData[(byte)6]; } int serverTimeStamp = (int)eventData[(byte)7]; int instantiationID = (int)eventData[(byte)8]; GameObject go = InstantiateLocally(prefabName, viewIDs, position, rotation, scale); OwnableObject ownershipManager = go.GetComponent <OwnableObject>(); bool isOwnershipRestricted = (bool)eventData[(byte)9]; int[] whiteListIDs = (int[])eventData[(byte)10]; ownershipManager.SetRestrictions(isOwnershipRestricted, whiteListIDs); } }
private void HandleSyncObjectOwnershipRestriction(ExitGames.Client.Photon.Hashtable eventData) { string objectName = (string)eventData[(byte)0]; int viewID = (int)eventData[(byte)1]; bool restricted = (bool)eventData[(byte)2]; int[] ownableIDs = (int[])eventData[(byte)3]; int serverTimeStamp = (int)eventData[(byte)4]; //UnityEngine.Debug.Log("restricted = " + ((restricted) ? "true" : "false")); GameObject[] objs = GameObject.FindObjectsOfType <GameObject>(); GameObject go = null; foreach (GameObject obj in objs) { if (obj.name.Equals(objectName)) { PhotonView pv = obj.GetComponent <PhotonView>(); if (pv == null) { continue; } else if (pv.viewID == viewID) { go = obj; break; } } } if (go != null) { OwnableObject ownershipManager = go.GetComponent <OwnableObject>(); ownershipManager.SetRestrictions(restricted, ownableIDs); } }
// Call back if another player leaves the room public override void OnPlayerLeftRoom(Player otherPlayer) { Debug.Log($"{otherPlayer.NickName} has left the room"); _roomNameText.text = PhotonNetwork.CurrentRoom.Name; _playerCountText.text = $"Player Count {PhotonNetwork.CurrentRoom.PlayerCount} / {PhotonNetwork.CurrentRoom.MaxPlayers}"; if (_playerList.ContainsKey(otherPlayer.ActorNumber)) { Destroy(_playerList[otherPlayer.ActorNumber].gameObject); _playerList.Remove(otherPlayer.ActorNumber); } //************************************************************\\ // Loop through each player and reassign player number \\ //************************************************************\\ int playerCounter = 1; if (PhotonNetwork.CurrentRoom.CustomProperties.ContainsKey(NetworkCustomSettings.GAME_MODE)) { foreach (Player player in PhotonNetwork.PlayerList) { ExitGames.Client.Photon.Hashtable playerNumberProperty = new ExitGames.Client.Photon.Hashtable() { { NetworkCustomSettings.PLAYER_NUMBER, playerCounter } }; player.SetCustomProperties(playerNumberProperty); ExitGames.Client.Photon.Hashtable actorNumberProperty = new ExitGames.Client.Photon.Hashtable() { { NetworkCustomSettings.ACTOR_NUMBER, player.ActorNumber } }; player.SetCustomProperties(actorNumberProperty); playerCounter++; } _startButton.SetActive(CheckPlayersReady()); } }
//Ao entrar em uma sala public override void OnJoinedRoom() { print("Jogador entrou em uma sala"); print("Nome da sala: " + PhotonNetwork.CurrentRoom.Name); //Nome da sala print("Número de jogadores na sala: " + PhotonNetwork.CurrentRoom.PlayerCount); //quantidade de jogadores na sala loginUI.gameObject.SetActive(false); partidasUI.gameObject.SetActive(false); object typeGameValue; if (PhotonNetwork.CurrentRoom.CustomProperties.TryGetValue(gameModeKey, out typeGameValue)) { print("GameMode: " + typeGameValue.ToString()); //print("GameMode: " + (string)typeGameValue); } foreach (var item in PhotonNetwork.PlayerList) //Lista de informações do player ao entrar na sala { print("Name: " + item.NickName); print("IsMaster? : " + item.IsMasterClient); //Customizando o player - Atribuindo valores aos mesmos Hastable playerCustom = new Hastable(); playerCustom.Add("Lives", 3); playerCustom.Add("Score", 0); item.SetCustomProperties(playerCustom, null, null); item.SetScore(0); } //GameObject playerTemp = Instantiate(myPlayer, transform.position, transform.rotation) as GameObject; PhotonNetwork.Instantiate(myPlayer.name, transform.position, transform.rotation, 0); //Instanciando jogador no multiplayer //PhotonNetwork.LoadLevel(1); }
private void LockMerchant(string clientID, string merchantname) { SoundManager.Ins.Play(AudioClipEnum.CardDraw); var merchantPrefab = listInstantMerchant.Find(x => x.Name == merchantname); var playerCard = playerCards.Find(x => x.GetClientID() == clientID); var _merchant = Instantiate(merchantPrefab, playerCard.transform); _merchant.Init(); _merchant.gameObject.SetActive(false); playerCard.SetInfo(_merchant); if (PhotonNetwork.IsMasterClient) { // Set player properties for choosen merchant Photon.Realtime.Player player = PhotonNetwork.PlayerList.First(x => x.UserId == clientID); ExitGames.Client.Photon.Hashtable merchantProperties = new ExitGames.Client.Photon.Hashtable(); merchantProperties.Add("merchantType", (int)(merchantPrefab.TagName)); player.SetCustomProperties(merchantProperties); currentTurnPlayerIndex++; if (currentTurnPlayerIndex < listPlayer.Count) { string nextClientID = listPlayer[currentTurnPlayerIndex].UserId; photonView.RPC("BeginTurn", RpcTarget.AllBufferedViaServer, nextClientID); } else { photonView.RPC("MoveToPlayScene", RpcTarget.AllBufferedViaServer); photonView.RPC("BeginTurn", RpcTarget.AllBufferedViaServer, "-1"); } } }
// NetworkingPeer.OnEvent (Code 202) public static bool IsInstantiatePacketValid(ExitGames.Client.Photon.Hashtable evData, PhotonPlayer sender) { if (evData == null || (!evData.ContainsKey((byte)0) || !(evData[(byte)0] is string)) || (evData.ContainsKey((byte)1) && !(evData[(byte)1] is Vector3)) || (evData.ContainsKey((byte)2) && !(evData[(byte)2] is Quaternion)) || (evData.ContainsKey((byte)3) && !(evData[(byte)3] is int)) || (evData.ContainsKey((byte)4) && !(evData[(byte)4] is int[])) || (evData.ContainsKey((byte)5) && !(evData[(byte)5] is object[])) || !evData.ContainsKey((byte)6) || !evData.ContainsKey((byte)7) || (evData.ContainsKey((byte)8) && !(evData[(byte)8] is short))) { Mod.Logger.Error($"E(202) Malformed instantiate from #{(sender == null ? "?" : sender.Id.ToString())}."); if (sender != null && !FengGameManagerMKII.IgnoreList.Contains(sender.Id)) { FengGameManagerMKII.IgnoreList.Add(sender.Id); } return(false); } return(true); }
//ルームプロパティが変更されたときに呼ばれる public override void OnRoomPropertiesUpdate(ExitGames.Client.Photon.Hashtable propertiesThatChanged) { object value = null; if (propertiesThatChanged.TryGetValue("HP1", out value)) { Debug.Log("Link HP1"); nowHP1 = (int)value; } if (propertiesThatChanged.TryGetValue("HP2", out value)) { Debug.Log("Link HP2"); nowHP2 = (int)value; } /* * if (propertiesThatChanged.TryGetValue("BM1", out value)) * { * Debug.Log("Link BlackMap1"); * BlackMap1 = (int[,])value; * if(PhotonScriptor.ConnectingScript.informPlayerID()==2) * { * GetReady = true; * } * } * if (propertiesThatChanged.TryGetValue("BM2", out value)) * { * Debug.Log("Link BlackMap2"); * BlackMap2 = (int[,])value; * if (PhotonScriptor.ConnectingScript.informPlayerID() == 1) * { * GetReady = true; * } * } */ }
public override void OnEnter() { string _roomName = null; if (!string.IsNullOrEmpty(roomName.Value)) { _roomName = roomName.Value; } ExitGames.Client.Photon.Hashtable _props = new ExitGames.Client.Photon.Hashtable(); int i = 0; foreach (FsmString _prop in customPropertyKey) { _props[_prop.Value] = PlayMakerPhotonProxy.GetValueFromFsmVar(this.Fsm, customPropertyValue[i]); i++; } string[] lobbyProps = new string[lobbyCustomProperties.Length]; int j = 0; foreach (FsmString _visibleProp in lobbyCustomProperties) { lobbyProps[j] = _visibleProp.Value; j++; } PhotonNetwork.CreateRoom(_roomName, isVisible.Value, isOpen.Value, maxNumberOfPLayers.Value, _props, lobbyProps); Finish(); }
public static void EnterWorld( Game game, string worldName, string username, Hashtable properties, Vector position, Vector rotation, Vector viewDistanceEnter, Vector viewDistanceExit) { var data = new Dictionary <byte, object> { { (byte)ParameterCode.WorldName, worldName }, { (byte)ParameterCode.Username, username }, { (byte)ParameterCode.Position, position }, { (byte)ParameterCode.ViewDistanceEnter, viewDistanceEnter }, { (byte)ParameterCode.ViewDistanceExit, viewDistanceExit } }; if (properties != null) { data.Add((byte)ParameterCode.Properties, properties); } if (!rotation.IsZero) { data.Add((byte)ParameterCode.Rotation, rotation); } game.SendOperation(OperationCode.EnterWorld, data, true, Settings.OperationChannel); }
public override void OnPlayerPropertiesUpdate(Player targetPlayer, Hashtable propertiesThatChanged) { if (propertiesThatChanged.ContainsKey("PMove") && targetPlayer == PhotonNetwork.LocalPlayer) { PlayerMoveType playerMove = targetPlayer.GetPlayerMove(); switch (playerMove) { case PlayerMoveType.Build: case PlayerMoveType.Selecting: BuildButton.SetActive(false); WorkButton.SetActive(false); CancelButton.SetActive(false); break; case PlayerMoveType.Work: case PlayerMoveType.BuildPosSelecting: BuildButton.SetActive(false); WorkButton.SetActive(false); CancelButton.SetActive(true); break; case PlayerMoveType.None: BuildButton.SetActive(true); WorkButton.SetActive(true); CancelButton.SetActive(false); break; case PlayerMoveType.NonTurn: BuildButton.SetActive(false); WorkButton.SetActive(false); CancelButton.SetActive(false); GameObject.Find("TurnManager").GetComponent <TurnAndRoundManager>().TurnEnd(); break; } } }
private void StartGame() { TurnSystemManager.sharedInstance.SetTurnInit(); //sistema de turno iniciar //Comienzo del cronometro Hashtable props = new Hashtable { { CronometerTimer.CronometerStartTime, (float)PhotonNetwork.Time } }; PhotonNetwork.CurrentRoom.SetCustomProperties(props); if (optionR_Time > 0) { //Comienzo del tiempo por ronda Hashtable props2 = new Hashtable { { RoundCountdownTimer.CountdownStartTime, (float)PhotonNetwork.Time } }; PhotonNetwork.CurrentRoom.SetCustomProperties(props2); } }
//void IPunCallbacks.OnPhotonMaxCccuReached(){} void IPunCallbacks.OnPhotonCustomRoomPropertiesChanged(ExitGames.Client.Photon.Hashtable propertiesThatChanged) { }
public static List <string> GetMods(PhotonPlayer player) { ExitGames.Client.Photon.Hashtable properties = player.customProperties; List <string> mods = new List <string>(); // Neko if (player.isNeko) { string userType = "[ffffff]"; if (player.isNekoUser) { userType += "(User)"; } if (player.isNekoOwner) { userType += "(Owner)"; } mods.Add($"[ee00ee][Neko{userType}]"); } // Fox if (player.isFoxMod) { mods.Add("[ff6600][Fox]"); } // Cyrus Essentials if (player.isCyrus) { mods.Add("[ffff00][CE]"); } // Anarchy if (player.isAnarchy) { mods.Add("[ffffff][Anarchy]"); } // KnK if (player.isKnK) { mods.Add("[ff0000][KnK]"); } // NRC if (player.isNRC) { mods.Add("[ffffff][NRC]"); } // TRAP if (player.isTrap) { mods.Add("[ee66ff][TRAP]"); } // RC83 if (player.isRC83) { mods.Add("[ffffff][RC83]"); } // Guardian (mine!!) if (properties.ContainsKey("GuardianMod") && properties["GuardianMod"] is int) { mods.Add($"[0099ff][Guardian]"); } if ((properties.ContainsKey("A.S Guard") && properties["A.S Guard"] is int) || (properties.ContainsKey("Allstar Mod") && properties["Allstar Mod"] is int)) { mods.Add("[ffffff][[ff0000]A[-]llStar]"); } // DogS if (properties.ContainsKey("dogshitmod") && GExtensions.AsString(properties["dogshitmod"]).Equals("dogshitmod")) { mods.Add("[ffffff][DogS]"); } // LNON if (properties.ContainsKey("LNON")) { mods.Add("[ffffff][LNON]"); } // Ignis if (properties.ContainsKey("Ignis")) { mods.Add("[ffffff][Ignis]"); } // PedoBear if (player.isPedoBear || properties.ContainsKey("PBModRC")) { mods.Add("[ffffff][[ff6600]P[553300]B[-][-]]"); } // Disciple if (properties.ContainsKey("DiscipleMod")) { mods.Add("[777777][Disciple]"); } // TLW if (properties.ContainsKey("TLW")) { mods.Add("[ffffff][TLW]"); } // ARC if (properties.ContainsKey("ARC-CREADOR")) { mods.Add("[ffffff][ARC (Creator)]"); } if (properties.ContainsKey("ARC")) { mods.Add("[ffffff][ARC]"); } // SRC if (properties.ContainsKey("SRC")) { mods.Add("[ffffff][SRC]"); } // Cyan Mod if (player.isCyan || properties.ContainsKey("CyanMod") || properties.ContainsKey("CyanModNew")) { mods.Add("[00ffff][Cyan Mod]"); } // Expedition if (player.isExpedition || properties.ContainsKey("ExpMod") || properties.ContainsKey("EMID") || properties.ContainsKey("Version") || properties.ContainsKey("Pref")) { string version = "[ffffff]v"; if (properties.ContainsKey("Version")) { version += GExtensions.AsFloat(properties["Version"]); } if (properties.ContainsKey("Pref")) { version += GExtensions.AsString(properties["Pref"]); } mods.Add($"[009900][Exp {version}[-]]"); } // Universe if (player.isUniverse || properties.ContainsKey("UPublica") || properties.ContainsKey("UPublica2") || properties.ContainsKey("UGrup") || properties.ContainsKey("Hats") || properties.ContainsKey("UYoutube") || properties.ContainsKey("UVip") || properties.ContainsKey("SUniverse") || properties.ContainsKey("UAdmin") || properties.ContainsKey("coins") || (properties.ContainsKey(string.Empty) && properties[string.Empty] is string)) { string edition = "[ffffff]"; if (properties.ContainsKey("UYoutube")) { edition += "(You[ff0000]Tube[-])"; } if (properties.ContainsKey("UVip")) { edition += "([ffcc00]VIP[-])"; } if (properties.ContainsKey("UAdmin")) { edition += "([ff0000]Admin[-])"; } mods.Add($"[aa00aa][Universe{edition}[-]]"); } // Teiko if (properties.ContainsKey("Teiko")) { mods.Add("[aed6f1][Teiko]"); } // SLB if (properties.ContainsKey("Wings") || properties.ContainsKey("EarCat") || properties.ContainsKey("Horns")) { mods.Add("[ffffff][SLB]"); } // Ranked RC if (player.isRankedRC || properties.ContainsKey("bronze") || properties.ContainsKey("diamond") || (properties.ContainsKey(string.Empty) && properties[string.Empty] is int)) { mods.Add("[ffffff][Ranked RC]"); } // DeadInside if (properties.ContainsKey("DeadInside")) { mods.Add("[000000][DeadInside]"); } // DFSAO if (properties.ContainsKey("DFSAO")) { mods.Add("[ffffff][DFSAO]"); } // AoE if (properties.ContainsKey("AOE") && GExtensions.AsString(properties["AOE"]).Equals("Made By Exile")) { mods.Add("[0000ff][AoE]"); } string name = GExtensions.AsString(player.customProperties[PhotonPlayerProperty.Name]); string guild = GExtensions.AsString(player.customProperties[PhotonPlayerProperty.Guild]); // Parrot if (guild.StartsWith("[00FF00]PARROT'S MOD")) { mods.Add("[00ff00][PARROT]"); } // Unknown if (player.isUnknown || properties.ContainsKey("Taquila") || properties.ContainsKey("Pain") || properties.ContainsKey("uishot")) { mods.Add("[ffffff][???]"); } // RC if (properties.ContainsKey(PhotonPlayerProperty.RCTeam) || properties.ContainsKey(PhotonPlayerProperty.RCBombR) || properties.ContainsKey(PhotonPlayerProperty.RCBombG) || properties.ContainsKey(PhotonPlayerProperty.RCBombB) || properties.ContainsKey(PhotonPlayerProperty.RCBombA) || properties.ContainsKey(PhotonPlayerProperty.RCBombRadius) || properties.ContainsKey(PhotonPlayerProperty.CustomBool) || properties.ContainsKey(PhotonPlayerProperty.CustomFloat) || properties.ContainsKey(PhotonPlayerProperty.CustomInt) || properties.ContainsKey(PhotonPlayerProperty.CustomString)) { mods.Add("[9999ff][RC]"); } // >48/>40 chars if (name.Length > 48 || guild.Length > 40) { string lengthFlags = string.Empty; if (name.Length > 48) { lengthFlags += ">48"; } if (guild.Length > 40) { lengthFlags += name.Length > 48 ? "|>40" : ">40"; } mods.Add($"[ffffff][{lengthFlags}]"); } // Vanilla if (mods.Count == 0) { mods.Add("[ffddaa][Vanilla]"); } return(mods); }
public override void TurnNext(CoreGameRootViewModel viewModel) { base.TurnNext(viewModel); int active_actor_id = Convert.ToInt32(Network.Client.CurrentRoom.CustomProperties ["active_actor_id"]); Hashtable ht1 = new Hashtable(); ht1.Add("my_turn", false); Publish(new NetSetPlayerProperties() { ActorId = active_actor_id, PropertiesToSet = ht1 }); int actor_id = active_actor_id; int player_count = viewModel.PlayerCollection.Count; do { int orderIdx = viewModel.PlayerCollection.SingleOrDefault(playerVM => playerVM.ActorId == actor_id).OrderIdx; orderIdx++; if (orderIdx >= player_count) { orderIdx = 0; } actor_id = viewModel.PlayerCollection.SingleOrDefault(playerVM => playerVM.OrderIdx == orderIdx).ActorId; bool correct = true; if (Convert.ToBoolean(Network.Client.CurrentRoom.GetPlayer(actor_id).CustomProperties ["is_win"])) { correct = false; } if (correct) { break; } } while(actor_id != active_actor_id); if (viewModel.WinPlayersCount == Network.Client.CurrentRoom.PlayerCount - 1) { Hashtable ht2 = new Hashtable(); ht2.Add("rank", (int)Network.Client.CurrentRoom.PlayerCount); Publish(new NetSetPlayerProperties() { ActorId = actor_id, PropertiesToSet = ht2 }); Hashtable ht = new Hashtable(); ht.Add("active_actor_id", -1); Publish(new NetSetRoomProperties() { PropertiesToSet = ht }); viewModel.ExecuteCalcMatchResult(); Publish(new NetRaiseEvent() { EventCode = GameService.EventCode.MatchOver }); viewModel.ExecuteRootMatchOver(); } else { // 自己的牌大,重新轮到自己发牌 if (Convert.ToInt32(Network.Client.CurrentRoom.CustomProperties ["current_cards_actor_id"]) == actor_id) { Hashtable ht3 = new Hashtable(); ht3.Add("current_cards", JsonConvert.SerializeObject(new List <CardInfo> ())); Publish(new NetSetRoomProperties() { PropertiesToSet = ht3 }); Publish(new NetRaiseEvent() { EventCode = GameService.EventCode.ClearCardsInPile }); CoreGameRoot.Pile.Cards.Clear(); } Hashtable ht2 = new Hashtable(); ht2.Add("my_turn", true); Publish(new NetSetPlayerProperties() { ActorId = actor_id, PropertiesToSet = ht2 }); Hashtable ht = new Hashtable(); ht.Add("active_actor_id", actor_id); Publish(new NetSetRoomProperties() { PropertiesToSet = ht }); } }
public override void OnPlayerPropertiesUpdate(Player targetPlayer, ExitGames.Client.Photon.Hashtable changedProps) { if (changedProps.ContainsKey(PunSettings.PropertiesKeyList.PlayerStateKey)) { _rpcState.CheckState(); } if ((int)_rpcState.RoomRPCAwaitState < (int)RPCAwaitStateList.FirstInMain) { return; } Debug.Log("PlayerPropertiesUpdate" + targetPlayer + " : " + changedProps); var gotFlag = (int)changedProps[PunSettings.PropertiesKeyList.FlagKey]; _scoreManager.SortMemberScore(targetPlayer, gotFlag); var nowFlagNum = (int)changedProps[PunSettings.PropertiesKeyList.NowFlagKey]; _flagManager.FlagNumJudge(targetPlayer, nowFlagNum); _flagManager.ChangeRoomFlagNum(targetPlayer); if (targetPlayer.IsLocal) { var flagInterval = (bool)changedProps[PunSettings.PropertiesKeyList.FlagIntervalKey]; _flagManager.FlagSteelInterval(flagInterval); } //↓playerは旗を取られたプレイヤー //var player = (Player)changedProps[PunSettings.PropertiesKeyList.StolenPlayerKey]; //if (player!=null&&player.IsLocal) //{ // BGMManager.Instance.Play(BGMPath.STOLEN); //} if ($"BGM/{BGMManager.Instance.GetCurrentAudioNames()[0]}" == BGMPath.STEAL && PhotonNetwork.LocalPlayer.CustomProperties[PunSettings.PropertiesKeyList.StolenPlayerKey] != null) { return; } Player[] playerArray = PhotonNetwork.PlayerList; var IsStolen = playerArray .Select(x => (Player)x.CustomProperties[PunSettings.PropertiesKeyList.StolenPlayerKey]) .Where(x => x != null) .Any(x => x.IsLocal); var bgm = IsStolen ? BGMPath.STOLEN : BGMPath.SUNRISE; if ($"BGM/{BGMManager.Instance.GetCurrentAudioNames()[0]}" == bgm) { return; } BGMManager.Instance.Play(bgm); //foreach (var x in playerArray) //{ // var p = (Player)x.CustomProperties[PunSettings.PropertiesKeyList.StolenPlayerKey]; // if (p == null) continue; // if (p.IsLocal) // { // BGMManager.Instance.Play(BGMPath.STOLEN); // break; // } // BGMManager.Instance.Play(BGMPath.SUNRISE); //} }
/// <summary>Refreshes the team lists. It could be a non-team related property change, too.</summary> /// <remarks>Called by PUN. See enum MonoBehaviourPunCallbacks for an explanation.</remarks> public override void OnPlayerPropertiesUpdate(Player targetPlayer, Hashtable changedProps) { this.UpdateTeams(); }
private void RaiseSyncSceneEventHandler(int otherPlayerID, bool forceSync) { if (PhotonNetwork.isMasterClient || forceSync) { List <GameObject> ASLObjectList = GrabAllASLObjects(); NetworkingPeer peer = PhotonNetwork.networkingPeer; foreach (GameObject go in ASLObjectList) { if (nonSyncItems.Contains(go)) { continue; } ExitGames.Client.Photon.Hashtable syncSceneData = new ExitGames.Client.Photon.Hashtable(); syncSceneData[(byte)0] = otherPlayerID; #if UNITY_EDITOR string prefabName = UnityEditor.PrefabUtility.GetPrefabParent(go).name; #else //string prefabName = go.name; string prefabName = ObjectInstantiationDatabase.GetPrefabName(go); #endif //UnityEngine.Debug.Log("Prefab name = " + prefabName); syncSceneData[(byte)1] = prefabName; if (go.transform.position != Vector3.zero) { syncSceneData[(byte)2] = go.transform.position; } if (go.transform.rotation != Quaternion.identity) { syncSceneData[(byte)3] = go.transform.rotation; } syncSceneData[(byte)4] = go.transform.localScale; int[] viewIDs = ExtractPhotonViewIDs(go); syncSceneData[(byte)5] = viewIDs; if (peer.currentLevelPrefix > 0) { syncSceneData[(byte)6] = peer.currentLevelPrefix; } syncSceneData[(byte)7] = PhotonNetwork.ServerTimestamp; syncSceneData[(byte)8] = go.GetPhotonView().instantiationId; OwnableObject ownershipManager = go.GetComponent <OwnableObject>(); syncSceneData[(byte)9] = ownershipManager.IsOwnershipRestricted; List <int> whiteListIDs = ownershipManager.OwnablePlayerIDs; int[] idList = new int[whiteListIDs.Count]; whiteListIDs.CopyTo(idList); syncSceneData[(byte)10] = idList; //RaiseEventOptions options = new RaiseEventOptions(); //options.CachingOption = (isGlobalObject) ? EventCaching.AddToRoomCacheGlobal : EventCaching.AddToRoomCache; //Debug.Log("All items packed. Attempting to literally raise event now."); RaiseEventOptions options = new RaiseEventOptions(); options.Receivers = ReceiverGroup.Others; PhotonNetwork.RaiseEvent(ASLEventCode.EV_SYNCSCENE, syncSceneData, true, options); } } }
/// <summary> /// Constructs a RoomInfo to be used in room listings in lobby. /// </summary> /// <param name="roomName">Name of the room and unique ID at the same time.</param> /// <param name="roomProperties">Properties for this room.</param> protected internal RoomInfo(string roomName, Hashtable roomProperties) { this.CacheProperties(roomProperties); this.name = roomName; }
public static void SetCurrentTimer(int time) { ExitGames.Client.Photon.Hashtable hash = new ExitGames.Client.Photon.Hashtable(); hash.Add("Timer", time); PhotonNetwork.room.SetCustomProperties(hash); }
/** リクエスト。ルーム。接続。 */ private void Main_RequestConnectRoom() { if (this.status_room.mode != Pun_Status_Room.Mode.Request) { //不明。 Tool.Assert(false); this.status_master.mode = Status_Master.Mode.Result; return; } if (this.IsConnectRoom() == true) { //すでに接続済み。 this.status_room.SetConnect(); return; } if (this.IsConnectMaster() == false) { //マスターが切断されている。 this.status_room.SetDisconnect(); return; } //接続。 { Photon.Realtime.RoomOptions t_room_option = new Photon.Realtime.RoomOptions(); { //MaxPlayers t_room_option.MaxPlayers = 16; //IsVisible t_room_option.IsVisible = true; //IsOpen t_room_option.IsOpen = true; //CustomRoomProperties ExitGames.Client.Photon.Hashtable t_custom_room_propertie = new ExitGames.Client.Photon.Hashtable(); { t_custom_room_propertie.Add("room_info", this.status_room.room_info); } t_room_option.CustomRoomProperties = t_custom_room_propertie; //CustomRoomPropertiesForLobby t_room_option.CustomRoomPropertiesForLobby = new string[] { "room_info" }; } Tool.Log("Pun", "JoinOrCreateRoom : " + "room_key = " + this.status_room.room_key + " : room_info = " + this.status_room.room_info); if (Photon.Pun.PhotonNetwork.JoinOrCreateRoom(this.status_room.room_key, t_room_option, Photon.Realtime.TypedLobby.Default) == true) { this.status_room.SetBusy(); } else { //リクエスト失敗。 this.status_room.mode = Pun_Status_Room.Mode.Result; } } }
public void OnPlayerPropertiesUpdate(Player targetPlayer, Hashtable changedProps) { Debug.Log("SupportLogger OnPlayerPropertiesUpdate(targetPlayer,changedProps)."); }
public void OnRoomPropertiesUpdate(Hashtable propertiesThatChanged) { Debug.Log("SupportLogger OnRoomPropertiesUpdate(propertiesThatChanged)."); }
public override void OnEnter() { string _roomName = null; if (!string.IsNullOrEmpty(roomName.Value)) { _roomName = roomName.Value; } ExitGames.Client.Photon.Hashtable _props = new ExitGames.Client.Photon.Hashtable(); int i = 0; foreach (FsmString _prop in customPropertyKey) { _props[_prop.Value] = PlayMakerUtils.GetValueFromFsmVar(this.Fsm, customPropertyValue[i]); i++; } string[] lobbyProps = new string[lobbyCustomProperties.Length]; int j = 0; foreach (FsmString _visibleProp in lobbyCustomProperties) { lobbyProps[j] = _visibleProp.Value; j++; } RoomOptions _options = new RoomOptions(); _options.MaxPlayers = (byte)maxNumberOfPLayers.Value; _options.IsVisible = isVisible.Value; _options.IsOpen = isOpen.Value; _options.CustomRoomProperties = _props; _options.CustomRoomPropertiesForLobby = lobbyProps; if (!playerTimeToLive.IsNone) { _options.PlayerTtl = playerTimeToLive.Value; } if (!emptyRoomTimeToLive.IsNone) { _options.EmptyRoomTtl = emptyRoomTimeToLive.Value; } if (!cleanupCacheOnLeave.IsNone) { _options.CleanupCacheOnLeave = cleanupCacheOnLeave.Value; } if (!suppressRoomEvents.IsNone) { _options.SuppressRoomEvents = suppressRoomEvents.Value; } if (!deleteNullProperties.IsNone) { _options.DeleteNullProperties = deleteNullProperties.Value; } if (!BroadcastPropsChangeToAll.IsNone) { _options.BroadcastPropsChangeToAll = BroadcastPropsChangeToAll.Value; } if (!publishUserId.IsNone) { _options.PublishUserId = publishUserId.Value; } if (!expectedUsers.IsNone) { _expectedUsers = expectedUsers.stringValues; } else { _expectedUsers = null; } if (plugins.Length > 0) { string[] _plugins = new string[plugins.Length]; int k = 0; foreach (FsmString _fsmstring in plugins) { _plugins[k] = _fsmstring.Value; k++; } _options.Plugins = _plugins; } PhotonNetwork.CreateRoom(_roomName, _options, lobby.GetTypedLobby(), _expectedUsers); Finish(); }
void Start() { //actualizando propiedades personalizadas Hashtable props = new Hashtable { { LlamaradaGame.PLAYER_LOADED_LEVEL, true } }; PhotonNetwork.LocalPlayer.SetCustomProperties(props); optionTime = (int)PhotonNetwork.CurrentRoom.CustomProperties["TIMER"]; optionR_Time = (int)PhotonNetwork.CurrentRoom.CustomProperties["R_TIME"]; if (optionTime == 0) { textTimer.enabled = false; textTimerMaster.enabled = false; } else if (optionTime == 1) { textTimer.enabled = false; } if (optionR_Time > 0) { if (optionR_Time == 1) { optionR_TimeNum = 30; } else if (optionR_Time == 2) { optionR_TimeNum = 45; } else if (optionR_Time == 3) { optionR_TimeNum = 60; } } //INSTANCIAR BOARMANAGER if (boarManagerPrefab == null) { Debug.LogError("<Color=Red><a>Missing</a></Color> boarManagerPrefab Reference. Please set it up in GameObject 'Game Controller'", this); } else { if (PhotonNetwork.IsMasterClient) { PhotonNetwork.InstantiateSceneObject(boarManagerPrefab.name, Vector3.zero, Quaternion.identity); } } //INSTACIAR TURNSYSTEM if (turnSystemManager == null) { Debug.LogError("<Color=Red><a>Missing</a></Color> turnSystenManagerPrefabs Reference. Please set it up in GameObject 'Game Controller'", this); } else { if (PhotonNetwork.IsMasterClient) { PhotonNetwork.InstantiateSceneObject(turnSystemManager.name, Vector3.zero, Quaternion.identity); } } //INSTANCIAR PLAYER if (playerPrefab == null) { Debug.LogError("<Color=Red><a>Missing</a></Color> playerPrefab Reference. Please set it up in GameObject 'Game Controller'", this); } else { if (PlayerController.LocalPlayerInstance == null) { //lista de jugadores Player[] players = PhotonNetwork.PlayerList; if (players.Length > 1) { if (!PhotonNetwork.IsMasterClient) { Vector3 positionPlayer = new Vector3(); positionPlayer = LlamaradaGame.GetPosition(PhotonNetwork.LocalPlayer.GetPlayerNumber()); GameObject player = PhotonNetwork.Instantiate(this.playerPrefab.name, positionPlayer, Quaternion.identity, 0); } } else { Vector3 positionPlayer = new Vector3(); positionPlayer = LlamaradaGame.GetPosition(PhotonNetwork.LocalPlayer.GetPlayerNumber()); PhotonNetwork.Instantiate(this.playerPrefab.name, positionPlayer, Quaternion.identity, 0); } } } // TIMER - Cambiado a CronometerTimer.cs /*escalaDeTiempoInicial = escalaDeTiempo; // Establecer la escala de tiempo original * tiempoAMostrarEnSegundos = GameManager.sharedInstance.timeTurn; // Inicializamos la variables que acumular * ActualizarReloj(tiempoInicial);*/ if (PhotonNetwork.IsMasterClient) { SetPopulationInEdifice(); } }
public static void SetDeath(this PhotonPlayer player, int newDeath) { Hashtable hdeath = new Hashtable(); // using PUN's implementation of Hashtable hdeath[PlayerDeath.PlayerDeathProp] = newDeath; player.SetCustomProperties(hdeath); // this locally sets the score and will sync it in-game asap. }
/// <summary> /// Creates a room using Server name, adds player name to custom information. /// </summary> public void CreateRoom() { if (PhotonNetwork.player.name == "") { float defaultRandom = UnityEngine.Random.Range(0, 9999999); PhotonNetwork.player.name = "Default" + defaultRandom.ToString(); } // Hashtable is ExitGames Hashtable Hashtable customProperties = new Hashtable(); customProperties["p"] = PhotonNetwork.player.name; // Player Name customProperties["r"] = "0"; // Round Number customProperties["l"] = isLocked; // Password Protected customProperties["pw"] = password; // Current Password string[] lobbyProperties = new string[customProperties.Count]; int ndx = 0; foreach (string key in customProperties.Keys) { lobbyProperties[ndx] = key; ndx++; } RoomOptions options = new RoomOptions(); options.maxPlayers = 4; options.isOpen = isOpen; options.isVisible = isVisible; options.customRoomProperties = customProperties; options.customRoomPropertiesForLobby = lobbyProperties; Debug.LogWarning(options.customRoomProperties.Count); PhotonNetwork.CreateRoom(roomName, options, null); }