// (相手に弾を当てた)プレイヤーのカスタムプロパティを更新する public static void OnDealDamage(this Player player) { hashtable[ScoreKey] = player.GetScore() + 100; // スコアを増やす player.SetCustomProperties(hashtable); hashtable.Clear(); }
public void UpdatePlayerProperties(string key, object value) { ht.Clear(); ht.Add(key, value); PhotonNetwork.LocalPlayer.SetCustomProperties(ht); }
/// <summary> /// /// </summary> public void ResetRoom() { Hashtable table = new Hashtable(); //Initialize new properties where the information will stay Room if (PhotonNetwork.IsMasterClient) { table.Add(PropertiesKeys.Team1Score, 0); table.Add(PropertiesKeys.Team2Score, 0); PhotonNetwork.CurrentRoom.SetCustomProperties(table); } table.Clear(); //Initialize new properties where the information will stay Players table.Add(PropertiesKeys.TeamKey, Team.None.ToString()); table.Add(PropertiesKeys.KillsKey, 0); table.Add(PropertiesKeys.DeathsKey, 0); table.Add(PropertiesKeys.ScoreKey, 0); table.Add(PropertiesKeys.UserRole, bl_GameData.Instance.RolePrefix); PhotonNetwork.LocalPlayer.SetCustomProperties(table); #if ULSP && LM bl_DataBase db = FindObjectOfType <bl_DataBase>(); int scoreLevel = 0; if (db != null) { scoreLevel = db.LocalUser.Score; } Hashtable PlayerTotalScore = new Hashtable(); PlayerTotalScore.Add("TotalScore", scoreLevel); PhotonNetwork.LocalPlayer.SetCustomProperties(PlayerTotalScore); #endif }
// ゲーム開始時刻を設定する public static void SetStartTime(this Room room, int timestamp) { hashtable[KeyStartTime] = timestamp; room.SetCustomProperties(hashtable); hashtable.Clear(); }
public async Task <bool> UpdateRoomProperties(string key, object value) { if (updateKey != null) { Debug.Log("Was UpdateRoomProperties"); return(false); } updateKey = key; ht.Clear(); ht.Add(key, value); orght.Clear(); if (PhotonNetwork.CurrentRoom.CustomProperties.TryGetValue(key, out object rVal)) { orght.Add(key, rVal); } else { orght.Add(key, null); } if (!PhotonNetwork.CurrentRoom.SetCustomProperties(ht, orght)) { updateKey = null; return(false); } updateVal = value; roomPropUpdateResult = new TaskCompletionSource <bool>(); return(await roomPropUpdateResult.Task); }
public static IEnumerator autoDispatchEntity(EntityBase eb) { Debug.LogFormat("Creating Serial Dispatcher for {0} : {1}", eb.name, eb.EntityID); Hashtable h = new Hashtable(); while (true) { h.Clear(); if (eb.isMine) { int code = eb.SerializeAuto(h); if (code != 0) { // If code is 2, message should be reliable // Debug.LogFormat("Dispatching {0}/{2}: {1}", eb.name, h.ToStringFull(), PhotonConstants.EntityUpdateCode); NetworkManager.netMessage(PhotonConstants.EntityUpdateCode, h, code == 2); } } yield return(null); } }
public void ConnectServer(string strUserID, string strNickname) { if (PV == null) { return; } if (PhotonNetwork.connected) { return; } PhotonNetwork.playerName = strNickname; if (PhotonNetwork.AuthValues == null) { PhotonNetwork.AuthValues = new AuthenticationValues(); } PhotonNetwork.AuthValues.UserId = strUserID; m_htPlayer.Clear(); // TODO : 유저 커스텀 값 // m_htPlayer.Add("", "") PhotonNetwork.ConnectUsingSettings("1.0"); }
public static void CleanThenInsert(this ExitGames.Client.Photon.Hashtable ht, object[] objs) { ht.Clear(); for (byte i = 0; i < objs.Length; i++) { ht[i] = objs[i]; } }
public async Task <bool> SetRoomProperty(KeyValExpPair kvePair) { while (rpInProgress.ContainsKey(kvePair.key)) { Debug.Log($"SetRoomProperties {kvePair.key} InProgress"); await Task.Delay(1500); } Debug.Log($"SetRoomProperties {kvePair.ToString()}"); //TrySet Room Properties toChange.Clear(); exptected.Clear(); kvePair.InsertInto(ref toChange, ref exptected); var kvrp = new KeyValResultPair(kvePair.key, kvePair.value, kvePair.exp); rpInProgress.Add(kvePair.key, kvrp); if (PhotonNetwork.CurrentRoom.SetCustomProperties(toChange, exptected)) { //Debug.Log($"{scriptName} SetCustomProperties Waiting"); await Task.WhenAny(Task.Delay(10000), kvrp.setPropResult.Task); if (!kvrp.setPropResult.Task.IsCompleted) { kvrp.setPropResult?.TrySetResult(false); } } else { Debug.LogWarning($"{scriptName} SetCustomProperties Immedidate fail"); kvrp.setPropResult?.TrySetResult(false); } var result = kvrp.setPropResult.Task.Result; Debug.Log($"{result}] {kvrp.ToString()}"); rpInProgress.Remove(kvePair.key); return(result); }
/// <summary> /// Initalizes all custom properties of the room. /// </summary> /// <returns></returns> public static Hashtable CreateRoomHashtable() { _localRoomProperties.Clear(); sceneLoaded.Initialize(_localRoomProperties, "RoomScene1"); entities.Initialize(_localRoomProperties, new Hashtable()); entities2.Initialize(_localRoomProperties, ""); return(_localRoomProperties); }
public static void ClearPlayerProperties(PhotonPlayer player) { Hashtable p = player.CustomProperties; if (p != null) { p.Clear(); player.SetCustomProperties(p); } }
public void OrderBurst() { if (!PhotonNetwork.InRoom) { return; } bool toBrust = false; if (PhotonNetwork.CurrentRoom.CustomProperties.TryGetValue(RPKey.Burst.ToString(), out object peoC)) { toBrust = !(bool)peoC; } tmpHT.Clear(); tmpHT[RPKey.Burst.ToString()] = toBrust; PhotonNetwork.CurrentRoom.SetCustomProperties(tmpHT); }
void Update() { newData.Clear(); // if (!photonView.IsMine) // { // //Update remote player (smooth this, this looks good, at the cost of some accuracy) // // transform.position = Vector3.Lerp(transform.position, new Vector3((float)Math.Round(correctPlayerPos.x,1),(float)Math.Round(correctPlayerPos.y,1),(float)Math.Round(correctPlayerPos.z,1)), Time.deltaTime * this.SmoothingDelay); // // transform.rotation = Quaternion.Lerp(transform.rotation, correctPlayerRot, Time.deltaTime * this.SmoothingDelay); // transform.position = Vector3.MoveTowards(transform.position, new Vector3((float)Math.Round(correctPlayerPos.x,1),(float)Math.Round(correctPlayerPos.y,1),(float)Math.Round(correctPlayerPos.z,1)), this.m_Distance * (1.0f / PhotonNetwork.SerializationRate)); // transform.rotation = Quaternion.RotateTowards(transform.rotation,correctPlayerRot, this.m_Angle * (1.0f / PhotonNetwork.SerializationRate)); // //transform.position = correctPlayerPos; // //transform.rotation = correctPlayerRot; // //UI_PlayersDistance.Instance.SetDistance(photonView.Owner.UserId,correctPlayerPos.x); // } // else{ // // newData.Add(photonView.Owner.UserId,transform.position.x); // // roomData[RoomPropertyKeys.PLAYER_DATA] = newData; // // PhotonNetwork.CurrentRoom.SetCustomProperties(roomData); // } OnPlayerMovement.OnNext(Tuple.Create(photonView.Owner.UserId, transform.position.x)); }
public static void SetPlayerNum(this Player player, int actorNum) { hashtable[playerNumKey] = actorNum; player.SetCustomProperties(hashtable); hashtable.Clear(); }