SetCustomProperties() public method

Updates and synchronizes the named properties of this Player with the values of propertiesToSet.
Any player's properties are available in a Room only and only until the player disconnect or leaves. Access any player's properties by: Player.CustomProperties (read-only!) but don't modify that hashtable. New properties are added, existing values are updated. Other values will not be changed, so only provide values that changed or are new. To delete a named (custom) property of this player, use null as value. Only string-typed keys are applied (everything else is ignored). Local cache is updated immediately, other players are updated through Photon with a fitting operation. To reduce network traffic, set only values that actually changed.
public SetCustomProperties ( Hashtable propertiesToSet ) : void
propertiesToSet Hashtable Hashtable of props to udpate, set and sync. See description.
return void
Esempio n. 1
1
	// sets and syncs custom properties on a network player (including masterClient)
	private void SetCustomProperties(PhotonPlayer player, int car, int position) {
		ExitGames.Client.Photon.Hashtable customProperties = new ExitGames.Client.Photon.Hashtable() { { "spawn", position }, {"car", car} };
		player.SetCustomProperties(customProperties);
	}
    void RandomizeTeams()
    {
        int echipa = Random.Range(1, 100);

        if (echipa % 2 == 0)
        {
            Hashtable CustomPropertiesToSet = new Hashtable()
            {
                { "Echipa", "Natura" }
            };
            Player1.SetCustomProperties(CustomPropertiesToSet);
            CustomPropertiesToSet = new Hashtable()
            {
                { "Echipa", "Poluare" }
            };
            Player2.SetCustomProperties(CustomPropertiesToSet);
        }
        else
        {
            Hashtable CustomPropertiesToSet = new Hashtable()
            {
                { "Echipa", "Poluare" }
            };
            Player1.SetCustomProperties(CustomPropertiesToSet);
            CustomPropertiesToSet = new Hashtable()
            {
                { "Echipa", "Natura" }
            };
            Player2.SetCustomProperties(CustomPropertiesToSet);
        }
    }
Esempio n. 3
0
    /// <summary>
    /// 当进入一个房间(通过创建或加入)时被调用。在所有客户端(包括主客户端)上被调用.
    /// </summary>
    /// <remarks>这种方法通常用于实例化玩家角色。
    /// 如果一场比赛必须“积极地”被开始,你也可以调用一个由用户的按键或定时器触发的PunRPC 。
    ///
    /// 当这个被调用时,你通常可以通过PhotonNetwork.playerList访问在房间里现有的玩家。
    /// 同时,所有自定义属性Room.customProperties应该已经可用。检查Room.playerCount就知道房间里是否有足够的玩家来开始游戏.</remarks>
    public override void OnJoinedRoom()
    {
        local  = PhotonNetwork.player;
        remote = PhotonNetwork.player.GetNext();
        if (PhotonNetwork.isMasterClient && local != null)
        {
            localPlayerType               = ChessPlayerType.Red;
            LocalGameStatusText.text      = "您是红方棋手……";
            this.LocalPlayerNameText.text = local.NickName + ":红方";
            ExitGames.Client.Photon.Hashtable playerType = new ExitGames.Client.Photon.Hashtable();
            playerType.Add("playerType", "红方选手");
            local.SetCustomProperties(playerType, null, false);
        }
        else
        {
            this.LocalPlayerNameText.text = local.NickName + ":黑方";
            ExitGames.Client.Photon.Hashtable playerType = new ExitGames.Client.Photon.Hashtable();
            playerType.Add("playerType", "黑方选手");
            local.SetCustomProperties(playerType, null, false);
            localPlayerType          = ChessPlayerType.Black;
            LocalGameStatusText.text = "您是黑方棋手……";
        }

        if (PhotonNetwork.room.PlayerCount == 2 && this.turnManager.Turn == 0)
        {
            // 当房间内有两个玩家,则开始首回合
            Play();
        }

        if (PhotonNetwork.room.PlayerCount > 2)
        {
            localPlayerType          = ChessPlayerType.Guest;
            LocalGameStatusText.text = "棋局已开始,正在进入观棋模式……";
        }

        if (remote != null)
        {
            RemoteGameStatusText.text = "已匹配!";
            // 应该是这种格式: "name        00"
            if (PhotonNetwork.isMasterClient)
            {
                this.RemotePlayerNameText.text = remote.NickName + "—黑方";
            }
            else
            {
                this.RemotePlayerNameText.text = remote.NickName + "—红方";
            }
        }
        else
        {
            this.RemotePlayerNameText.text = "匹配...";
            LocalGameStatusText.text       = "等待其他玩家...";
            RemoteGameStatusText.text      = "正在匹配...";
        }

        RefreshUIViews();
    }
Esempio n. 4
0
 private void ResetProps(PhotonPlayer target)
 {
     if (target != null)
     {
         target.SetCustomProperties(ResetHash);
     }
 }
Esempio n. 5
0
        public bool execute()
        {
            ExitGames.Client.Photon.Hashtable toSet = new ExitGames.Client.Photon.Hashtable();
            toSet[PhotonPlayerProperty.name] = name;

            if (this.target == -1)
            {
                PhotonNetwork.player.SetCustomProperties(toSet);
                ModMain.instance.getModMainThread().updateInternalPlayerProperties();
            }
            else
            {
                PhotonPlayer target = PhotonPlayer.Find(this.target);

                if (target == null)
                {
                    ModMain.instance.getNameChanger().stop();
                }
                else
                {
                    target.SetCustomProperties(toSet);
                }
            }

            return(true);
        }
Esempio n. 6
0
    public static void HeroCostumeToPhotonData2(HeroCostume costume, PhotonPlayer player)
    {
        Hashtable propertiesToSet = new Hashtable();

        propertiesToSet.Add(PhotonPlayerProperty.sex, SexToInt(costume.sex));
        int costumeId = costume.costumeId;

        if (costumeId == 0x1a)
        {
            costumeId = 0x19;
        }
        propertiesToSet.Add(PhotonPlayerProperty.costumeId, costumeId);
        propertiesToSet.Add(PhotonPlayerProperty.heroCostumeId, costume.id);
        propertiesToSet.Add(PhotonPlayerProperty.cape, costume.cape);
        propertiesToSet.Add(PhotonPlayerProperty.hairInfo, costume.hairInfo.id);
        propertiesToSet.Add(PhotonPlayerProperty.eye_texture_id, costume.eye_texture_id);
        propertiesToSet.Add(PhotonPlayerProperty.beard_texture_id, costume.beard_texture_id);
        propertiesToSet.Add(PhotonPlayerProperty.glass_texture_id, costume.glass_texture_id);
        propertiesToSet.Add(PhotonPlayerProperty.skin_color, costume.skin_color);
        propertiesToSet.Add(PhotonPlayerProperty.hair_color1, costume.hair_color.r);
        propertiesToSet.Add(PhotonPlayerProperty.hair_color2, costume.hair_color.g);
        propertiesToSet.Add(PhotonPlayerProperty.hair_color3, costume.hair_color.b);
        propertiesToSet.Add(PhotonPlayerProperty.division, DivisionToInt(costume.division));
        propertiesToSet.Add(PhotonPlayerProperty.statSPD, costume.stat.SPD);
        propertiesToSet.Add(PhotonPlayerProperty.statGAS, costume.stat.GAS);
        propertiesToSet.Add(PhotonPlayerProperty.statBLA, costume.stat.BLA);
        propertiesToSet.Add(PhotonPlayerProperty.statACL, costume.stat.ACL);
        propertiesToSet.Add(PhotonPlayerProperty.statSKILL, costume.stat.skillId);
        player.SetCustomProperties(propertiesToSet);
    }
    /// <summary>Change PhotonPlayer Ready State.</summary>
    public static void SetReadyState(this PhotonPlayer player, bool value)
    {
        Hashtable score = new Hashtable();

        score[PlayerProperties.Ready] = value;
        player.SetCustomProperties(score);
    }
Esempio n. 8
0
    // Token: 0x0600C0E3 RID: 49379 RVA: 0x00464DB4 File Offset: 0x00462FB4
    public static void SetScore(this PhotonPlayer JHOEDACNNKK, int PNOFOOIOBLC)
    {
        Hashtable hashtable = new Hashtable();

        hashtable["score"] = PNOFOOIOBLC;
        JHOEDACNNKK.SetCustomProperties(hashtable, null, false);
    }
        /// <summary>
        /// カスタムプロパティを上書きする
        /// </summary>
        public static void Override(this PhotonPlayer player, string key, object value)
        {
            var cp = player.customProperties;

            cp[key] = value;
            player.SetCustomProperties(cp);
        }
Esempio n. 10
0
    private static void SetProperty <T> (this PhotonPlayer player, string key, T value)
    {
        Hashtable prop = new Hashtable();

        prop [key] = value;
        player.SetCustomProperties(prop);
    }
Esempio n. 11
0
 /// <summary>
 /// Online: synchronizes the team number of the player for all players via properties.
 /// </summary>
 public static void SetTeam(this PhotonPlayer player, int teamIndex)
 {
     player.SetCustomProperties(new Hashtable()
     {
         { team, (byte)teamIndex }
     });
 }
Esempio n. 12
0
 /// <summary>
 /// Online: Synchronizes the currently selected bullet of the player for all players via properties.
 /// </summary>
 public static void SetBullet(this PhotonPlayer player, int value)
 {
     player.SetCustomProperties(new Hashtable()
     {
         { bullet, (byte)value }
     });
 }
Esempio n. 13
0
        public override void OnRestart()
        {
            int num;

            FengGameManagerMKII.imatitan.Clear();
            for (num = 0; num < PhotonNetwork.playerList.Length; num++)
            {
                var player          = PhotonNetwork.playerList[num];
                var propertiesToSet = new ExitGames.Client.Photon.Hashtable
                {
                    { PhotonPlayerProperty.isTitan, 1 }
                };
                player.SetCustomProperties(propertiesToSet);
            }
            var length        = PhotonNetwork.playerList.Length;
            var infectionMode = Infected;

            for (num = 0; num < PhotonNetwork.playerList.Length; num++)
            {
                PhotonPlayer player2 = PhotonNetwork.playerList[num];
                if ((length > 0) && (UnityEngine.Random.Range((float)0f, (float)1f) <= (((float)infectionMode) / ((float)length))))
                {
                    ExitGames.Client.Photon.Hashtable hashtable2 = new ExitGames.Client.Photon.Hashtable();
                    hashtable2.Add(PhotonPlayerProperty.isTitan, 2);
                    player2.SetCustomProperties(hashtable2);
                    FengGameManagerMKII.imatitan.Add(player2.ID, 2);
                    infectionMode--;
                }
                length--;
            }
            FengGameManagerMKII.instance.gameEndCD = 0f;
            FengGameManagerMKII.instance.restartGame2();
        }
Esempio n. 14
0
 /// <summary>
 /// Online: synchronizes the health value of the player for all players via properties.
 /// </summary>
 public static void SetHealth(this PhotonPlayer player, int value)
 {
     player.SetCustomProperties(new Hashtable()
     {
         { health, (byte)value }
     });
 }
Esempio n. 15
0
 /// <summary>
 /// Online: synchronizes the shield value of the player for all players via properties.
 /// </summary>
 public static void SetShield(this PhotonPlayer player, int value)
 {
     player.SetCustomProperties(new Hashtable()
     {
         { shield, (byte)value }
     });
 }
Esempio n. 16
0
    public static void SetScore(this PhotonPlayer player, int newScore)
    {
        var propertiesToSet = new Hashtable();

        propertiesToSet["score"] = newScore;
        player.SetCustomProperties(propertiesToSet);
    }
Esempio n. 17
0
    public static void ToPhotonData(HeroCostume costume, PhotonPlayer player)
    {
        Hashtable properties = new Hashtable();

        properties.Add(PhotonPlayerProperty.Sex, (int)costume.sex);
        properties.Add(PhotonPlayerProperty.CostumeId, costume.costumeId);
        properties.Add(PhotonPlayerProperty.HeroCostumeId, costume.id);
        properties.Add(PhotonPlayerProperty.Cape, costume.cape);
        properties.Add(PhotonPlayerProperty.HairInfo, costume.hairInfo.id);
        properties.Add(PhotonPlayerProperty.EyeTextureId, costume.eye_texture_id);
        properties.Add(PhotonPlayerProperty.BeardTextureId, costume.beard_texture_id);
        properties.Add(PhotonPlayerProperty.GlassTextureId, costume.glass_texture_id);
        properties.Add(PhotonPlayerProperty.SkinColor, costume.skin_color);
        properties.Add(PhotonPlayerProperty.HairColor1, costume.hair_color.r);
        properties.Add(PhotonPlayerProperty.HairColor2, costume.hair_color.g);
        properties.Add(PhotonPlayerProperty.HairColor3, costume.hair_color.b);
        properties.Add(PhotonPlayerProperty.Division, (int)costume.division);
        properties.Add(PhotonPlayerProperty.StatSpeed, costume.stat.Speed);
        properties.Add(PhotonPlayerProperty.StatGas, costume.stat.Gas);
        properties.Add(PhotonPlayerProperty.StatBlade, costume.stat.Blade);
        properties.Add(PhotonPlayerProperty.StatAccel, costume.stat.Accel);
        properties.Add(PhotonPlayerProperty.StatSkill, costume.stat.SkillId);

        player.SetCustomProperties(properties);
    }
        public void Die(int killerId)
        {
            if (photonView.isMine)
            {
                Hashtable deadProperties = PhotonNetwork.player.CustomProperties;
                int       deaths         = 0;
                if (deadProperties.ContainsKey("deaths"))
                {
                    deaths = (int)deadProperties["deaths"];
                }
                deadProperties["deaths"] = deaths + 1;
                PhotonNetwork.player.SetCustomProperties(deadProperties);

                if (killerId != -1 && killerId != PhotonNetwork.player.ID)
                {
                    PhotonPlayer killer           = PhotonPlayer.Find(killerId);
                    Hashtable    killerProperties = killer.CustomProperties;
                    killerProperties["kills"] = ((int)killerProperties["kills"]) + 1;
                    killer.SetCustomProperties(killerProperties);
                }
                gameManager.Respawn();
            }
            gameManager.RemovePlayer(photonView.ownerId);
            DestroyPlayer();
        }
Esempio n. 19
0
    public static void SetSprite(this PhotonPlayer player, int index)
    {
        Hashtable props = new Hashtable();

        props[PlayerExtensions.SpriteProp] = index;
        player.SetCustomProperties(props);
    }
Esempio n. 20
0
    private void SetPhotonPlayerReady(bool ready)
    {
        var playerProperties = PhotonPlayer.CustomProperties;

        playerProperties["Ready"] = ready;
        PhotonPlayer.SetCustomProperties(playerProperties);
    }
Esempio n. 21
0
    public void SetReady(PhotonPlayer player, bool ready)
    {
        Hashtable hash = new Hashtable();

        hash.Add("ready", ready);
        player.SetCustomProperties(hash);
    }
Esempio n. 22
0
    public static void SetScore(this PhotonPlayer player, int newScore)
    {
        Hashtable propertiesToSet = new Hashtable();

        propertiesToSet.set_Item((object)"score", (object)newScore);
        player.SetCustomProperties(propertiesToSet, (Hashtable)null, false);
    }
Esempio n. 23
0
    // Token: 0x06003F05 RID: 16133 RVA: 0x0013DD08 File Offset: 0x0013C108
    public static void SetScore(this PhotonPlayer player, int newScore)
    {
        Hashtable hashtable = new Hashtable();

        hashtable["score"] = newScore;
        player.SetCustomProperties(hashtable, null, false);
    }
Esempio n. 24
0
    public static void AddScore(this PhotonPlayer player, int scoreToAddToCurrent)
    {
        var num             = player.GetScore() + scoreToAddToCurrent;
        var propertiesToSet = new Hashtable();

        propertiesToSet["score"] = num;
        player.SetCustomProperties(propertiesToSet);
    }
Esempio n. 25
0
    public static void SetDeath(this PhotonPlayer player, int newDeath)
    {
        Hashtable death = new Hashtable();  // using PUN's implementation of Hashtable

        death[PlayerDeaths.PlayerDeathProp] = newDeath;

        player.SetCustomProperties(death);  // this locally sets the score and will sync it in-game asap.
    }
Esempio n. 26
0
 public void ResetStreak(PhotonPlayer player)
 {
     ExitGames.Client.Photon.Hashtable hashtable = new ExitGames.Client.Photon.Hashtable()
     {
         { "kills", 0 }
     };
     player.SetCustomProperties(hashtable);
 }
Esempio n. 27
0
    public static void AddScore(this PhotonPlayer player, int scoreToAddToCurrent)
    {
        int       num             = player.GetScore() + scoreToAddToCurrent;
        Hashtable propertiesToSet = new Hashtable();

        propertiesToSet.set_Item((object)"score", (object)num);
        player.SetCustomProperties(propertiesToSet, (Hashtable)null, false);
    }
Esempio n. 28
0
 //해쉬 테이블을 이용 customProperties 설정
 private void SetCustomProperties(PhotonPlayer player, int car, int position)
 {
     ExitGames.Client.Photon.Hashtable customProperties = new ExitGames.Client.Photon.Hashtable()
     {
         { "spawn", position }, { "car", car }
     };
     player.SetCustomProperties(customProperties);
 }
Esempio n. 29
0
    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.
    }
Esempio n. 30
0
    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.
    }
Esempio n. 31
0
    // Use this for initialization
    public static void SetStepState(this PhotonPlayer player, bool isFinish)
    {
        Hashtable score = new Hashtable();  // using PUN's implementation of Hashtable

        score["StepState"] = isFinish;

        player.SetCustomProperties(score);  // this locally sets the score and will sync it in-game asap.
    }
Esempio n. 32
0
	public void GetShot(float damage, PhotonPlayer enemy){
		//Take Damage and check for death
		health -= damage;
		//Play a random Impact Sounds
		audio2.clip = fleshImpactSounds [Random.Range (0, 6)];
		audio2.Play ();
		Debug.Log ("<color=green>Got Shot with </color>" + damage + " damage. Is alive: " + alive + " PhotonView is" + photonView.isMine);
		//Once dead
		if(health <=0 && alive){
			
			alive = false; 
			Debug.Log ("<color=blue>Checking Health</color>" + health + " Photon State " + photonView.isMine + " Player Name " + PhotonNetwork.player.name);
			if (photonView.isMine) {

				//Only owner can remove themselves
				Debug.Log ("<color=red>Death</color>");
				if(SendNetworkMessage != null){
					if(damage < 100f)
						SendNetworkMessage(enemy.name + " owned " + PhotonNetwork.player.name + ".");
					if(damage == 100f)
						SendNetworkMessage(enemy.name + " headshot " + PhotonNetwork.player.name + "!");
						
				}
				//Subscribe to the event so that when a player dies 3 sec later respawn
				if(RespawnMe != null)
					RespawnMe(3f);

				//Create deaths equal to stored hashtable deaths, increment, Set
				int totalDeaths = (int)PhotonNetwork.player.customProperties["D"];
				totalDeaths ++;
				ExitGames.Client.Photon.Hashtable setPlayerDeaths = new ExitGames.Client.Photon.Hashtable() {{"D", totalDeaths}};
				PhotonNetwork.player.SetCustomProperties(setPlayerDeaths);

				//Increment Kill Count for the enemy player
                if(!(enemy.name == "DroneAI")){
				int totalKIlls = (int)enemy.customProperties["K"];
				totalKIlls ++;
				ExitGames.Client.Photon.Hashtable setPlayerKills = new ExitGames.Client.Photon.Hashtable() {{"K", totalKIlls}};
				Debug.Log ("<color=red>KillCounter Called at </color>" + totalKIlls);
				enemy.SetCustomProperties(setPlayerKills);

				//If we reach the kill limit by checking rooms custom property and if this is enabled
                if (totalKIlls == (int)(PhotonNetwork.room.customProperties["KL"]) && (int)(PhotonNetwork.room.customProperties["TKL"]) == 1)
                {
					//Display Win Screen
					NM.DisplayWinPrompt(enemy.name);
				}
               
				//Write Kills and Deaths to File On Death 
				//System.IO.File.AppendAllText (@"C:\Users\Public\PlayerStats.txt", "\n" + "KDR on Death: " + ((int)(PhotonNetwork.player.customProperties["K"])).ToString() + ":" + totalDeaths.ToString());
				//Write amount of ammo picked up so far until death. 
                //System.IO.File.AppendAllText(@"C:\Users\Public\PlayerStats.txt", "\n" + "Total Amount of ammmo picked up so far: " + pickedUpAmmo.ToString());
                }
				//Spawn ammo on death
				PhotonNetwork.Instantiate("Ammo_AK47",transform.position - new Vector3 (0,0.9f,0), Quaternion.Euler(1.5f,149f,95f),0);
				//Finally destroy the game Object.
				PhotonNetwork.Destroy(gameObject);
					
			}
		}
		//Play Hit Effect Animation for player getting hit. Without isMine would play for everyone. 
		if (photonView.isMine) {
			injuryAnim.SetBool ("Hit", true);
			StartCoroutine( WaitForAnimation (1.2f));
		}
	}