Exemplo n.º 1
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);
        }
        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);
        }
        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);
        }
        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();
        }
        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();
        }