Beispiel #1
0
        }        // doInstantiate

        /// <summary>
        /// Runs the sanity check on game object. It must have for example a PlayMakerPhotonGameObjectProxy component attached for example.
        /// </summary>
        bool runSanityCheckOnGameObject()
        {
            if (!PhotonNetwork.isMasterClient)
            {
                return(false);
            }

            // get the photon proxy for Photon RPC access
            GameObject go = GameObject.Find("PlayMaker Photon Proxy");

            if (go == null)
            {
                return(false);
            }

            // get the proxy component
            PlayMakerPhotonProxy _proxy = go.GetComponent <PlayMakerPhotonProxy>();

            if (_proxy == null)
            {
                return(false);
            }

            return(_proxy.ValidatePreFlightCheckOnGameObject(gameObject.Value));
        }        //doRunSanityCheckOnGameObject
Beispiel #2
0
    /// <summary>
    /// compose this message to dispatch the associated global Fsm Event.
    /// </summary>
    void OnJoinedRoom()
    {
        if (debug)
        {
            Debug.Log("PLayMaker Photon proxy:OnJoinedRoom: " + Time.timeSinceLevelLoad);
        }

        /*
         * //------- THAT WORKS ---------//
         * var list = new List<PlayMakerFSM>(PlayMakerFSM.FsmList);
         *
         * foreach (PlayMakerFSM fsm in list){
         *
         *      if (true)
         *      {
         *              fsm.SendEvent("PHOTON / JOINED ROOM"); // fine
         *      }else{
         *              fsm.Fsm.ProcessEvent(FsmEvent.GetFsmEvent("PHOTON / JOINED ROOM")); // too late. same as PlayMakerFSM.BroadcastEvent()
         *      }
         * }
         * //-------
         *
         * // PlayMakerFSM.BroadcastEvent ("PHOTON / JOINED ROOM");  DO NOT WORK, too late.
         */

        PlayMakerPhotonProxy.BroadCastToAll("PHOTON / JOINED ROOM");

        Debug.Log("post PHOTON / JOINED ROOM broadcasting");
    }
        void DoREC()
        {
            // get the photon proxy for Photon RPC access
            GameObject go = GameObject.Find("PlayMaker Photon Proxy");

            if (go == null)
            {
                return;
            }


            if (remoteEvent != null && remoteEvent.IsGlobal == false)
            {
                return;
            }

            PhotonTargets _photonTargets = getPhotonTargets();

            // get the proxy component
            PlayMakerPhotonProxy _proxy = go.GetComponent <PlayMakerPhotonProxy>();

            if (_proxy == null)
            {
                return;
            }

            if (!stringData.IsNone && stringData.Value != "")
            {
                _proxy.PhotonRpcBroacastFsmEventWithString(_photonTargets, remoteEvent.Name, stringData.Value);
            }
            else
            {
                _proxy.PhotonRpcBroacastFsmEvent(photonTargets, remoteEvent.Name);
            }
        }
Beispiel #4
0
    // get the Playmaker Photon proxy fsm.
    void Awake()
    {
        Debug.Log("Player awake");

        // get the photon proxy for Photon Fsm Proxy to send event.
        GameObject go = GameObject.Find("PlayMaker Photon Proxy");

        if (go == null)
        {
            Debug.LogError("Working with photon network require that you add a 'PlayMaker Photon Proxy' component to the gameObject. You can do so from the menu 'PlayMaker Photon/components/Add photon proxy to scene'");
            return;
        }

        // get the proxy to set the debug flag.
        PlayMakerPhotonProxy _proxy = go.GetComponent <PlayMakerPhotonProxy>();

        if (_proxy != null)
        {
            debug = _proxy.debug;
        }

        // get the Fsm for reference when sending events.
        fsmProxy = go.GetComponent <PlayMakerFSM>();
        if (fsmProxy == null)
        {
            return;
        }

        _proxy.SanitizeGameObject(this.gameObject);
    }    // Awake
        void DoREC()
        {
            // get the photon proxy for Photon RPC access
            GameObject go = GameObject.Find("PlayMaker Photon Proxy");

            if (go == null)
            {
                return;
            }


            if (remoteEvent != null && remoteEvent.IsGlobal == false)
            {
                return;
            }

            PhotonTargets _photonTargets = getPhotonTargets();

            // get the proxy component
            PlayMakerPhotonProxy _proxy = go.GetComponent <PlayMakerPhotonProxy>();

            if (_proxy == null)
            {
                Debug.LogWarning("PlayMakerPhotonProxy is missing");
                return;
            }

            if (eventTarget.target == FsmEventTarget.EventTarget.BroadcastAll)
            {
                if (!stringData.IsNone && stringData.Value != "")
                {
                    _proxy.PhotonRpcBroacastFsmEventWithString(_photonTargets, remoteEvent.Name, stringData.Value);
                }
                else
                {
                    _proxy.PhotonRpcBroacastFsmEvent(photonTargets, remoteEvent.Name);
                }
            }
            else
            {
                PlayMakerPhotonGameObjectProxy _goProxy = Owner.GetComponent <PlayMakerPhotonGameObjectProxy>();
                if (_proxy == null)
                {
                    Debug.LogWarning("PlayMakerPhotonProxy is missing");
                    return;
                }

                if (!stringData.IsNone && stringData.Value != "")
                {
                    _goProxy.PhotonRpcSendFsmEventWithString(_photonTargets, remoteEvent.Name, stringData.Value);
                }
                else
                {
                    _goProxy.PhotonRpcSendFsmEvent(photonTargets, remoteEvent.Name);
                }
            }
        }
        void DoRPC()
        {
            // get the photon proxy for Photon RPC access
            GameObject go = GameObject.Find("PlayMaker Photon Proxy");

            if (go == null)
            {
                return;
            }


            if (remoteEvent != null && remoteEvent.IsGlobal == false)
            {
                return;
            }

            RpcTarget _photonTargets = getPhotonTargets();

            // get the proxy component
            PlayMakerPhotonProxy _proxy = go.GetComponent <PlayMakerPhotonProxy>();

            if (_proxy == null)
            {
                Debug.LogWarning("PlayMakerPhotonProxy is missing");
                return;
            }

            if (eventTarget.target == FsmEventTarget.EventTarget.BroadcastAll)
            {
                if (data.Length > 0)
                {
                    //_proxy.PhotonRpcFsmBroadcastEventWithData(_photonTargets,remoteEvent.Name,data);
                }
                else
                {
                    _proxy.PhotonRpcBroacastFsmEvent(rpcTarget, remoteEvent.Name);
                }
            }
            else
            {
                PlayMakerPhotonGameObjectProxy _goProxy = Owner.GetComponent <PlayMakerPhotonGameObjectProxy>();
                if (_proxy == null)
                {
                    Debug.LogWarning("PlayMakerPhotonProxy is missing");
                    return;
                }

                if (data.Length > 0)
                {
                    _goProxy.PhotonRpcSendFsmEventWithData(_photonTargets, remoteEvent.Name, data);
                }
                else
                {
                    _goProxy.PhotonRpcSendFsmEvent(rpcTarget, remoteEvent.Name);
                }
            }
        }
Beispiel #7
0
        bool getRoomProperties()
        {
            Room _room     = PhotonNetwork.room;
            bool _isInRoom = _room != null;

            isInRoom.Value = _isInRoom;

            if (_isInRoom)
            {
                if (isInRoomEvent != null)
                {
                    Fsm.Event(isInRoomEvent);
                }
            }
            else
            {
                if (isNotInRoomEvent != null)
                {
                    Fsm.Event(isNotInRoomEvent);
                }
                return(false);
            }

            // we get the room properties
            RoomName.Value    = _room.name;
            maxPlayers.Value  = _room.maxPlayers;
            open.Value        = _room.open;
            visible.Value     = _room.visible;
            playerCount.Value = _room.playerCount;

            // get the custom properties
            int i = 0;

            foreach (FsmString key in customPropertyKeys)
            {
                if (_room.customProperties.ContainsKey(key.Value))
                {
                    PlayMakerPhotonProxy.ApplyValueToFsmVar(this.Fsm, customPropertiesValues[i], _room.customProperties[key.Value]);
                }
                else
                {
                    return(false);
                }
                i++;
            }

            return(true);
        }
        void SetPlayerProperty()
        {
            if (customPropertyValue == null)
            {
                LogError("customPropertyValue is null ");
                return;
            }

            PhotonPlayer _player = PhotonNetwork.player;

            ExitGames.Client.Photon.Hashtable _prop = new ExitGames.Client.Photon.Hashtable();
            Log(" set key " + customPropertyKey.Value + "=" + PlayMakerPhotonProxy.GetValueFromFsmVar(this.Fsm, customPropertyValue));

            _prop[customPropertyKey.Value] = PlayMakerPhotonProxy.GetValueFromFsmVar(this.Fsm, customPropertyValue);
            _player.SetCustomProperties(_prop);
        }
Beispiel #9
0
        void SetRoomProperty()
        {
            Room _room     = PhotonNetwork.room;
            bool _isInRoom = _room != null;

            if (!_isInRoom)
            {
                Fsm.Event(failureEvent);
                return;
            }

            ExitGames.Client.Photon.Hashtable _prop = new ExitGames.Client.Photon.Hashtable();

            _prop[customPropertyKey.Value] = PlayMakerPhotonProxy.GetValueFromFsmVar(this.Fsm, customPropertyValue);
            _room.SetCustomProperties(_prop);
            Fsm.Event(successEvent);
        }
        bool getLastMessagePlayerProperties()
        {
            // get the photon proxy for Photon RPC access
            GameObject go = GameObject.Find("PlayMaker Photon Proxy");

            if (go == null)
            {
                return(false);
            }

            // get the proxy component
            PlayMakerPhotonProxy _proxy = go.GetComponent <PlayMakerPhotonProxy>();

            if (_proxy == null)
            {
                return(false);
            }

            PhotonPlayer _player = _proxy.lastMessagePhotonPlayer;

            if (_player == null)
            {
                return(false);
            }

            name.Value           = _player.name;
            ID.Value             = _player.ID;
            isLocal.Value        = _player.isLocal;
            isMasterClient.Value = _player.isMasterClient;

            // get the custom properties
            int i = 0;

            foreach (FsmString key in customPropertyKeys)
            {
                if (!_player.customProperties.ContainsKey(key.Value))
                {
                    return(false);
                }
                PlayMakerPhotonProxy.ApplyValueToFsmVar(this.Fsm, customPropertiesValues[i], _player.customProperties[key.Value]);
                i++;
            }

            return(true);
        }
        void DoREC()
        {
            // get the photon proxy for Photon RPC access
            GameObject go = GameObject.Find("PlayMaker Photon Proxy");

            if (go == null)
            {
                return;
            }

            if (remoteEvent.Name == "")
            {
                return;
            }

            // get the proxy component
            PlayMakerPhotonProxy _proxy = go.GetComponent <PlayMakerPhotonProxy>();

            if (_proxy == null)
            {
                return;
            }

            PhotonPlayer _target = getPhotonPLayerTarget();

            if (_target.ID == -1)
            {
                return;
            }

            if (!stringData.IsNone && stringData.Value != "")
            {
                _proxy.PhotonRpcFsmBroadcastEventWithString(_target, remoteEvent.Name, stringData.Value);
            }
            else
            {
                _proxy.PhotonRpcBroadcastFsmEvent(_target, remoteEvent.Name);
            }
        }
        bool getLastDisconnectCause()
        {
            // get the photon proxy for Photon RPC access
            GameObject go = GameObject.Find("PlayMaker Photon Proxy");

            if (go == null)
            {
                return(false);
            }

            // get the proxy component
            PlayMakerPhotonProxy _proxy = go.GetComponent <PlayMakerPhotonProxy>();

            if (_proxy == null)
            {
                return(false);
            }

            cause.Value = _proxy.lastDisconnectCause.ToString();

            return(true);
        }
        bool getOwnerProperties()
        {
            if (_networkView == null)
            {
                return(false);
            }

            PhotonPlayer _player = _networkView.owner;

            if (_player == null)
            {
                return(false);
            }

            name.Value           = _player.name;
            ID.Value             = _player.ID;
            isLocal.Value        = _player.isLocal;
            isMasterClient.Value = _player.isMasterClient;

            // get the custom properties
            int i = 0;

            foreach (FsmString key in customPropertyKeys)
            {
                if (_player.customProperties.ContainsKey(key.Value))
                {
                    PlayMakerPhotonProxy.ApplyValueToFsmVar(this.Fsm, customPropertiesValues[i], _player.customProperties[key.Value]);
                }
                else
                {
                    return(false);
                }
                i++;
            }

            return(true);
        }
Beispiel #14
0
        public override void OnEnter()
        {
            string _roomName = null;

            if (!string.IsNullOrEmpty(roomName.Value))
            {
                _roomName = roomName.Value;
            }


            ExitGames.Client.Photon.Hashtable _props = new ExitGames.Client.Photon.Hashtable();

            int i = 0;

            foreach (FsmString _prop in customPropertyKey)
            {
                _props[_prop.Value] = PlayMakerPhotonProxy.GetValueFromFsmVar(this.Fsm, customPropertyValue[i]);
                i++;
            }


            string[] lobbyProps = new string[lobbyCustomProperties.Length];

            int j = 0;

            foreach (FsmString _visibleProp in lobbyCustomProperties)
            {
                lobbyProps[j] = _visibleProp.Value;
                j++;
            }

            PhotonNetwork.CreateRoom(_roomName, isVisible.Value, isOpen.Value, maxNumberOfPLayers.Value, _props, lobbyProps);


            Finish();
        }
Beispiel #15
0
    void BuildSceneWizard()
    {
        // JFF : Adds the playmaker proxy, and only display that button if the scene doesn't have it already.
        // mabe make it in red or a lot clearer
        GUILayout.BeginHorizontal();
        GUILayout.Label("Scene", EditorStyles.boldLabel, GUILayout.Width(100));

        if (!PlayMakerPhotonEditorUtility.IsSceneSetup())
        {
            GUI.color = PlayMakerPhotonEditorUtility.lightOrange;
            if (GUILayout.Button(new GUIContent("Add Photon System to the scene", "Required for Photon and PlayMaker to work together")))
            {
                PlayMakerPhotonEditorUtility.DoCreateRpcProxy();
            }
            GUI.color = Color.white;
            if (FsmEditorGUILayout.HelpButton("Required for scenes that will use Photon"))
            {
                EditorUtility.OpenWithDefaultApp(PhotonGOPhotonProxyHelpUrl);
            }
        }
        else
        {
            GUI.color = Color.green;
            GUILayout.Label("The scene is set up properly.", "box", GUILayout.ExpandWidth(true));
        }
        GUI.color = Color.white;
        GUILayout.EndHorizontal();

        if (!PlayMakerPhotonEditorUtility.IsSceneSetup())
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("", EditorStyles.boldLabel, GUILayout.Width(100));
            GUILayout.Label("You need to first add the Photon System Proxy Prefab if you want this scene to work for multi users and PlayMaker", "box", GUILayout.ExpandWidth(true));
            GUILayout.EndHorizontal();
        }
        GUILayout.Space(22);


        // JFF : Adds a photon view to the selected gameObject, will automatically add the gameObject proxy if required.
        if (Selection.activeGameObject)
        {
            // check that it is not the photon proxy
            PlayMakerPhotonProxy prox = Selection.activeGameObject.GetComponent <PlayMakerPhotonProxy>();

            if (prox != null)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Photon Proxy", EditorStyles.boldLabel, GUILayout.Width(100));
                GUILayout.Label("This GameObject must not be edited. It is the bridge between Photon and PlayMaker", "box", GUILayout.ExpandWidth(true));


                if (FsmEditorGUILayout.HelpButton("Photon Proxy must not be edited"))
                {
                    EditorUtility.OpenWithDefaultApp(PhotonGOPhotonProxyHelpUrl);
                }

                GUILayout.EndHorizontal();
            }
            else
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Component", EditorStyles.boldLabel, GUILayout.Width(100));

                //object[] objects = Selection.GetFiltered(typeof(PlayMakerFSM),SelectionMode.Unfiltered);

                //PlayMakerFSM fsm = objects[0] as PlayMakerFSM;
                GUILayout.BeginVertical();
                GUILayout.BeginHorizontal();
                if (GUILayout.Button(new GUIContent("Add network-ready FSM to  '" + Selection.activeGameObject.name + "'", "Required for Fsm that will use Photon")))
                {
                    PlayMakerPhotonEditorUtility.DoCreateFsmWithPhotonView();
                }

                if (FsmEditorGUILayout.HelpButton("Required on GameObject that will use Photon network engine"))
                {
                    EditorUtility.OpenWithDefaultApp(PhotonGOFsmSetupHelpUrl);
                }

                GUILayout.EndHorizontal();

                GUILayout.Space(12);

                GUILayout.BeginHorizontal();
                if (GUILayout.Button(new GUIContent("Add Photon View to '" + Selection.activeGameObject.name + "'", "Required on GameObject that will use Photon")))
                {
                    PlayMakerPhotonEditorUtility.DoAddPhotonView();
                }

                if (FsmEditorGUILayout.HelpButton("Required on GameObject that will be instantiated over the Photon network"))
                {
                    EditorUtility.OpenWithDefaultApp(PhotonGOPhotonViewSetupHelpUrl);
                }

                GUILayout.EndHorizontal();
                GUILayout.EndVertical();

                GUILayout.EndHorizontal();
            }


            GUILayout.Space(22);
        }
    }
        public override void OnEnter()
        {
            //check if we are in a room or not
            if (PhotonNetwork.room == null)
            {
                Fsm.Event(notInRoomEvent);
                Finish();
                return;
            }

            if (nextPlayerIndex == 0)
            {
                if (includeSelf.Value)
                {
                    players = PhotonNetwork.playerList;
                }
                else
                {
                    players = PhotonNetwork.otherPlayers;
                }
            }

            if (players.Length == 0)
            {
                nextPlayerIndex = 0;
                Fsm.Event(noPlayersEvent);
                Fsm.Event(finishedEvent);
                Finish();
                return;
            }

            if (nextPlayerIndex >= players.Length)
            {
                nextPlayerIndex = 0;
                Fsm.Event(finishedEvent);
                Finish();
                return;
            }

            _player = players[nextPlayerIndex];

            // we get the player properties
            playerID.Value       = _player.ID;
            playerIsLocal.Value  = _player.isLocal;
            playerName.Value     = _player.name;
            playerIsMasterClient = _player.isMasterClient;


            // get the custom properties
            int i = 0;

            foreach (FsmString key in customPropertyKeys)
            {
                PlayMakerPhotonProxy.ApplyValueToFsmVar(this.Fsm, customPropertiesValues[i], _player.customProperties[key.Value]);
                i++;
            }


            nextPlayerIndex++;

            Fsm.Event(loopEvent);

            Finish();
        }
        public override void OnEnter()
        {
            //check if we are in a room or not
            //if (PhotonNetwoek.is)
            if (!PhotonNetwork.insideLobby)
            {
                Fsm.Event(notInLobbyEvent);
                Finish();
                return;
            }

            if (nextRoomIndex == 0)
            {
                rooms = PhotonNetwork.GetRoomList();
            }

            if (rooms.Length == 0)
            {
                nextRoomIndex = 0;
                Fsm.Event(noRoomsEvent);
                Fsm.Event(finishedEvent);
                Finish();
                return;
            }

            if (nextRoomIndex >= rooms.Length)
            {
                nextRoomIndex = 0;
                Fsm.Event(finishedEvent);
                Finish();
                return;
            }

            _room = rooms[nextRoomIndex];

            // we get the room properties
            RoomName.Value    = _room.name;
            maxPlayers.Value  = _room.maxPlayers;
            open.Value        = _room.open;
            visible.Value     = _room.visible;
            playerCount.Value = _room.playerCount;


            // get the custom properties
            int i = 0;

            foreach (FsmString key in customPropertyKeys)
            {
                if (_room.customProperties.ContainsKey(key.Value))
                {
                    PlayMakerPhotonProxy.ApplyValueToFsmVar(this.Fsm, customPropertiesValues[i], _room.customProperties[key.Value]);
                }
                i++;
            }


            nextRoomIndex++;

            Fsm.Event(loopEvent);

            Finish();
        }