当前位置: 首页>>代码示例>>C#>>正文


C# RaiseEventOptions类代码示例

本文整理汇总了C#中RaiseEventOptions的典型用法代码示例。如果您正苦于以下问题:C# RaiseEventOptions类的具体用法?C# RaiseEventOptions怎么用?C# RaiseEventOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RaiseEventOptions类属于命名空间,在下文中一共展示了RaiseEventOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SendInstantiate

    internal Hashtable SendInstantiate(string prefabName, Vector3 position, Quaternion rotation, int group, int[] viewIDs, object[] data, bool isGlobalObject)
    {
        // first viewID is now also the gameobject's instantiateId
        int instantiateId = viewIDs[0];   // LIMITS PHOTONVIEWS&PLAYERS

        //TODO: reduce hashtable key usage by using a parameter array for the various values
        Hashtable instantiateEvent = new Hashtable(); // This players info is sent via ActorID
        instantiateEvent[(byte)0] = prefabName;

        if (position != Vector3.zero)
        {
            instantiateEvent[(byte)1] = position;
        }

        if (rotation != Quaternion.identity)
        {
            instantiateEvent[(byte)2] = rotation;
        }

        if (group != 0)
        {
            instantiateEvent[(byte)3] = group;
        }

        // send the list of viewIDs only if there are more than one. else the instantiateId is the viewID
        if (viewIDs.Length > 1)
        {
            instantiateEvent[(byte)4] = viewIDs; // LIMITS PHOTONVIEWS&PLAYERS
        }

        if (data != null)
        {
            instantiateEvent[(byte)5] = data;
        }

        if (this.currentLevelPrefix > 0)
        {
            instantiateEvent[(byte)8] = this.currentLevelPrefix;    // photonview's / object's level prefix
        }

        instantiateEvent[(byte)6] = this.ServerTimeInMilliSeconds;
        instantiateEvent[(byte)7] = instantiateId;


        RaiseEventOptions options = new RaiseEventOptions();
        options.CachingOption = (isGlobalObject) ? EventCaching.AddToRoomCacheGlobal : EventCaching.AddToRoomCache;

        this.OpRaiseEvent(PunEvent.Instantiation, instantiateEvent, true, options);
        return instantiateEvent;
    }
开发者ID:JonasSkaug,项目名称:afgangsprojekt-team-tj,代码行数:50,代码来源:NetworkingPeer.cs

示例2: ServerCleanInstantiateAndDestroy

    /// <summary>
    /// Removes an instantiation event from the server's cache. Needs id and actorNr of player who instantiated.
    /// </summary>
    private void ServerCleanInstantiateAndDestroy(int instantiateId, int creatorId)
    {
        Hashtable removeFilter = new Hashtable();
        removeFilter[(byte)7] = instantiateId;

        RaiseEventOptions options = new RaiseEventOptions() { CachingOption = EventCaching.RemoveFromRoomCache, TargetActors = new int[] { creatorId } };
        this.OpRaiseEvent(PunEvent.Instantiation, removeFilter, true, options);
        //this.OpRaiseEvent(PunEvent.Instantiation, removeFilter, true, 0, new int[] { actorNr }, EventCaching.RemoveFromRoomCache);

        Hashtable evData = new Hashtable();
        evData[(byte)0] = instantiateId;
        options = null;
        if (instantiateId > 0 && instantiateId < PhotonNetwork.MAX_VIEW_IDS)
        {
            // if the view gets loaded with the scene, the EvDestroy must be cached
            // reason: joining players will load the obj and have to destroy it (too)
            options = new RaiseEventOptions();
            options.CachingOption = EventCaching.AddToRoomCacheGlobal;
            Debug.Log("Destroying GO as global. ID: " + instantiateId);
        }
        this.OpRaiseEvent(PunEvent.Destroy, evData, true, options);
    }
开发者ID:JonasSkaug,项目名称:afgangsprojekt-team-tj,代码行数:25,代码来源:NetworkingPeer.cs

示例3: OpRaiseEvent

    public override bool OpRaiseEvent(byte eventCode, object customEventContent, bool sendReliable, RaiseEventOptions raiseEventOptions)
    {
        if (PhotonNetwork.offlineMode)
        {
            return false;
        }

        return base.OpRaiseEvent(eventCode, customEventContent, sendReliable, raiseEventOptions);
    }
开发者ID:JonasSkaug,项目名称:afgangsprojekt-team-tj,代码行数:9,代码来源:NetworkingPeer.cs

示例4: RPC


//.........这里部分代码省略.........
        }

        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);
            }
        }

        RaiseEventOptions options = new RaiseEventOptions() { TargetActors = playerIds.ToArray(), Encrypt = encrypt };
        this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options);
    }
开发者ID:Awesome-MQP,项目名称:Storybook,代码行数:101,代码来源:NetworkingPeer.cs

示例5: OpCleanRpcBuffer

    /// <summary>Cleans server RPCs for PhotonView (without any further checks).</summary>
    public void OpCleanRpcBuffer(PhotonView view)
    {
        Hashtable rpcFilterByViewId = new Hashtable();
        rpcFilterByViewId[(byte)0] = view.viewID;

        RaiseEventOptions options = new RaiseEventOptions() { CachingOption = EventCaching.RemoveFromRoomCache };
        this.OpRaiseEvent(PunEvent.RPC, rpcFilterByViewId, true, options);
        //this.OpRaiseEvent(PunEvent.RPC, rpcFilterByViewId, true, 0, EventCaching.RemoveFromRoomCache, ReceiverGroup.Others);
    }
开发者ID:JonasSkaug,项目名称:afgangsprojekt-team-tj,代码行数:10,代码来源:NetworkingPeer.cs

示例6: RPC

    /// RPC Hashtable Structure
    /// (byte)0 -> (int) ViewId (combined from actorNr and actor-unique-id)
    /// (byte)1 -> (short) prefix (level)
    /// (byte)2 -> (int) server timestamp
    /// (byte)3 -> (string) methodname
    /// (byte)4 -> (object[]) parameters
    /// (byte)5 -> (byte) method shortcut (alternative to name)
    ///
    /// This is sent as event (code: 200) which will contain a sender (origin of this RPC).

    internal void RPC(PhotonView view, string methodName, PhotonTargets target, params object[] parameters)
    {
        if (this.blockSendingGroups.Contains(view.group))
        {
            return; // Block sending on this group
        }

        if (view.viewID < 1)
        {
            Debug.LogError("Illegal view ID:" + view.viewID + " method: " + methodName + " GO:" + view.gameObject.name);
        }

        if (PhotonNetwork.logLevel >= PhotonLogLevel.Full)
            Debug.Log("Sending RPC \"" + methodName + "\" to " + target);


        //ts: changed RPCs to a one-level hashtable as described in internal.txt
        Hashtable rpcEvent = new Hashtable();
        rpcEvent[(byte)0] = (int)view.viewID; // LIMITS NETWORKVIEWS&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)
        {
            rpcEvent[(byte)4] = (object[])parameters;
        }

        // Check scoping
        if (target == PhotonTargets.All)
        {
            RaiseEventOptions options = new RaiseEventOptions() { InterestGroup = (byte)view.group };
            this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options);
            //this.OpRaiseEvent(PunEvent.RPC, (byte)view.group, rpcEvent, true, 0);

            // Execute local
            this.ExecuteRPC(rpcEvent, this.mLocalActor);
        }
        else if (target == PhotonTargets.Others)
        {
            RaiseEventOptions options = new RaiseEventOptions() { InterestGroup = (byte)view.group };
            this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options);
        }
        else if (target == PhotonTargets.AllBuffered)
        {
            RaiseEventOptions options = new RaiseEventOptions() { CachingOption = EventCaching.AddToRoomCache};
            this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options);

            // Execute local
            this.ExecuteRPC(rpcEvent, this.mLocalActor);
        }
        else if (target == PhotonTargets.OthersBuffered)
        {
            RaiseEventOptions options = new RaiseEventOptions() { CachingOption = EventCaching.AddToRoomCache };
            this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options);
        }
        else if (target == PhotonTargets.MasterClient)
        {
            if (this.mMasterClient == this.mLocalActor)
            {
                this.ExecuteRPC(rpcEvent, this.mLocalActor);
            }
            else
            {
                RaiseEventOptions options = new RaiseEventOptions() { Receivers = ReceiverGroup.MasterClient };
                this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options);
            }
        }
        else if (target == PhotonTargets.AllViaServer)
        {
            RaiseEventOptions options = new RaiseEventOptions() { InterestGroup = (byte)view.group, Receivers = ReceiverGroup.All };
            this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options);
            if (PhotonNetwork.offlineMode)
            {
                this.ExecuteRPC(rpcEvent, this.mLocalActor);
            }
//.........这里部分代码省略.........
开发者ID:JonasSkaug,项目名称:afgangsprojekt-team-tj,代码行数:101,代码来源:NetworkingPeer.cs

示例7: RunViewUpdate

    // this is called by Update() and in Unity that means it's single threaded.
    public void RunViewUpdate()
    {
        if (!PhotonNetwork.connected || PhotonNetwork.offlineMode || this.mActors == null)
        {
            return;
        }

        // no need to send OnSerialize messages while being alone (these are not buffered anyway)
        if (this.mActors.Count <= 1)
        {
            #if !PHOTON_DEVELOP
            return;
            #endif
        }

        /* Format of the data hashtable:
         * Hasthable dataPergroup*
         *  [(byte)0] = PhotonNetwork.ServerTimestamp;
         *  [(byte)1] = currentLevelPrefix;  OPTIONAL!
         *
         *  [(short)10] = data 1
         *  [(short)11] = data 2 ...
         */

        int countOfUpdatesToSend = 0;
        foreach (PhotonView view in this.photonViewList.Values)
        {
            // a client only sends updates for active, synchronized PhotonViews that are under it's control (isMine)
            if (view.synchronization == ViewSynchronization.Off || view.isMine == false || view.gameObject.activeInHierarchy == false)
            {
                continue;
            }

            if (this.blockSendingGroups.Contains(view.group))
            {
                continue; // Block sending on this group
            }

            // call the PhotonView's serialize method(s)
            object[] evData = this.OnSerializeWrite(view);
            if (evData == null)
            {
                continue;
            }

            if (view.synchronization == ViewSynchronization.ReliableDeltaCompressed || view.mixedModeIsReliable)
            {
                Hashtable groupHashtable = null;
                bool found = this.dataPerGroupReliable.TryGetValue(view.group, out groupHashtable);
                if (!found)
                {
                    groupHashtable = new Hashtable(10);
                    this.dataPerGroupReliable[view.group] = groupHashtable;
                }

                groupHashtable.Add((short)(groupHashtable.Count+10), evData);
                countOfUpdatesToSend++;
            }
            else
            {
                Hashtable groupHashtable = null;
                bool found = this.dataPerGroupUnreliable.TryGetValue(view.group, out groupHashtable);
                if (!found)
                {
                    groupHashtable = new Hashtable(10);
                    this.dataPerGroupUnreliable[view.group] = groupHashtable;
                }

                groupHashtable.Add((short)(groupHashtable.Count+10), evData);
                countOfUpdatesToSend++;
            }
        }   // all views serialized

        // if we didn't produce anything to send, don't do it
        if (countOfUpdatesToSend == 0)
        {
            return;
        }

        // we got updates to send. every group is send it's own message and unreliable and reliable are split as well
        RaiseEventOptions options = new RaiseEventOptions();
        #if PHOTON_DEVELOP
        options.Receivers = ReceiverGroup.All;
        #endif

        foreach (int groupId in this.dataPerGroupReliable.Keys)
        {
            options.InterestGroup = (byte)groupId;
            Hashtable groupHashtable = this.dataPerGroupReliable[groupId];
            if (groupHashtable.Count == 0)
            {
                continue;
            }

            groupHashtable[(byte)0] = PhotonNetwork.ServerTimestamp;
            if (this.currentLevelPrefix >= 0)
            {
                groupHashtable[(byte)1] = this.currentLevelPrefix;
            }
//.........这里部分代码省略.........
开发者ID:yuvadius,项目名称:need4bit,代码行数:101,代码来源:NetworkingPeer.cs

示例8: OpRemoveCompleteCacheOfPlayer

 /// <summary>
 /// Instead removing RPCs or Instantiates, this removed everything cached by the actor.
 /// </summary>
 /// <param name="actorNumber"></param>
 public void OpRemoveCompleteCacheOfPlayer(int actorNumber)
 {
     RaiseEventOptions options = new RaiseEventOptions() { CachingOption = EventCaching.RemoveFromRoomCache, TargetActors = new int[] { actorNumber } };
     this.OpRaiseEvent(0, null, true, options);
     //this.OpRaiseEvent(0, null, true, 0, new int[] { actorNumber }, EventCaching.RemoveFromRoomCache);
 }
开发者ID:JonasSkaug,项目名称:afgangsprojekt-team-tj,代码行数:10,代码来源:NetworkingPeer.cs

示例9: NewPhotonEvent

    /// <summary>
    /// Create Photon Events
    /// </summary>
    /// <param name="id"></param>
    /// <param name="content"></param>
    /// <param name="b"></param>
    /// <param name="options"></param>
    public void NewPhotonEvent(int id, object content, bool b, RaiseEventOptions options)
    {
        if (!isConnected)
            return;

        byte mByte = (byte)id;
        PhotonNetwork.RaiseEvent(mByte, content, b, options);
    }
开发者ID:tegleg,项目名称:mfp,代码行数:15,代码来源:bl_PhotonHelper.cs

示例10: LateUpdate

    void LateUpdate()
    {
        if (_queuedActions.Count > 0)
        {
            Hashtable[] actionsToSend = new Hashtable[_queuedActions.Count];
            for (int i=0; i< _queuedActions.Count ; i++)
            {
                actionsToSend[i] = _queuedActions[i].Encode();
            }

            RaiseEventOptions options = new RaiseEventOptions();
            options.Receivers = ExitGames.Client.Photon.ReceiverGroup.All;
            PhotonNetwork.RaiseEvent((byte)87, actionsToSend, true, options);
            _queuedActions.Clear();
        }
    }
开发者ID:Barnaff,项目名称:NetherWars2,代码行数:16,代码来源:NetworkManager.cs

示例11: RaiseEvent

    /// <summary>
    /// Sends fully customizable events in a room. Events consist of at least an EventCode (1..199) and can have content.
    /// </summary>
    /// <remarks>
    /// To receive the events someone sends, register your handling method in PhotonNetwork.OnEventCall.
    /// 
    /// Example: 
    /// private void OnEventHandler(byte eventCode, object content, PhotonPlayer sender)
    /// { Debug.Log("OnEventHandler"); }
    /// 
    /// PhotonNetwork.OnEventCall += this.OnEventHandler;
    /// 
    /// 
    /// The eventContent is optional. To be able to send something, it must be a "serializable type", something that
    /// the client can turn into a byte[] basically. Most basic types and arrays of them are supported, including
    /// Unity's Vector2, Vector3, Quaternion. Transforms or classes some project defines are NOT supported!
    /// You can make your own class a "serializable type" by following the example in CustomTypes.cs.
    /// 
    /// 
    /// The RaiseEventOptions have some (less intuitive) combination rules:
    /// If you set targetActors (an array of PhotonPlayer.ID values), the receivers parameter gets ignored.
    /// When using event caching, the targetActors, receivers and interestGroup can't be used. Buffered events go to all.
    /// When using cachingOption removeFromRoomCache, the eventCode and content are actually not sent but used as filter.
    /// </remarks>
    /// <param name="eventCode">A byte identifying the type of event. You might want to use a code per action or to signal which content can be expected. Allowed: 1..199.</param>
    /// <param name="eventContent">Some serializable object like string, byte, integer, float (etc) and arrays of those. Hashtables with byte keys are good to send variable content.</param>
    /// <param name="sendReliable">Makes sure this event reaches all players. It gets acknowledged, which requires bandwidth and it can't be skipped (might add lag in case of loss).</param>
    /// <param name="options">Allows more complex usage of events. If null, RaiseEventOptions.Default will be used (which is fine).</param>
    /// <returns>False if event could not be sent</returns>
    public static bool RaiseEvent(byte eventCode, object eventContent, bool sendReliable, RaiseEventOptions options)
    {
        if (!inRoom || eventCode <= 0 || eventCode >= 200)
        {
            return false;
        }

        return networkingPeer.OpRaiseEvent(eventCode, eventContent, sendReliable, options);
    }
开发者ID:prithviprn,项目名称:SpaceFerret,代码行数:38,代码来源:PhotonNetwork.cs

示例12: PreBeginPlay

    /*****************************************************************************************
     *| GAME METHODS | COROUTINES |
     *****************************************************************************************/
    IEnumerator PreBeginPlay( )
    {
        //Debug
        while ( Application.loadedLevelName != MatchLevel )
        {
            yield return null;
        }

        //Initiate the grid system
        GridSystem.InitializeGrid( );

        //Initiate the actor manager
        ACTOR_MANAGER = gameObject.AddComponent<ActorManager>( );
        ActorManager.Instance = ACTOR_MANAGER;

        //Initiate the phase manager
        PHASE_MANAGER = gameObject.AddComponent<PhaseManager>( );

        while ( !GridSystem.IsInitialized )
        {
            yield return null;
        }

        //All systems done, we're now in game and loaded
        CurrentGameState = GameState.GAME;
        bInputEnabled = false;
        GameObject waitingModal = ModalWindow.Display( "WaitingForPlayersPanel" );

        while ( bInEvent )
        {
            yield return null;
        }

        //Set as ready
        Hashtable readyProperties = new Hashtable( )
        {
            {"Ready", true}
        };

        PhotonNetwork.player.SetCustomProperties( readyProperties );

        //On the server
        if ( PhotonNetwork.isMasterClient )
        {
            //Wait until all players are ready
            while ( !AllPlayersReady ) yield return null;

            //Transfer actor ownership
            int baseNum = 0;
            foreach ( PhotonPlayer p in PhotonNetwork.playerList )
            {
                PlayerBase baseToBeAssigned = PlayerBase.AllBases[ baseNum ];
                if ( baseToBeAssigned != null )
                {
                    //Raise PhotonView assignment event
                    byte evCode = 0;
                    int[] content = new int[]
                    {
                        baseToBeAssigned.photonView.viewID,
                        p.ID
                    };

                    RaiseEventOptions op = new RaiseEventOptions( );
                    op.Receivers = ExitGames.Client.Photon.ReceiverGroup.All;

                    PhotonNetwork.RaiseEvent( evCode, content, true, op );
                    baseNum++;
                }
            }

            //Once all players are ready, begin the game
            photonView.RPC( "RPCBeginGame", PhotonTargets.AllBuffered );

            //Destroy the modal
            GameObject.Destroy( waitingModal.gameObject );
        }
        else
        {
            //Wait until the game starts
            while ( !bGameStarted ) yield return null;
        }

        //Destroy the modal
        if ( waitingModal != null )
        {
            GameObject.Destroy( waitingModal.gameObject );
        }

        yield return null;
    }
开发者ID:MrSuicideFish,项目名称:TBTD,代码行数:93,代码来源:GameManager.cs

示例13: RunViewUpdate


//.........这里部分代码省略.........
         *  OPTIONAL: [(byte)1] = currentLevelPrefix;
         *  +  data
         */

        relevanceCount++;
        foreach (KeyValuePair<int, PhotonView> kvp in this.photonViewList)
        {
            PhotonView view = kvp.Value;

            if (view.shouldSync && view.isMine && view.HasSpawned)
            {
#if UNITY_2_6_1 || UNITY_2_6 || UNITY_3_0 || UNITY_3_0_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5
                if (!view.gameObject.active)
                {
                    continue; // Only on actives
                }
#else
                if (!view.gameObject.activeInHierarchy)
                {
                    continue; // Only on actives
                }
#endif
                if (this.blockSendingGroups.Contains(view.group))
                {
                    continue; // Block sending on this group
                }

                OnSerializeReliableWrite(view, false);
                OnSerializeUnreliableWrite(view);
            }
        }

        PhotonPlayer[] players = PhotonNetwork.otherPlayers;
        foreach (KeyValuePair<int, PhotonView> pair in photonViewList)
        {
            PhotonView view = pair.Value;

            
            foreach (PhotonPlayer player in players)
            {
                if (!view.shouldSync || !view.isMine || !view.HasSpawned)
                    continue;

                if (!view.CheckRelevance(player))
                    continue;

#if UNITY_2_6_1 || UNITY_2_6 || UNITY_3_0 || UNITY_3_0_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5
                if (!view.gameObject.active)
                {
                    continue; // Only on actives
                }
#else
                if (!view.gameObject.activeInHierarchy)
                {
                    continue; // Only on actives
                }
#endif
                if (this.blockSendingGroups.Contains([email protected]))
                {
                    continue; // Block sending on this group
                }

                dataPerGroupReliable.Clear();
                dataPerGroupUnreliable.Clear();

                if (!dataPerGroupReliable.ContainsKey(view.group))
                {
                    dataPerGroupReliable[view.group] = new Hashtable();
                    dataPerGroupReliable[view.group][(byte)0] = this.ServerTimeInMilliSeconds;
                }

                Hashtable reliableGroupHashtable = dataPerGroupReliable[view.group];
                reliableGroupHashtable.Add((short)reliableGroupHashtable.Count, view.reliableSerializedData);

                if (!dataPerGroupUnreliable.ContainsKey(view.group))
                {
                    dataPerGroupUnreliable[view.group] = new Hashtable();
                    dataPerGroupUnreliable[view.group][(byte)0] = this.ServerTimeInMilliSeconds;
                }

                Hashtable unreliableGroupHashtable = dataPerGroupUnreliable[view.group];
                unreliableGroupHashtable.Add((short)unreliableGroupHashtable.Count, view.unreliableSerializedData);

                //Send the messages: every group is send in it's own message and unreliable and reliable are split as well
                RaiseEventOptions options = new RaiseEventOptions();
                options.TargetActors = new int[] {player.ID};

                foreach (KeyValuePair<int, Hashtable> kvp in dataPerGroupReliable)
                {
                    options.InterestGroup = (byte)kvp.Key;
                    this.OpRaiseEvent(PunEvent.SendSerializeReliable, kvp.Value, true, options);
                }
                foreach (KeyValuePair<int, Hashtable> kvp in dataPerGroupUnreliable)
                {
                    options.InterestGroup = (byte)kvp.Key;
                    this.OpRaiseEvent(PunEvent.SendSerialize, kvp.Value, false, options);
                }
            }
        }
    }
开发者ID:Awesome-MQP,项目名称:Storybook,代码行数:101,代码来源:NetworkingPeer.cs

示例14: OpRemoveFromServerInstantiationsOfPlayer

 private void OpRemoveFromServerInstantiationsOfPlayer(int actorNr)
 {
     // removes all "Instantiation" events of player actorNr. this is not an event for anyone else
     RaiseEventOptions options = new RaiseEventOptions() { CachingOption = EventCaching.RemoveFromRoomCache, TargetActors = new int[] { actorNr } };
     this.OpRaiseEvent(PunEvent.Instantiation, null, true, options);
     //this.OpRaiseEvent(PunEvent.Instantiation, null, true, 0, new int[] { actorNr }, EventCaching.RemoveFromRoomCache);
 }
开发者ID:JonasSkaug,项目名称:afgangsprojekt-team-tj,代码行数:7,代码来源:NetworkingPeer.cs

示例15: RPC

    /// RPC Hashtable Structure
    /// (byte)0 -> (int) ViewId (combined from actorNr and actor-unique-id)
    /// (byte)1 -> (short) prefix (level)
    /// (byte)2 -> (int) server timestamp
    /// (byte)3 -> (string) methodname
    /// (byte)4 -> (object[]) parameters
    /// (byte)5 -> (byte) method shortcut (alternative to name)
    ///
    /// This is sent as event (code: 200) which will contain a sender (origin of this RPC).
    internal void RPC(PhotonView view, string methodName, PhotonTargets target, PhotonPlayer player, bool encrypt, params object[] parameters)
    {
        if (this.blockSendingGroups.Contains(view.group))
        {
            return; // Block sending on this group
        }

        if (view.viewID < 1)
        {
            Debug.LogError("Illegal view ID:" + view.viewID + " method: " + methodName + " GO:" + view.gameObject.name);
        }

        if (PhotonNetwork.logLevel >= PhotonLogLevel.Full)
        {
            Debug.Log("Sending RPC \"" + methodName + "\" to target: " + target + " or player:" + player + ".");
        }

        //ts: changed RPCs to a one-level hashtable as described in internal.txt
        Hashtable rpcEvent = new Hashtable();
        rpcEvent[(byte)0] = (int)view.viewID; // LIMITS NETWORKVIEWS&PLAYERS
        if (view.prefix > 0)
        {
            rpcEvent[(byte)1] = (short)view.prefix;
        }
        rpcEvent[(byte)2] = PhotonNetwork.ServerTimestamp;

        // 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)
        {
            rpcEvent[(byte)4] = (object[])parameters;
        }

        // if sent to target player, this overrides the target
        if (player != null)
        {
            if (this.LocalPlayer.ID == player.ID)
            {
                this.ExecuteRpc(rpcEvent, player);
            }
            else
            {
                RaiseEventOptions options = new RaiseEventOptions() { TargetActors = new int[] { player.ID }, Encrypt = encrypt };
                this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options);
            }

            return;
        }

        // send to a specific set of players
        if (target == PhotonTargets.All)
        {
            RaiseEventOptions options = new RaiseEventOptions() { InterestGroup = (byte)view.group, Encrypt = encrypt };
            this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options);

            // Execute local
            this.ExecuteRpc(rpcEvent, this.LocalPlayer);
        }
        else if (target == PhotonTargets.Others)
        {
            RaiseEventOptions options = new RaiseEventOptions() { InterestGroup = (byte)view.group, Encrypt = encrypt };
            this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options);
        }
        else if (target == PhotonTargets.AllBuffered)
        {
            RaiseEventOptions options = new RaiseEventOptions() { CachingOption = EventCaching.AddToRoomCache, Encrypt = encrypt };
            this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options);

            // Execute local
            this.ExecuteRpc(rpcEvent, this.LocalPlayer);
        }
        else if (target == PhotonTargets.OthersBuffered)
        {
            RaiseEventOptions options = new RaiseEventOptions() { CachingOption = EventCaching.AddToRoomCache, Encrypt = encrypt };
            this.OpRaiseEvent(PunEvent.RPC, rpcEvent, true, options);
        }
        else if (target == PhotonTargets.MasterClient)
        {
            if (this.mMasterClientId == this.LocalPlayer.ID)
            {
                this.ExecuteRpc(rpcEvent, this.LocalPlayer);
            }
//.........这里部分代码省略.........
开发者ID:yuvadius,项目名称:need4bit,代码行数:101,代码来源:NetworkingPeer.cs


注:本文中的RaiseEventOptions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。