OpRaiseEvent() public method

Send an event with custom code/type and any content to the other players in the same room.
This override explicitly uses another parameter order to not mix it up with the implementation for Hashtable only.
public OpRaiseEvent ( byte eventCode, object customEventContent, bool sendReliable, RaiseEventOptions, raiseEventOptions ) : bool
eventCode byte Identifies this type of event (and the content). Your game's event codes can start with 0.
customEventContent object Any serializable datatype (including Hashtable like the other OpRaiseEvent overloads).
sendReliable bool If this event has to arrive reliably (potentially repeated if it's lost).
raiseEventOptions RaiseEventOptions, Contains (slightly) less often used options. If you pass null, the default options will be used.
return bool
        public void OpRaiseEvent(byte eventCode, object message, bool reliable, int[] toPlayers)
        {
            if (loadBalancingPeer.PeerState != ExitGames.Client.Photon.PeerStateValue.Connected)
            {
                return;
            }

            RaiseEventOptions eventOptions = new RaiseEventOptions();

            eventOptions.TargetActors = toPlayers;

            loadBalancingPeer.OpRaiseEvent(eventCode, message, reliable, eventOptions);
        }
Exemplo n.º 2
0
        public void OpRaiseEvent(byte i_EventCode, object i_Message, bool i_Reliable, int[] i_ToPlayers)
        {
            if (m_LoadBalancingPeer.PeerState != ExitGames.Client.Photon.PeerStateValue.Connected)
            {
                return;
            }

            RaiseEventOptions eventOptions = new RaiseEventOptions();

            eventOptions.TargetActors = i_ToPlayers;

            m_LoadBalancingPeer.OpRaiseEvent(i_EventCode, i_Message, i_Reliable, eventOptions);
        }
Exemplo n.º 3
0
    internal void SendPlayerInfo(LoadBalancingPeer peer)
    {
        if (peer == null)
        {
            return;
        }

        // Setting up the content of the event. Here we want to send a player's info: nickName and color.
        Hashtable eventInfo = new Hashtable();

        eventInfo.Add((byte)EventKey.PlayerName, this.NickName);
        eventInfo.Add((byte)EventKey.PlayerReady, this.PlayerReady);

        // The event's code must be of type byte, so we have to cast it. We do this above as well, to get routine ;)
        peer.OpRaiseEvent((byte)EventCode.PlayerInfo, eventInfo, null, SendOptions.SendReliable);
    }
Exemplo n.º 4
0
        /// <summary>
        /// Raises an event with the player's position data.
        /// "isSendReliable"        decides if these events are reliable or unreliable.
        /// "Game.RaiseEncrypted"   decided if the event is encrypted.
        ///
        /// Once more: Neither sending reliable nor encrypting this event makes sense in a game.
        /// Both is just done as showcase!
        /// </summary>
        /// <remarks>
        /// Each running client will know many players, but only one is the "local" one, which
        /// actually sends it's position! See Game.SendPostion(), which choses the local player only.
        /// </remarks>
        /// <param name="peer"></param>
        internal void SendEvMove(LoadBalancingPeer peer)
        {
            if (peer == null)
            {
                return;
            }

            // prepare the event data we want to send
            // this could contain more key-values as needed by a game (think: rotation, y-coordinate)
            Hashtable eventContent = new Hashtable();

            eventContent.Add((byte)DemoEventKey.PlayerPositionX, (byte)this.posX);
            eventContent.Add((byte)DemoEventKey.PlayerPositionY, (byte)this.posY);

            // if encryption is turned off, we simply use OpRaiseEvent
            peer.OpRaiseEvent((byte)DemoEventCode.PlayerMove, eventContent, isSendReliable, null);
        }
Exemplo n.º 5
0
    internal void SendPlayerLocation(LoadBalancingPeer peer)
    {
        if (peer == null)
        {
            return;
        }

        Hashtable eventContent = new Hashtable();

        eventContent.Add((byte)EventKey.PlayerPositionX, (float)this.XPosition);
        eventContent.Add((byte)EventKey.PlayerPositionY, (float)this.YPosition);

        peer.OpRaiseEvent((byte)EventCode.PlayerMove, eventContent, new RaiseEventOptions {
            Receivers = ReceiverGroup.All
        }, new SendOptions()
        {
            DeliveryMode = DeliveryMode.UnreliableUnsequenced
        });
    }
    public void SendClaimWin()
    {
        var player = (RealtimePlayer)LocalPlayer;

        if (LoadBalancingPeer == null)
        {
            return;
        }

        Hashtable eventContent = new Hashtable();

        eventContent.Add((byte)EventKey.PlayerName, player.NickName);

        LoadBalancingPeer.OpRaiseEvent((byte)EventCode.ClaimWin, eventContent, new RaiseEventOptions {
            Receivers = ReceiverGroup.All
        }, new SendOptions()
        {
            DeliveryMode = DeliveryMode.Reliable
        });
    }
Exemplo n.º 7
0
        public void OpRaiseEvent(Byte eventCode, Object message, Boolean reliable, Int32[] toPlayers)
        {
            if (_loadBalancingPeer.PeerState != PeerStateValue.Connected)
            {
                return;
            }

            _parameters[ParameterCode.Code] = eventCode;
            _parameters[ParameterCode.Data] = message;

            _eventOptions.TargetActors = toPlayers;

            if (eventCode != MessageTypes.SEND_CODE)
            {
                _loadBalancingPeer.OpRaiseEvent(eventCode, message, reliable, _eventOptions);
            }
            else
            {
                PhotonNetwork.networkingPeer.SendOperation(OperationCode.RaiseEvent, _parameters, _sendOperationOptions);
            }

            _loadBalancingPeer.SendOutgoingCommands();
        }