Esempio n. 1
0
        // receive snapshots from server - you can cast JUMPSnapshotData to your own custom type
        public void OnPhotonEventCall(byte eventCode, object content, int senderId)
        {
            if (eventCode == JUMPCommand_Snapshot.JUMPSnapshot_EventCode)
            {
                JUMPCommand_Snapshot snap = new JUMPCommand_Snapshot((object[])content);

                if (OnSnapshotReceived != null)
                {
                    OnSnapshotReceived(snap);
                }
            }
        }
Esempio n. 2
0
        private void SendEventToClient(JUMPCommand_Snapshot commandEvent, int?playerID = null)
        {
            if (IsOfflinePlayMode)
            {
                JUMPMultiplayer.GameClient.OnPhotonEventCall(commandEvent.CommandEventCode, commandEvent.CommandData, JUMPMultiplayer.PlayerID);
            }
            else
            {
                RaiseEventOptions options = null;
                if (playerID.HasValue)
                {
                    options = new RaiseEventOptions();
                    options.TargetActors = new int[1] {
                        playerID.Value
                    };
                }

                PhotonNetwork.RaiseEvent(commandEvent.CommandEventCode, commandEvent.CommandData, sendReliable: true, options: options);
            }
        }
Esempio n. 3
0
        public void Tick(double ElapsedSeconds)
        {
            GameServerEngine.Tick(ElapsedSeconds);
            Bots.ForEach(x => x.Tick(ElapsedSeconds));

            // Is it time for a snapshot?
            SnapshotTimer += TimeSpan.FromSeconds(ElapsedSeconds);
            if (SnapshotTimer > SnapshotFrequency)
            {
                SnapshotTimer = TimeSpan.Zero;
                foreach (var player in Players)
                {
                    // Bots don't get a snapshot, they have access to the whole engine with the full state of all players and bots
                    if (!(player is IJUMPBot))
                    {
                        JUMPCommand_Snapshot snapCommand = GameServerEngine.TakeSnapshot(player.PlayerID);

                        SendEventToClient(snapCommand, player.PlayerID);
                    }
                }
            }
        }
Esempio n. 4
0
 private void RaiseOnSnapshotReceived(JUMPCommand_Snapshot snapshot)
 {
     LogVerbose(() => FormatLogMessage("JUMP.RaiseOnSnapshotReceived"));
     OnSnapshotReceived.Invoke(snapshot);
 }