本文整理汇总了C#中EventData.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# EventData.ToString方法的具体用法?C# EventData.ToString怎么用?C# EventData.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventData
的用法示例。
在下文中一共展示了EventData.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnEvent
public void OnEvent(EventData photonEvent)
{
if (this.DebugOut >= DebugLevel.INFO)
{
this.DebugReturn(DebugLevel.INFO, string.Format("OnEvent: {0}", photonEvent.ToString()));
}
int actorNr = -1;
PhotonPlayer originatingPlayer = null;
if (photonEvent.Parameters.ContainsKey(ParameterCode.ActorNr))
{
actorNr = (int)photonEvent[ParameterCode.ActorNr];
if (this.mActors.ContainsKey(actorNr))
{
originatingPlayer = (PhotonPlayer)this.mActors[actorNr];
}
//else
//{
// // the actor sending this event is not in actorlist. this is usually no problem
// if (photonEvent.Code != (byte)LiteOpCode.Join)
// {
// Debug.LogWarning("Received event, but we do not have this actor: " + actorNr);
// }
//}
}
switch (photonEvent.Code)
{
case EventCode.GameList:
{
this.mGameList = new Dictionary<string, RoomInfo>();
Hashtable games = (Hashtable)photonEvent[ParameterCode.GameList];
foreach (DictionaryEntry game in games)
{
string gameName = (string)game.Key;
this.mGameList[gameName] = new RoomInfo(gameName, (Hashtable)game.Value);
}
mGameListCopy = new RoomInfo[mGameList.Count];
mGameList.Values.CopyTo(mGameListCopy, 0);
SendMonoMessage(PhotonNetworkingMessage.OnReceivedRoomListUpdate);
break;
}
case EventCode.GameListUpdate:
{
Hashtable games = (Hashtable)photonEvent[ParameterCode.GameList];
foreach (DictionaryEntry room in games)
{
string gameName = (string)room.Key;
Room game = new Room(gameName, (Hashtable)room.Value);
if (game.removedFromList)
{
this.mGameList.Remove(gameName);
}
else
{
this.mGameList[gameName] = game;
}
}
this.mGameListCopy = new RoomInfo[this.mGameList.Count];
this.mGameList.Values.CopyTo(this.mGameListCopy, 0);
SendMonoMessage(PhotonNetworkingMessage.OnReceivedRoomListUpdate);
break;
}
case EventCode.QueueState:
if (photonEvent.Parameters.ContainsKey(ParameterCode.Position))
{
this.mQueuePosition = (int)photonEvent[ParameterCode.Position];
}
else
{
this.DebugReturn(DebugLevel.ERROR, "Event QueueState must contain position!");
}
if (this.mQueuePosition == 0)
{
// once we're un-queued, let's join the lobby or simply be "connected to master"
if (PhotonNetwork.autoJoinLobby)
{
this.OpJoinLobby();
this.State = global::PeerState.Authenticated;
}
else
{
this.State = global::PeerState.ConnectedToMaster;
NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnConnectedToMaster);
}
}
break;
case EventCode.AppStats:
// Debug.LogInfo("Received stats!");
this.mPlayersInRoomsCount = (int)photonEvent[ParameterCode.PeerCount];
this.mPlayersOnMasterCount = (int)photonEvent[ParameterCode.MasterPeerCount];
this.mGameCount = (int)photonEvent[ParameterCode.GameCount];
break;
//.........这里部分代码省略.........
示例2: OnEvent
public void OnEvent(EventData photonEvent)
{
if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
Debug.Log(string.Format("OnEvent: {0}", photonEvent.ToString()));
int actorNr = -1;
PhotonPlayer originatingPlayer = null;
if (photonEvent.Parameters.ContainsKey(ParameterCode.ActorNr))
{
actorNr = (int)photonEvent[ParameterCode.ActorNr];
if (this.mActors.ContainsKey(actorNr))
{
originatingPlayer = (PhotonPlayer)this.mActors[actorNr];
}
//else
//{
// // the actor sending this event is not in actorlist. this is usually no problem
// if (photonEvent.Code != (byte)LiteOpCode.Join)
// {
// Debug.LogWarning("Received event, but we do not have this actor: " + actorNr);
// }
//}
}
switch (photonEvent.Code)
{
case PunEvent.OwnershipRequest:
{
int[] requestValues = (int[]) photonEvent.Parameters[ParameterCode.CustomEventContent];
int requestedViewId = requestValues[0];
int currentOwner = requestValues[1];
Debug.Log("Ev OwnershipRequest: " + photonEvent.Parameters.ToStringFull() + " ViewID: " + requestedViewId + " from: " + currentOwner + " Time: " + Environment.TickCount%1000);
PhotonView requestedView = PhotonView.Find(requestedViewId);
if (requestedView == null)
{
Debug.LogWarning("Can't find PhotonView of incoming OwnershipRequest. ViewId not found: " + requestedViewId);
break;
}
Debug.Log("Ev OwnershipRequest PhotonView.ownershipTransfer: " + requestedView.ownershipTransfer + " .ownerId: " + requestedView.ownerId + " isOwnerActive: " + requestedView.isOwnerActive + ". This client's player: " + PhotonNetwork.player.ToStringFull());
switch (requestedView.ownershipTransfer)
{
case OwnershipOption.Fixed:
Debug.LogWarning("Ownership mode == fixed. Ignoring request.");
break;
case OwnershipOption.Takeover:
if (currentOwner == requestedView.ownerId)
{
// a takeover is successful automatically, if taken from current owner
requestedView.ownerId = actorNr;
}
break;
case OwnershipOption.Request:
if (currentOwner == PhotonNetwork.player.ID || PhotonNetwork.player.isMasterClient)
{
if ((requestedView.ownerId == PhotonNetwork.player.ID) || (PhotonNetwork.player.isMasterClient && !requestedView.isOwnerActive))
{
SendMonoMessage(PhotonNetworkingMessage.OnOwnershipRequest, new object[] {requestedView, originatingPlayer});
}
}
break;
default:
break;
}
}
break;
case PunEvent.OwnershipTransfer:
{
int[] transferViewToUserID = (int[]) photonEvent.Parameters[ParameterCode.CustomEventContent];
Debug.Log("Ev OwnershipTransfer. ViewID " + transferViewToUserID[0] + " to: " + transferViewToUserID[1] + " Time: " + Environment.TickCount%1000);
int requestedViewId = transferViewToUserID[0];
int newOwnerId = transferViewToUserID[1];
PhotonView pv = PhotonView.Find(requestedViewId);
pv.ownerId = newOwnerId;
break;
}
case EventCode.GameList:
{
this.mGameList = new Dictionary<string, RoomInfo>();
Hashtable games = (Hashtable)photonEvent[ParameterCode.GameList];
foreach (DictionaryEntry game in games)
{
string gameName = (string)game.Key;
this.mGameList[gameName] = new RoomInfo(gameName, (Hashtable)game.Value);
}
mGameListCopy = new RoomInfo[mGameList.Count];
mGameList.Values.CopyTo(mGameListCopy, 0);
SendMonoMessage(PhotonNetworkingMessage.OnReceivedRoomListUpdate);
break;
}
case EventCode.GameListUpdate:
{
//.........这里部分代码省略.........
示例3: OnEvent
public override void OnEvent(EventData photonEvent)
{
Debug.Log("[DemoGame] OnEvent: {" + photonEvent.Code + "} >>> " + photonEvent.ToString());
base.OnEvent(photonEvent);
switch (photonEvent.Code)
{
case (byte)EvTileClick:
object content = photonEvent.Parameters[ParameterCode.CustomEventContent];
Hashtable turnClick = content as Hashtable;
if (turnClick != null)
{
int turnNumber = (int)turnClick[(byte)1];
int clickedTile = (int)turnClick[(byte)2];
while (turnNumber >= this.lastTilesClicked.Count)
{
this.lastTilesClicked.Add(new List<int>());
}
this.lastTilesClicked[turnNumber].Add(clickedTile);
this.evCount++;
Debug.Log("got click ev. tile: " + clickedTile + " turn: " + turnNumber);
}
break;
case EventCode.PropertiesChanged:
DebugReturn(DebugLevel.ALL, "Got Properties via Event. Update Board by room props.");
this.UpdateBoard();
break;
}
}
示例4: OnEvent
public void OnEvent(EventData photonEvent)
{
if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
Debug.Log(string.Format("OnEvent: {0}", photonEvent.ToString()));
int actorNr = -1;
PhotonPlayer originatingPlayer = null;
if (photonEvent.Parameters.ContainsKey(ParameterCode.ActorNr))
{
actorNr = (int)photonEvent[ParameterCode.ActorNr];
if (this.mActors.ContainsKey(actorNr))
{
originatingPlayer = (PhotonPlayer)this.mActors[actorNr];
}
//else
//{
// // the actor sending this event is not in actorlist. this is usually no problem
// if (photonEvent.Code != (byte)LiteOpCode.Join)
// {
// Debug.LogWarning("Received event, but we do not have this actor: " + actorNr);
// }
//}
}
switch (photonEvent.Code)
{
case EventCode.GameList:
{
this.mGameList = new Dictionary<string, RoomInfo>();
Hashtable games = (Hashtable)photonEvent[ParameterCode.GameList];
foreach (DictionaryEntry game in games)
{
string gameName = (string)game.Key;
this.mGameList[gameName] = new RoomInfo(gameName, (Hashtable)game.Value);
}
mGameListCopy = new RoomInfo[mGameList.Count];
mGameList.Values.CopyTo(mGameListCopy, 0);
SendMonoMessage(PhotonNetworkingMessage.OnReceivedRoomListUpdate);
break;
}
case EventCode.GameListUpdate:
{
Hashtable games = (Hashtable)photonEvent[ParameterCode.GameList];
foreach (DictionaryEntry room in games)
{
string gameName = (string)room.Key;
RoomInfo game = new RoomInfo(gameName, (Hashtable)room.Value);
if (game.removedFromList)
{
this.mGameList.Remove(gameName);
}
else
{
this.mGameList[gameName] = game;
}
}
this.mGameListCopy = new RoomInfo[this.mGameList.Count];
this.mGameList.Values.CopyTo(this.mGameListCopy, 0);
SendMonoMessage(PhotonNetworkingMessage.OnReceivedRoomListUpdate);
break;
}
case EventCode.QueueState:
if (photonEvent.Parameters.ContainsKey(ParameterCode.Position))
{
this.mQueuePosition = (int)photonEvent[ParameterCode.Position];
}
else
{
Debug.LogError("Event QueueState must contain position!");
}
if (this.mQueuePosition == 0)
{
// once we're un-queued, let's join the lobby or simply be "connected to master"
if (PhotonNetwork.autoJoinLobby)
{
this.State = global::PeerState.Authenticated;
this.OpJoinLobby(this.lobby);
}
else
{
this.State = global::PeerState.ConnectedToMaster;
NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnConnectedToMaster);
}
}
break;
case EventCode.AppStats:
// Debug.LogInfo("Received stats!");
this.mPlayersInRoomsCount = (int)photonEvent[ParameterCode.PeerCount];
this.mPlayersOnMasterCount = (int)photonEvent[ParameterCode.MasterPeerCount];
this.mGameCount = (int)photonEvent[ParameterCode.GameCount];
break;
case EventCode.Join:
// actorNr is fetched out of event above
//.........这里部分代码省略.........
示例5: OnEvent
public void OnEvent(EventData photonEvent)
{
if (this.DebugOut >= DebugLevel.INFO)
{
this.DebugReturn(DebugLevel.INFO, string.Format("OnEvent: {0}", photonEvent.ToString()));
}
int actorNr = -1;
PhotonPlayer originatingPlayer = null;
if (photonEvent.Parameters.ContainsKey(ParameterCode.ActorNr))
{
actorNr = (int)photonEvent[ParameterCode.ActorNr];
if (this.mActors.ContainsKey(actorNr))
{
originatingPlayer = (PhotonPlayer)this.mActors[actorNr];
}
// else
// {
// if (photonEvent.Code != (byte)LiteOpCode.Join)
// {
// Debug.LogError("Received event, but we do not have this actor: " + actorNr);//TODO: CACHE THIS EVENT FOR A FEW SECONDS AND TRY AGAIN?
// }
// }
}
switch (photonEvent.Code)
{
case EventCode.AzureNodeInfo:
{
byte currentNodeId = (byte)photonEvent[ParameterCode.AzureLocalNodeId];
byte masterNodeId = (byte)photonEvent[ParameterCode.AzureMasterNodeId];
if (currentNodeId != masterNodeId)
{
this.SwitchNode(masterNodeId);
}
else
{
this.nodeId = currentNodeId;
}
break;
}
case EventCode.GameList:
{
this.mGameList = new Dictionary<string, RoomInfo>();
Hashtable games = (Hashtable)photonEvent[ParameterCode.GameList];
foreach (DictionaryEntry game in games)
{
string gameName = (string)game.Key;
this.mGameList[gameName] = new RoomInfo(gameName, (Hashtable)game.Value);
}
mGameListCopy = new RoomInfo[mGameList.Count];
mGameList.Values.CopyTo(mGameListCopy, 0);
SendMonoMessage(PhotonNetworkingMessage.OnReceivedRoomList);
break;
}
case EventCode.GameListUpdate:
{
Hashtable games = (Hashtable)photonEvent[ParameterCode.GameList];
foreach (DictionaryEntry room in games)
{
string gameName = (string)room.Key;
Room game = new Room(gameName, (Hashtable)room.Value);
if (game.removedFromList)
{
this.mGameList.Remove(gameName);
}
else
{
this.mGameList[gameName] = game;
}
}
this.mGameListCopy = new RoomInfo[this.mGameList.Count];
this.mGameList.Values.CopyTo(this.mGameListCopy, 0);
SendMonoMessage(PhotonNetworkingMessage.OnReceivedRoomListUpdate);
break;
}
case EventCode.QueueState:
if (photonEvent.Parameters.ContainsKey(ParameterCode.Position))
{
this.mQueuePosition = (int)photonEvent[ParameterCode.Position];
}
else
{
this.DebugReturn(DebugLevel.ERROR, "Event QueueState must contain position!");
}
if (this.mQueuePosition == 0)
{
// PeerState oldState = this.State;
this.State = global::PeerState.Authenticated;
// if (oldState == PeerState.QueuedComingFromGameserver)
// {
//.........这里部分代码省略.........
示例6: AssertMessage
internal static void AssertMessage(Type from, string[] stack, EventData data, LogLevels level, string expected, Type expectedError)
{
DateTime time = DateTime.Now;
Assert.AreEqual(AppDomain.CurrentDomain.FriendlyName, data.AppDomainName);
Assert.AreEqual("nunit.core", data.EntryAssembly.ToLower());
Assert.Less(0, data.EventId);
Assert.IsTrue(data.EventTime <= DateTime.Now);
if (!System.Diagnostics.Debugger.IsAttached)
Assert.IsTrue((time - data.EventTime).TotalMilliseconds < 500);
if (expectedError == null)
Assert.IsNull(data.Exception);
else
Assert.AreEqual(data.Exception.GetType(), expectedError);
Assert.Less(0, data.FileColumn, "no FileColumn");
Assert.Less(0, data.FileLine, "no FileLine");
Assert.IsTrue(data.FileLocation.Contains(data.FileName));
Assert.AreEqual(from.Name + ".cs", Path.GetFileName(data.FileName));
if(expected != null) Assert.IsTrue(data.FullMessage.Contains(expected));
Assert.IsTrue(data.FullMessage.Contains(data.FileName));
//ROK - not always available, optimizations can disable
//Assert.Less(0, data.IlOffset, "no ILOffset");
Assert.Less(-1, data.IlOffset, "no ILOffset");
Assert.AreEqual(level, data.Level);
Assert.IsTrue(data.Location.Contains(String.Format("{0}.{1}(", from.FullName, data.MethodName)));
if (stack == null)
{
Assert.IsNull(data.LogCurrent);
Assert.IsNull(data.LogStack);
}
else
{
Assert.AreEqual(stack[stack.Length - 1], data.LogCurrent);
Assert.AreEqual(String.Join("::", stack), data.LogStack);
}
Assert.AreEqual(Thread.CurrentThread.ManagedThreadId, data.ManagedThreadId);
Assert.AreEqual(Thread.CurrentThread.Name, data.ManagedThreadName);
if (expected != null) Assert.AreEqual(expected, data.Message);
Assert.IsTrue(data.Method.StartsWith(from.FullName));
Assert.IsTrue(data.Method.EndsWith(")"));
Assert.IsNotNull(data.MethodArgs);
Assert.AreEqual(from.Assembly.GetName().Name, data.MethodAssembly);
Assert.AreEqual(from.Assembly.GetName().Version.ToString(), data.MethodAssemblyVersion);
Assert.IsNotEmpty(data.MethodName);
Assert.AreEqual(from.FullName, data.MethodType);
Assert.AreEqual(from.Name, data.MethodTypeName);
Assert.AreEqual(Log.Config.Output, data.Output);
Assert.AreEqual(Process.GetCurrentProcess().Id, data.ProcessId);
Assert.AreEqual("nunit-console", Path.GetFileNameWithoutExtension( data.ProcessName ).ToLower());
Assert.IsTrue(String.IsNullOrEmpty(data.ThreadPrincipalName));
Assert.IsNotEmpty(data.ToXml());
new XmlDocument().LoadXml(data.ToXml());
StringWriter sw = new StringWriter();
data.Write(sw);
if (expected != null) Assert.IsTrue(sw.ToString().Contains(expected));
if (expected != null)
{
Assert.AreEqual(expected, data.ToString("{Message}"));
Assert.AreEqual("!" + expected + "-", data.ToString("{Message:!%s-}"));
Assert.AreEqual(expected, data.ToString("{Message}{ThreadPrincipalName}"));
StringWriter wtr = new StringWriter();
data.Write(wtr, "{Message}");
Assert.AreEqual(expected, wtr.ToString().Trim());
}
}
示例7: OnEvent
public void OnEvent(EventData photonEvent)
{
if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
Debug.Log(string.Format("OnEvent: {0}", photonEvent.ToString()));
int actorNr = -1;
PhotonPlayer originatingPlayer = null;
if (photonEvent.Parameters.ContainsKey(ParameterCode.ActorNr))
{
actorNr = (int)photonEvent[ParameterCode.ActorNr];
originatingPlayer = this.GetPlayerWithId(actorNr);
//else
//{
// // the actor sending this event is not in actorlist. this is usually no problem
// if (photonEvent.Code != (byte)LiteOpCode.Join)
// {
// Debug.LogWarning("Received event, but we do not have this actor: " + actorNr);
// }
//}
}
switch (photonEvent.Code)
{
case PunEvent.OwnershipRequest:
{
Debug.LogError("Owner request has been deprecated with new changes.");
#if NEVER
int[] requestValues = (int[]) photonEvent.Parameters[ParameterCode.CustomEventContent];
int requestedViewId = requestValues[0];
int currentOwner = requestValues[1];
Debug.Log("Ev OwnershipRequest: " + photonEvent.Parameters.ToStringFull() + " ViewID: " + requestedViewId + " from: " + currentOwner + " Time: " + Environment.TickCount%1000);
PhotonView requestedView = PhotonView.Find(requestedViewId);
if (requestedView == null)
{
Debug.LogWarning("Can't find PhotonView of incoming OwnershipRequest. ViewId not found: " + requestedViewId);
break;
}
Debug.Log("Ev OwnershipRequest PhotonView.ownershipTransfer: " + requestedView.ownershipTransfer + " .ownerId: " + requestedView.ownerId + " isOwnerActive: " + requestedView.isOwnerActive + ". This client's player: " + PhotonNetwork.player.ToStringFull());
switch (requestedView.ownershipTransfer)
{
case OwnershipOption.Fixed:
Debug.LogWarning("Ownership mode == fixed. Ignoring request.");
break;
case OwnershipOption.Takeover:
if (currentOwner == requestedView.ownerId)
{
// a takeover is successful automatically, if taken from current owner
requestedView.ownerId = actorNr;
}
break;
case OwnershipOption.Request:
if (currentOwner == PhotonNetwork.player.ID || PhotonNetwork.player.isMasterClient)
{
if ((requestedView.ownerId == PhotonNetwork.player.ID) || (PhotonNetwork.player.isMasterClient && !requestedView.isOwnerActive))
{
SendMonoMessage(PhotonNetworkingMessage.OnOwnershipRequest, new object[] {requestedView, originatingPlayer});
}
}
break;
default:
break;
}
#endif
}
break;
case PunEvent.OwnershipTransfer:
{
int[] transferViewToUserID = (int[]) photonEvent.Parameters[ParameterCode.CustomEventContent];
Debug.Log("Ev OwnershipTransfer. ViewID " + transferViewToUserID[0] + " to: " + transferViewToUserID[1] + " Time: " + Environment.TickCount%1000);
int requestedViewId = transferViewToUserID[0];
int newOwnerId = transferViewToUserID[1];
PhotonView pv = PhotonView.Find(requestedViewId);
if (originatingPlayer == pv.owner || !pv.isOwnerActive && originatingPlayer.isMasterClient)
{
pv.ownerId = newOwnerId;
pv.RebuildNetworkRelavance();
if(newOwnerId == PhotonNetwork.player.ID)
pv.SendMessage("OnStartOwner", false, SendMessageOptions.DontRequireReceiver);
}
break;
}
case PunEvent.ControllerTransfer:
{
_HandleControllerTransfer(photonEvent, originatingPlayer);
break;
}
case PunEvent.ParentChanged:
{
_HandleParentChange(photonEvent, originatingPlayer);
//.........这里部分代码省略.........