本文整理汇总了C#中PhotonView.CheckRelevance方法的典型用法代码示例。如果您正苦于以下问题:C# PhotonView.CheckRelevance方法的具体用法?C# PhotonView.CheckRelevance怎么用?C# PhotonView.CheckRelevance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhotonView
的用法示例。
在下文中一共展示了PhotonView.CheckRelevance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RPC
internal void RPC(PhotonView view, string methodName, PhotonPlayer[] players, bool encrypt, params object[] parameters)
{
if (this.blockSendingGroups.Contains(view.group))
{
return; // Block sending on this group
}
if (view.viewID < 1) //TODO: check why 0 should be illegal
{
Debug.LogError("Illegal view ID:" + view.viewID + " method: " + methodName + " GO:" + view.gameObject.name);
}
//ts: changed RPCs to a one-level hashtable as described in internal.txt
Hashtable rpcEvent = new Hashtable();
rpcEvent[(byte)0] = (int)view.viewID; // LIMITS PHOTONVIEWS&PLAYERS
if (view.prefix > 0)
{
rpcEvent[(byte)1] = (short)view.prefix;
}
rpcEvent[(byte)2] = this.ServerTimeInMilliSeconds;
// send name or shortcut (if available)
int shortcut = 0;
if (rpcShortcuts.TryGetValue(methodName, out shortcut))
{
rpcEvent[(byte)5] = (byte)shortcut; // LIMITS RPC COUNT
}
else
{
rpcEvent[(byte)3] = methodName;
}
if (parameters != null && parameters.Length > 0)
{
for(int i = 0; i < parameters.Length; i++)
{
object parameter = parameters[i];
if (parameter == null)
continue;
Type parameterType = parameter.GetType();
if(!parameterType.IsAssignableFrom(typeof(PhotonView)) && parameterType.IsAssignableFrom(typeof(Component)))
{
Component component = parameter as Component;
Assert.IsNotNull(component);
PhotonView parameterView = component.GetComponent<PhotonView>();
if(!parameterView)
Debug.LogError("Components must be attatched to an object iwth a photon view in order to be sent over the network.");
parameters[i] = parameterView;
}
else if(parameterType.IsArray && !parameterType.GetElementType().IsAssignableFrom(typeof(PhotonView)) && parameterType.GetElementType().IsAssignableFrom(typeof(Component)))
{
Component[] components = parameter as Component[];
Assert.IsNotNull(components);
PhotonView[] parameterViews = new PhotonView[components.Length];
for(int j = 0; j < components.Length; j++)
{
Component component = components[j];
if(component == null)
{
parameterViews[j] = null;
}
else
{
PhotonView parameterElementView = component.GetComponent<PhotonView>();
if(!parameterElementView)
Debug.LogError("Components must be attatched to an object iwth a photon view in order to be sent over the network.");
parameterViews[j] = parameterElementView;
}
}
}
}
rpcEvent[(byte) 4] = (object[]) parameters;
}
bool isMine = view.isMine;
bool isController = view.isController;
bool allowFullCom = true;
PhotonPlayer owner = view.owner;
List<int> playerIds = new List<int>(players.Length);
foreach (PhotonPlayer player in players)
{
if (isMine && (player.isLocal || view.CheckRelevance(player)))
playerIds.Add(player.ID);
else if(!isMine)
{
if (allowFullCom)
playerIds.Add(player.ID);
else if (isController && owner == player)
playerIds.Add(player.ID);
}
//.........这里部分代码省略.........