public override void OnPhotonCustomRoomPropertiesChanged(ExitGames.Client.Photon.Hashtable propertiesThatChanged) { foreach( string key in propertiesThatChanged.Keys ) { Debug.Log("Outer Room PropertyChanged -> " + key + " : " + propertiesThatChanged[key]); if ( photonView.isMine && (string)propertiesThatChanged[key] == "ready" ) { Debug.Log("Inner Room PropertyChanged -> " + key + " : " + propertiesThatChanged[key]); readyCount += 1; if ( readyCount == GameManager.Instance.maxPlayer) { this.photonView.RPC("BattleStart", PhotonTargets.All, PhotonNetwork.time + 5 ); } } } }
public override void OnOperationResponse(ExitGames.Client.Photon.OperationResponse response) { SubCode subCode = ParameterTool.GetParameters<SubCode>(response.Parameters, ParameterCode.SubCode, false); switch(subCode) { case SubCode.SendTeam: if(response.ReturnCode==(short)ReturnCode.GetTeam) { List<Role> list = ParameterTool.GetParameters<List<Role>>(response.Parameters, ParameterCode.RoleList); int masterRoleID = ParameterTool.GetParameters<int>(response.Parameters, ParameterCode.MasterRoleID,false); //组队成功 if(OnGetTeam!=null) OnGetTeam(list,masterRoleID); } else if(response.ReturnCode==(short)ReturnCode.WaitTeam) { if(OnWaitTeam!=null) OnWaitTeam(); //正在组队 } break; case SubCode.CancelTeam: if(OnCancelTeam!=null&&response.ReturnCode==(short)ReturnCode.Success) { OnCancelTeam(); } break; } }
public override void OnOperationResponse(ExitGames.Client.Photon.OperationResponse response) { switch (response.ReturnCode) { case (short)ReturnCode.Fail: MessageManager._instance.ShowMessage(response.DebugMessage,2); break; case (short)ReturnCode.Success: MessageManager._instance.ShowMessage("注册成功",2); controller.HideRegisterPanel(); controller.ShowStartPanel(); controller.usernameLabelStart.text = user.Username; break; } }
/// <summary> /// 从服务器接接到响应 /// </summary> /// <param name="response"></param> public override void OnOperationResponse(ExitGames.Client.Photon.OperationResponse response) { object subobject; response.Parameters.TryGetValue((byte)ParameterCode.SubCode, out subobject); SubCode subCode = (SubCode)subobject; switch (subCode) { case SubCode.GetTask: List<TaskDB> list = ParameterTool.GetParameters<List<TaskDB>>(response.Parameters, ParameterCode.TaskdbList); if (OnGetTaskList != null) { OnGetTaskList(list); } break; case SubCode.AddTask: TaskDB taskDB = ParameterTool.GetParameters<TaskDB>(response.Parameters, ParameterCode.Taskdb); if (OnAddTask != null) { if (response.ReturnCode == (short)ReturnCode.Success) { OnAddTask(taskDB); } } break; case SubCode.UpdateTask: if (OnUpdateTask != null) { if (response.ReturnCode == (short)ReturnCode.Success) OnUpdateTask(); } break; } }
/// <summary> /// On recieving a mission through the PhotonNetwork, configure the newMissionWindow and activate the newMissionButton, both linked in Editor. /// </summary> /// <param name="missionData"></param> private void OnMissionRecieved(ExitGames.Client.Photon.Hashtable missionData) { object value; if (missionData.TryGetValue("missionTitle", out value)) { newMissionWindow.titleText.text = value as string; } if (missionData.TryGetValue("missionDescription", out value)) { newMissionWindow.descriptionText.text = value as string; } newMissionButton.gameObject.SetActive(true); }
public override void OnEvent(ExitGames.Client.Photon.EventData eventData) { if (Enum.IsDefined(typeof(LoadBalancingEnums.EventCode), eventData.Code)) { Counters.ReliableEventsReceived.Increment(); WindowsCounters.ReliableEventsReceived.Increment(); } else { base.OnEvent(eventData); } }
public void DebugReturn(ExitGames.Client.Photon.DebugLevel level, string message) { if (level == ExitGames.Client.Photon.DebugLevel.ERROR) { UnityEngine.Debug.LogError(message); } else if (level == ExitGames.Client.Photon.DebugLevel.WARNING) { UnityEngine.Debug.LogWarning(message); } else { UnityEngine.Debug.Log(message); } }
public static string HashToString(ExitGames.Client.Photon.Hashtable hash) { string output = ""; foreach (object key in hash.Keys) { if (key is ExitGames.Client.Photon.Hashtable) { output += "{" + HashToString((ExitGames.Client.Photon.Hashtable)key) + "}"; } else { output += "{" + key.ToString() + ":" + hash[key] + "}"; } } return output; }
/// <summary> /// Initializes a new instance of the <see cref="Assignment"/> class. Retrieves and deletes the target location and description from data. The remainder of data is saved as typeData. /// </summary> /// <param name="sequenceN">The sequence number of the assignment.</param> /// <param name="type">The type of assignment, must correspond with and assignment scene.</param> /// <param name="data">Hashtable containing the rest of the assignment data, including type specific data.</param> public Assignment(int sequenceN, string type, ExitGames.Client.Photon.Hashtable data = null) { assignmentType = type; sequenceNumber = sequenceN; assignmentState = Assignment.STATE_NEW; if (data != null) { object value; if (data.TryGetValue("missionDescription", out value)) { description = (string)value; data.Remove("missionDescription"); } typeData = data; } }
public override void OnDisconnect(GameControllerBase mainGame, ExitGames.Client.Photon.StatusCode returnCode) { base.OnDisconnect(mainGame, returnCode); _isDisconnected = true; _counter = 10; // 10 seconds countdown Debug.Log("MainGame: Disconnected with returnCode " + returnCode); WindowManager.IsVisible = false; Messenger<string>.Broadcast(Messages.BANNER_CHANGE, "GUI/Banner/ditu_bg"); Messenger<bool>.Broadcast(Messages.BANNER_SETVISIBILITY, true); PBGameMaster.GameState = GameStateType.Disconnected; //mainGame.Clear(); _countdownTimer.Start(); }
public override void OnOperationResponse(ExitGames.Client.Photon.OperationResponse response) { SubCode subCode = ParameterTool.GetParameters<SubCode>(response.Parameters, ParameterCode.SubCode, false); //Debug.Log("InventoryItemDB:"+subCode); switch(subCode) { case SubCode.GetInventoryItemDB: List<InventoryItemDB> list =ParameterTool.GetParameters<List<InventoryItemDB>>(response.Parameters, ParameterCode.InventoryItemdbList); //Debug.Log(list); if (list==null||list.Count==0) { //Debug.Log("数据库没有装备信息"); return; } if(OnGetInventoryItemDB!=null) { OnGetInventoryItemDB(list); } break; case SubCode.AddInventoryItemDB: InventoryItemDB itemDB = ParameterTool.GetParameters<InventoryItemDB>(response.Parameters, ParameterCode.InventoryItemdb); if (OnAddInventoryItemDB != null) OnAddInventoryItemDB(itemDB); break; case SubCode.UpdateInventoryItemDB: OnUpdateInventoryItemDB(); break; case SubCode.UpdateInventoryItemDBList: if (OnUpdateInventoryItemDBList!=null) OnUpdateInventoryItemDBList(); break; case SubCode.GetShopInventoryDBList: List<ShopInventoryDB> shoplist = ParameterTool.GetParameters<List<ShopInventoryDB>>(response.Parameters, ParameterCode.ShopInventorydbList); if(OnGetShopInventoryDB!=null) { OnGetShopInventoryDB(shoplist); } break; } }
public override void OnOperationResponse(ExitGames.Client.Photon.OperationResponse response) { SubCode subCode = ParameterTool.GetSubCode(response.Parameters); switch (subCode) { case SubCode.Add: SkillDB skillDB = ParameterTool.GetParameter<SkillDB>(response.Parameters, ParameterCode.SkillDB); if (OnAddSkillDB != null) { OnAddSkillDB(skillDB); } break; case SubCode.Get: List<SkillDB> list = ParameterTool.GetParameter<List<SkillDB>>(response.Parameters, ParameterCode.SkillDBList); if (OnGetSkillDBList != null) { OnGetSkillDBList(list); } break; case SubCode.Update: if (OnUpdateSkillDB != null) { OnUpdateSkillDB(); } break; case SubCode.Upgrade: SkillDB skillDB2 = ParameterTool.GetParameter<SkillDB>(response.Parameters, ParameterCode.SkillDB); if (OnUpgradeSkillDB != null) { OnUpgradeSkillDB(skillDB2); } break; } }
//得到响应 public override void OnOperationResponse(ExitGames.Client.Photon.OperationResponse response) { SubCode subcode = ParameterTool.GetParameter<SubCode>(response.Parameters, ParameterCode.SubCode,false); switch (subcode) { case SubCode.GetRole: List<Role> list = ParameterTool.GetParameter<List<Role>>(response.Parameters, ParameterCode.RoleList); OnGetRole(list); break; case SubCode.AddRole: Role role = ParameterTool.GetParameter<Role>(response.Parameters, ParameterCode.Role); OnAddRole(role); break; case SubCode.SelectRole: if (OnSelectRole != null) { OnSelectRole(); } break; } }
public override void OnOperationResponse(ExitGames.Client.Photon.OperationResponse response) { object subobject; response.Parameters.TryGetValue((byte)ParameterCode.SubCode, out subobject); SubCode subCode = (SubCode)subobject; switch(subCode) { case SubCode.GetRole: switch(response.ReturnCode) { case (short)ReturnCode.Success: List<Role> list = ParameterTool.GetParameters<List<Role>>(response.Parameters, ParameterCode.RoleList); OnGetRole(list); break; case (short)ReturnCode.Empty: OnGetEmptyRole();//当服务器没有该角色信息的时候跳转到创建角色的界面。 break; } break; case SubCode.AddRole: switch(response.ReturnCode) { case (short)ReturnCode.Success: Role role =ParameterTool.GetParameters<Role>(response.Parameters,ParameterCode.Role); OnAddRole(role); break; case (short)ReturnCode.Fail: //添加角色失败 MessageManager._instance.SendMessage(response.DebugMessage); break; } break; case SubCode.SelectRole: if (OnseletRole != null) OnseletRole(); break; } }
public void OnEvent(ExitGames.Client.Photon.EventData @event) { var eventData = new EventData { Code = @event.Code, Parameters = @event.Parameters }; if (log.IsDebugEnabled) { log.Debug("EventReceived"); LogHelper.WriteDictionaryContent(eventData.Parameters, 0); } this.eventQueue.Enqueue(eventData); OnEventReceived(this, eventData); }
void OnFailedToConnectToPhoton(ExitGames.Client.Photon.StatusCode status) { Debug.Log("Failed to connect to Photon: " + status); failConnectMesage = "Failed to connect to Photon: " + status; }
public void DebugReturn(ExitGames.Client.Photon.DebugLevel level, string message) { Debug.Log(message); }
public void OnWebRpcResponse(ExitGames.Client.Photon.OperationResponse response){ Publish (this); }
/// <summary> /// dumps a game state hashtable to the console /// </summary> public static void DumpGameState(ExitGames.Client.Photon.Hashtable gameState) { string s = "--- GAME STATE ---\n(click to view)\n\n"; if (gameState == null) { Debug.Log("DumpGameState: Passed gamestate was null: assembling full gamestate."); gameState = AssembleGameState(); } foreach (object key in gameState.Keys) { if (key.GetType() == typeof(int)) { object player; gameState.TryGetValue(key, out player); s += vp_MPNetworkPlayer.GetName((int)key) + ":\n"; foreach (object o in ((ExitGames.Client.Photon.Hashtable)player).Keys) { s += "\t\t" + (o.ToString()) + ": "; object val; ((ExitGames.Client.Photon.Hashtable)player).TryGetValue(o, out val); s += val.ToString().Replace("(System.String)", "") + "\n"; } } else { object val; gameState.TryGetValue(key, out val); s += key.ToString() + ": " + val.ToString(); } s += "\n"; } UnityEngine.Debug.Log(s); }
protected virtual void ReceivePlayerState(ExitGames.Client.Photon.Hashtable gameState, PhotonMessageInfo info) { //Debug.Log("GOT PLAYER STATE!"); if ((info.sender != PhotonNetwork.masterClient) || (info.sender.isLocal)) return; // -------- refresh stats of all included players -------- foreach (vp_MPNetworkPlayer player in vp_MPNetworkPlayer.Players.Values) { if (player == null) continue; object stats; if (gameState.TryGetValue(player.ID, out stats) && (stats != null)) player.Stats.SetFromHashtable((ExitGames.Client.Photon.Hashtable)stats); //else // vp_MPDebug.Log("Failed to extract player " + player.ID + " stats from gamestate"); } // -------- refresh all teams -------- if(vp_MPTeamManager.Exists) vp_MPTeamManager.Instance.RefreshTeams(); }
protected virtual void ReceiveGameState(ExitGames.Client.Photon.Hashtable gameState, PhotonMessageInfo info) { //vp_MPDebug.Log("GOT FULL GAMESTATE!"); //DumpGameState(gameState); if ((info.sender != PhotonNetwork.masterClient) || (info.sender.isLocal)) return; //vp_MPDebug.Log("Gamestate updated @ " + info.timestamp); //Debug.Log("Gamestate updated @ " + info.timestamp); // -------- extract game phase, game time and duration -------- // TODO: make generic method 'ExtractStat' that does this object phase; if ((gameState.TryGetValue("Phase", out phase) && (phase != null))) Phase = (GamePhase)phase; object timeLeft; object duration; if ((gameState.TryGetValue("TimeLeft", out timeLeft) && (timeLeft != null)) && (gameState.TryGetValue("Duration", out duration) && (duration != null))) vp_MPClock.Set((float)timeLeft, (float)duration); // -------- instantiate missing player prefabs -------- vp_MPPlayerSpawner.Instance.InstantiateMissingPlayerPrefabs(gameState); // -------- refresh stats of all players -------- ReceivePlayerState(gameState, info); // -------- refresh health of all non-player damage handlers -------- foreach (vp_DamageHandler d in vp_DamageHandler.Instances.Values) { if (d == null) continue; if (d is vp_PlayerDamageHandler) continue; PhotonView p = d.GetComponent<PhotonView>(); if (p == null) continue; object currentHealth; if (gameState.TryGetValue(-p.viewID, out currentHealth) && (currentHealth != null)) { d.CurrentHealth = (float)currentHealth; if (d.CurrentHealth <= 0.0f) vp_Utility.Activate(d.gameObject, false); } else vp_MPDebug.Log("Failed to extract health of damage handler " + p.viewID + " from gamestate"); } // -------- disable any pickups noted as currently disabled in the state -------- //vp_MPDebug.Log("DISABLED PICKUPS: " + vp_MPPickupManager.Instance.Pickups.Keys.Count); foreach (int id in vp_MPPickupManager.Instance.Pickups.Keys) { List<vp_ItemPickup> p; vp_MPPickupManager.Instance.Pickups.TryGetValue(id, out p); if ((p == null) || (p.Count < 1) || p[0] == null) continue; object isDisabled; if (gameState.TryGetValue(id, out isDisabled) && (isDisabled != null)) vp_Utility.Activate(p[0].transform.gameObject, false); } // -------- refresh all teams -------- if(vp_MPTeamManager.Exists) vp_MPTeamManager.Instance.RefreshTeams(); }
/// <summary> /// pushes the master client's version of the game state and all /// player stats onto another client. if 'player' is null, the game /// state will be pushed onto _all_ other clients. 'gameState' can /// optionally be provided for cases where only a partial game state /// (a few stats on a few players) needs to be sent. by default the /// method will assemble and broadcast all stats of all players. /// </summary> public void TransmitGameState(PhotonPlayer targetPlayer, ExitGames.Client.Photon.Hashtable gameState = null) { if (!PhotonNetwork.isMasterClient) return; //DumpGameState(gameState); // if no (partial) gamestate has been provided, assemble and // broadcast the entire gamestate if (gameState == null) gameState = AssembleGameState(); //DumpGameState(gameState); if (targetPlayer == null) { //Debug.Log("sending to all" + Time.time); photonView.RPC("ReceiveGameState", PhotonTargets.Others, (ExitGames.Client.Photon.Hashtable)gameState); } else { //Debug.Log("sending to " + targetPlayer + "" + Time.time); photonView.RPC("ReceiveGameState", targetPlayer, (ExitGames.Client.Photon.Hashtable)gameState); } if (vp_MPTeamManager.Exists) vp_MPTeamManager.Instance.RefreshTeams(); }
public void SetPlayersCards(ExitGames.Client.Photon.Hashtable cardsData) { Debug.Log("setting cards data: " + cardsData); PhotonNetwork.room.SetCustomProperties(cardsData); }
public void OnOperationResponse(ExitGames.Client.Photon.OperationResponse operationResponse) { var response = new OperationResponse { OperationCode = operationResponse.OperationCode, Parameters = operationResponse.Parameters, ReturnCode = operationResponse.ReturnCode, DebugMessage = operationResponse.DebugMessage, }; if (log.IsDebugEnabled) { LogOperationResponse(response); } this.operationResponseQueue.Enqueue(response); OnResponseReceived(this, response); }
void IPunCallbacks.OnWebRpcResponse(ExitGames.Client.Photon.OperationResponse response){}
/// <summary> /// pushes the master client's version of the game state and all /// player stats onto all other clients. 'gameState' can optionally /// be provided for cases where only a partial game state (a few /// stats on a few players) needs to be sent. by default the method /// will assemble and broadcast all stats of all players. /// </summary> public void TransmitGameState(ExitGames.Client.Photon.Hashtable gameState = null) { TransmitGameState(null, gameState); }
void IPunCallbacks.OnPhotonCustomRoomPropertiesChanged(ExitGames.Client.Photon.Hashtable propertiesThatChanged){}
public override void OnOperationResponse(ExitGames.Client.Photon.OperationResponse response) { SubCode subCode = ParameterTool.GetParameter<SubCode>(response.Parameters,ParameterCode.SubCode,false); switch (subCode) { case SubCode.GetTaskDB: List<TaskDB> list = ParameterTool.GetParameter<List<TaskDB>>(response.Parameters, ParameterCode.TaskDBList); if (OnGetTaskDBList != null) { OnGetTaskDBList(list); } break; case SubCode.AddTaskDB: TaskDB taskDB = ParameterTool.GetParameter<TaskDB>(response.Parameters, ParameterCode.TaskDB); if (OnAddTaskDB != null) { OnAddTaskDB(taskDB); } break; case SubCode.UpdateTaskDB: if (OnUpdateTaskDB != null) { OnUpdateTaskDB(); } break; } }
//处理响应 public override void OnOperationResponse(ExitGames.Client.Photon.OperationResponse response) { SubCode subcode = ParameterTool.GetParameter<SubCode>(response.Parameters, ParameterCode.SubCode, false); switch (subcode) { //查询 case SubCode.GetInventoryItemDB: List<InventoryItemDB> list = ParameterTool.GetParameter<List<InventoryItemDB>>(response.Parameters,ParameterCode.InventoryItemDBList); if (OnGetInventoryItemDBList != null) { OnGetInventoryItemDBList(list); } break; //添加 case SubCode.AddInventoryItemDB: if (OnAddInventoryItemDB != null) { InventoryItemDB itemDB = ParameterTool.GetParameter<InventoryItemDB>(response.Parameters,ParameterCode.InventoryItemDB); OnAddInventoryItemDB(itemDB); } break; //更新,一个的情况 case SubCode.UpdateInventoryItemDB: if (OnUpdateInventoryItemDB != null) { OnUpdateInventoryItemDB(); } break; //更新,两个的情况 case SubCode.UpdateInventoryItemDBList: if (OnUpdateInventoryItemDBList != null) { OnUpdateInventoryItemDBList(); } break; //装备升级 case SubCode.UpgradeEquip: if (OnUpgradeEquip != null) { OnUpgradeEquip(); } break; } }
public override void OnOperationResponse(ExitGames.Client.Photon.OperationResponse response) { MessageManager._instance.ShowMessage(response.DebugMessage); switch(response.ReturnCode) { case (short)ReturnCode.Success: StartmenuController.instance.HideLogin(); StartmenuController.instance.label_start_user.text = user.UserName; StartmenuController.instance.ShowStartMenu(); StartmenuController.instance.isLogin = true; break; case (short)ReturnCode.Fail: StartmenuController.instance.isLogin = false; break; } }