Example #1
0
    public void Client_UpdatePlayerHealthAndAlive(NetworkPlayer targetplayer, bool IsAlive, int CurrentHealth)
    {
        MPPlayer player = MultiplayerManager.GetMPPlayer(targetplayer);

        player.PlayerIsAlive = IsAlive;
        player.PlayerHealth  = CurrentHealth;
    }
Example #2
0
    public void Start()
    {
        alreadyPlayer1Spawned = false;

        otherPlayer = FindObjectOfType <MPPlayer>();



        if (isServer)
        {
            players = GameObject.FindGameObjectsWithTag("Player");
            Debug.Log(players.Length);
            player1 = players[0]; // wird wohl nach Adam Riese der Server sein...?!

            if (players.Length >= 2)
            {
                player2 = players[1];
            }
        }

        serverPlayerPlace = otherPlayer.player1.transform;

        if (players.Length >= 2)
        {
            clientPlayerPlace = otherPlayer.player2.transform;
        }
    }
Example #3
0
    //FUNCTION IF MASTERCLIENT IS DISCONNECTED SO SWITCH NEW MASTERCLIENT
    void OnMasterClientSwitched(PhotonPlayer newMasterClient)
    {
        MPPlayer tempPlayer = null;

        foreach (MPPlayer p in playersList)
        {
            if (p.photonP == newMasterClient)
            {
                tempPlayer = p;
            }
        }
        if (tempPlayer != null)
        {
            tempPlayer.Master = true;
        }
        if (GlobalVariables.m_instance.GameIsReady)
        {
            int countInGame = GameManager.m_instance.CountPlayerInGame();
            print(countInGame);
            if (countInGame <= 2)
            {
                GameManager.m_instance.StartCoroutine(GameManager.m_instance.CloseLoadingAndLaunchReset());
                GlobalUI.m_instance.Loading.SetActive(true);
            }
            else
            {
                GameManager.m_instance.StartCoroutine(GameManager.m_instance.LaunchPrint());
            }
        }
        else
        {
            GameManager.m_instance.LaunchTimer = true;
        }
    }
Example #4
0
 void ClientAddPlayerToList(string playerName, NetworkPlayer view)
 {
     MPPlayer team = new MPPlayer();
     team.teamName = playerName;
     team.playerNetwork = view;
     playersList.Add(team);
 }
Example #5
0
    //IF MASTERCLIENT ADD IN YOUR MEMBERS LIST, NEW PLAYER CONNECTED AND LAUNCH "RpcAddPlayerToList"
    public void CmdAddPlayerToList(PhotonPlayer uniqueID, string pse, bool master, int globalID)
    {
        if (!PhotonNetwork.isMasterClient)
        {
            return;
        }
        if (PhotonNetwork.room.PlayerCount == PhotonNetwork.room.MaxPlayers)
        {
            PhotonNetwork.room.IsVisible = false;
            PhotonNetwork.room.IsOpen    = false;
        }
        MPPlayer addlist = new MPPlayer();

        addlist.id       = globalID;
        addlist.pseudo   = pse;
        addlist.Master   = master;
        addlist.IDphoton = uniqueID;
        playersList.Add(addlist);

        PlayersInRoom = PhotonNetwork.room.PlayerCount;

        if (master)
        {
            pse = "<color=#a52a2aff>" + pse + "</color>";
        }
        ListMemberText.text += pse + "\n";
        RpcAddPlayerToList();
    }
Example #6
0
    void RpcGameOverEffects(bool serverWon)
    {
        // aus Sicht des Gewinners:
        otherPlayer = FindObjectOfType <MPPlayer>();

        serverPlayerPlace = otherPlayer.player1.transform;
        clientPlayerPlace = otherPlayer.player2.transform;

        MPPlayer serverPlayer = serverPlayerPlace.GetComponentInParent <MPPlayer>();
        MPPlayer clientPlayer = clientPlayerPlace.GetComponentInParent <MPPlayer>();


        // Beim Host wird es richtig angezeigt, beim Server falsch...

        if (serverWon)
        {
            Instantiate(winningFanfare.gameObject, serverPlayer.transform);
        }
        else
        {
            Instantiate(winningFanfare.gameObject, clientPlayer.transform);
        }

        //restartMenuCanvas.enabled = true;


        //restartMenu.SetActive(true);

        // unnötig?
        //Destroy(serverPlayer);
        //Destroy(clientPlayer);
    }
Example #7
0
    [PunRPC]    //THE MASTERCLIENT RECEIVE "CmdAddPlayerToList" SENDING BY NEW PLAYER CONNECTED AND LAUNCH "RpcAddPlayerToList"
    public void CmdAddPlayerToList(PhotonPlayer photonP, string pse, bool master, int globalID)
    {
        if (!PhotonNetwork.isMasterClient)          //IF YOU NOT THE MASTERCLIENT
        {
            return;
        }
        if (PhotonNetwork.room.PlayerCount == PhotonNetwork.room.MaxPlayers) //IF PLAYERS IN ROOM IS EQUAL OF PLAYERS MAXIMUM IN ROOM
        {
            PhotonNetwork.room.IsVisible = false;                            //HIDE ROOM IN MATCHMAKING PHOTON
            PhotonNetwork.room.IsOpen    = false;                            //CLOSE ROOM IN MATCHMAKING PHOTON
        }
        //MASTERCLIENT ADDED IN ITS LIST OF PLAYERS, NEW PLAYER
        MPPlayer addlist = new MPPlayer();

        addlist.id      = globalID;
        addlist.pseudo  = pse;
        addlist.Master  = master;
        addlist.photonP = photonP;
        playersList.Add(addlist);

        GameManager.m_instance.VerifIsGameReady(photonP);
        GameManager.m_instance.CountInRoom();
        GlobalUI.m_instance.putInPlay.text = "$" + GlobalVariables.m_instance.PutInPlay.ToString("0.##");
        RpcAddPlayerToList();
    }
Example #8
0
    public void OnRealTimeMessageReceived(bool reliable, string senderId, byte[] data)
    {
        string rawData = data.ConvertToString();

        string[] dataClumps = rawData.Split(' ');

        string dataHeader = dataClumps[0];

        LogDebugMessage("New MSG: " + dataHeader + " from " + senderId);

        switch (dataHeader)
        {
        case _introductionConst: {
            MPPlayer theNewPlayer = new MPPlayer(PlayGamesPlatform.Instance.RealTime.GetConnectedParticipants().Find(x => x.ParticipantId == senderId));

            OtherPlayerJoinedRoom(theNewPlayer);
        }

        break;

        case _gameStartingConst: {
            if (CurState != RoomStates.GameInProgress)
            {
                GameStarted();

                LogDebugMessage("Game Starting!");
            }
        }

        break;

        case _playerChangedState: {
            MPPlayer senderPlayer = _playersInRoom.Find(x => x.GetID() == senderId);

            if (senderPlayer != null)
            {
                UserStates oldState = senderPlayer.GetState();

                senderPlayer.ChangeStateTo((UserStates)int.Parse(dataClumps[1]));

                //check for player leaving
                if (senderPlayer.GetState() == UserStates.Disconnected)
                {
                    OtherPlayerLeftRoom(senderPlayer);
                }

                //check to see if they are setting themselves to ready
                else if (
                    (oldState == UserStates.Ready && senderPlayer.GetState() != UserStates.Ready) ||                    //changing from ready to not ready
                    (oldState != UserStates.Ready && senderPlayer.GetState() == UserStates.Ready)                       //changing from not ready to ready
                    )
                {
                    PlayerChangedReady(senderPlayer);
                }
            }
        }
        break;
        }
    }
Example #9
0
    void Client_AddPlayerToList(string PlayerName, NetworkPlayer PlayerNetwork)
    {
        MPPlayer temps = new MPPlayer();

        temps.PlayerName    = PlayerName;
        temps.PlayerNetwork = PlayerNetwork;
        PlayerList.Add(temps);
    }
Example #10
0
    void ClientAddPlayerToList(string playerName, NetworkPlayer view)
    {
        MPPlayer team = new MPPlayer();

        team.teamName      = playerName;
        team.playerNetwork = view;
        playersList.Add(team);
    }
Example #11
0
    /// <summary>
    /// Called when we are told that another player has joined the room
    /// Adds to the players in room list
    /// </summary>
    /// <param name="thePlayer">The player who joined.</param>
    void OtherPlayerJoinedRoom(MPPlayer thePlayer)
    {
        _playersInRoom.Add(thePlayer);
        thePlayer.ChangeStateTo(UserStates.Connected);

        if (_playersInRoom.Count >= _minOpponents)
        {
            CurState = RoomStates.WaitingForPlayersReady;
        }
    }
Example #12
0
    /// <summary>
    /// Called when we are told that another player has left the room.
    /// Removes the player from the player list
    /// </summary>
    /// <param name="thePlayer">The player.</param>
    void OtherPlayerLeftRoom(MPPlayer thePlayer)
    {
        LogDebugMessage("Other player left room");

        _playersInRoom.Remove(thePlayer);
        thePlayer.ChangeStateTo(UserStates.Disconnected);

        if (_playersInRoom.Count < _minOpponents)
        {
            CurState = RoomStates.WaitingForPlayersConnected;
        }
    }
Example #13
0
    /// <summary>
    /// Called when we have joined a game room
    /// </summary>
    void JoinedRoomSucessfuly()
    {
        LogDebugMessage("Joined room");

        _playersInRoom = new List <MPPlayer>();

        OurPlayer = new MPPlayer(PlayGamesPlatform.Instance.RealTime.GetSelf());
        OurPlayer.PlayerStateChangedEvent += OurUserStateChanged;
        _playersInRoom.Add(OurPlayer);

        CurState = RoomStates.WaitingForPlayersConnected;

        SendMessageToAll(_introductionConst);
    }
Example #14
0
    void Client_AddPlayerToList(string playerName, NetworkPlayer view)
    {
        MPPlayer newPlayer = new MPPlayer();

        newPlayer.PlayerName    = playerName;
        newPlayer.PlayerNetwork = view;

        PlayerList.Add(newPlayer);

        if (Network.player == view)
        {
            MyPlayer = newPlayer;
        }
    }
Example #15
0
    public void OnPeersDisconnected(string[] peers)
    {
        LogDebugMessage("Peers disconnected " + peers);

        foreach (string disconnectedPeer in peers)
        {
            MPPlayer thePlayer = _playersInRoom.Find(x => x.GetID() == disconnectedPeer);

            if (thePlayer != null)
            {
                OtherPlayerLeftRoom(thePlayer);
            }
        }
    }
Example #16
0
    //REFRESH THE LIST PLAYERS AFTER PLAYER DISCONNECTED
    public void CheckList(PhotonPlayer photonP)
    {
        if (PhotonNetwork.isMasterClient)
        {
            GameManager.m_instance.StopAllCoroutines();

            MPPlayer tempPlayer = null;
            foreach (MPPlayer p in playersList)
            {
                if (p.photonP == photonP)
                {
                    tempPlayer = p;
                }
            }
            if (tempPlayer != null)
            {
                if (tempPlayer.NbrCardBoards > 0)
                {
                    GlobalVariables.m_instance.NbrPlayersIsReady--;
                }
                playersList.Remove(tempPlayer);
                Destroy(tempPlayer.BarTop);
            }
            GameManager.m_instance.CountInRoom();

            if (GlobalVariables.m_instance.GameIsReady)
            {
                if (playersList.Count < 2)
                {
                    GameManager.m_instance.StartCoroutine(GameManager.m_instance.CloseLoadingAndLaunchReset());
                    GlobalUI.m_instance.Loading.SetActive(true);
                }
                else
                {
                    GameManager.m_instance.StartCoroutine(GameManager.m_instance.LaunchPrint());
                }
            }
            else
            {
                GameManager.m_instance.LaunchTimer = true;
            }
            RpcAddPlayerToList();

            if (PhotonNetwork.room.PlayerCount < PhotonNetwork.room.MaxPlayers)
            {
                PhotonNetwork.room.IsVisible = true;
                PhotonNetwork.room.IsOpen    = true;
            }
        }
    }
Example #17
0
    void Client_AddPlayerToList(string playername, NetworkPlayer view)
    {
        MPPlayer tempplayer = new MPPlayer();

        tempplayer.PlayerName    = playername;
        tempplayer.PlayerNetwork = view;
        PlayerList.Add(tempplayer);
        if (Network.player == view)
        {
            Debug.Log("Client_AddPlayerToList,if (Network.player == view), called");
            MyPlayer = tempplayer;
            GameObject play = Network.Instantiate(PlayerManagerPrefab, Vector3.zero, Quaternion.identity, 5) as GameObject;
            //play.GetComponent<PlayerManager>().thisplayer = MyPlayer; //Remove This Part
        }
    }
Example #18
0
    void client_addPlayerToList(string playerName, NetworkPlayer view)
    {
        MPPlayer temp = new MPPlayer();

        temp.playerName    = playerName;
        temp.playerNetwork = view;
        playerList.Add(temp);

        if (Network.player == view)
        {
            myPlayer = temp;
            // instantiate client's input sender
            Network.Instantiate(multiplayerInputHandlerPrefab, Vector3.zero, Quaternion.identity, 5);
        }
    }
Example #19
0
    void Client_RemovePlayer(NetworkPlayer view)
    {
        MPPlayer temppl = null;

        foreach (MPPlayer pl in PlayerList)
        {
            if (pl.PlayerNetwork == view)
            {
                temppl = pl;
            }
        }
        if (temppl != null)
        {
            PlayerList.Remove(temppl);
        }
    }
Example #20
0
    /// <summary>
    /// Called when the user has changed their multiplayer state
    /// </summary>
    /// <param name="player">Player.</param>
    public void PlayerChangedReady(MPPlayer player)
    {
        bool everyoneReady = true;

        //check to see if everyone in the room is ready
        foreach (MPPlayer loopedPlayer in _playersInRoom)
        {
            everyoneReady &= loopedPlayer.GetState() == UserStates.Ready;
        }

        if (everyoneReady == true)
        {
            SendMessageToAll(_gameStartingConst);
            GameStarted();
        }
    }
Example #21
0
    void RemovePlayer(NetworkPlayer PlayerNetwork)
    {
        MPPlayer temps = null;

        foreach (MPPlayer pl in PlayerList)
        {
            if (pl.PlayerNetwork == PlayerNetwork)
            {
                temps = pl;
            }
        }
        if (temps != null)
        {
            PlayerList.Remove(temps);
        }
    }
Example #22
0
    //REFRESH LIST PLAYERS AFTER PLAYER DISCONNECTED
    public void CheckList(PhotonPlayer idview)
    {
        if (PhotonNetwork.isMasterClient)
        {
            if (PhotonNetwork.room.PlayerCount < PhotonNetwork.room.MaxPlayers)
            {
                PhotonNetwork.room.IsVisible = true;
                PhotonNetwork.room.IsOpen    = true;
            }

            MPPlayer tempPlayer = null;
            foreach (MPPlayer player in playersList)
            {
                if (player.IDphoton == idview)
                {
                    tempPlayer = player;
                }
            }
            if (tempPlayer != null)
            {
                playersList.Remove(tempPlayer);
            }

            PlayersInRoom = PhotonNetwork.room.PlayerCount;

            ListMemberText.text = "";

            for (int i = 0; i < PlayersInRoom; i++)
            {
                string pse = "";
                playersList [i].id = i + 1;
                if (playersList [i].IDphoton.IsMasterClient)
                {
                    playersList [i].Master = true;
                    pse = "<color=#a52a2aff>" + playersList [i].pseudo + "</color>";
                }
                else
                {
                    playersList [i].Master = false;
                    pse = playersList [i].pseudo;
                }
                ListMemberText.text += pse + "\n";
            }
            TitleRoom.text = "Table N°" + PhotonNetwork.room.Name;
            RpcAddPlayerToList();
        }
    }
Example #23
0
    void ClientRemovePlayerFromList(NetworkPlayer view)
    {
        MPPlayer tempPlayer = null;

        foreach (MPPlayer player in playersList)
        {
            if (player.playerNetwork == view)
            {
                tempPlayer = player;
            }
        }

        if (tempPlayer != null)
        {
            playersList.Remove(tempPlayer);
        }
    }
Example #24
0
    public void FindPlayers()
    {
        // hm?
        otherPlayer = FindObjectOfType <MPPlayer>();

        //if (isServer)        {
        players = GameObject.FindGameObjectsWithTag("Player");
        player1 = players[0];     // wird wohl nach Adam Riese der Server sein...?!

        if (players.Length >= 2)
        {
            player2 = players[1];
        }
        else
        {
            player2 = otherPlayer.GetComponentInParent <GameObject>();
        }
        //}
    }
Example #25
0
    //ADD NEW PLAYERS TO LIST MEMBERS
    public void RpcAddPlayerToList2(string playerName, PhotonPlayer photonID, bool isMaster, int idplayer)
    {
        if (PhotonNetwork.isMasterClient)
        {
            return;
        }
        MPPlayer addlist = new MPPlayer();

        addlist.id       = idplayer;
        addlist.pseudo   = playerName;
        addlist.Master   = isMaster;
        addlist.IDphoton = photonID;
        playersList.Add(addlist);
        if (isMaster)
        {
            playerName = "<color=#a52a2aff>" + playerName + "</color>";
        }
        ListMemberText.text += playerName + "\n";
    }
Example #26
0
    //REFRESH LIST PLAYERS AFTER PLAYER DISCONNECTED
    public void refreshRemaningBallMaster(PhotonPlayer photonP, int remaning)
    {
        if (PhotonNetwork.isMasterClient)
        {
            MPPlayer tempPlayer = null;
            foreach (MPPlayer p in playersList)
            {
                if (p.photonP == photonP)
                {
                    tempPlayer = p;
                }
            }
            if (tempPlayer != null)
            {
                tempPlayer.RemainingBalls = remaning;
            }

            RpcAddPlayerToList();
        }
    }
Example #27
0
    void client_removePlayer(NetworkPlayer view)
    {
        MPPlayer temp = null;

        foreach (MPPlayer pl in playerList)
        {
            if (pl.playerNetwork == view)
            {
                Debug.Log("FOUND");
                temp = pl;
            }
        }
        if (temp != null)
        {
            playerList.Remove(temp);
            temp = null;
        }

        Debug.Log("player disconnected. Before: " + serverSideGasings.Count);
        serverSideGasings.Remove(getGasingOwnedByPlayer(view));
        Debug.Log("player disconnected. After: " + serverSideGasings.Count);
        Network.DestroyPlayerObjects(view);
    }
Example #28
0
    [PunRPC]    //ADD NEW PLAYERS TO LIST MEMBERS
    public void RpcAddPlayerToList2(string playerName, PhotonPlayer photonP, bool isMaster, bool bingo, bool ingame, int idplayer, int nbrcards, int remaningball)
    {
        //THE FUNCTION IS SENDING BY THE MASTERCLIENTFOR ALL PLAYERS AND NOT FOR THE MASTERCLIENT
        if (PhotonNetwork.isMasterClient)
        {
            return;
        }
        GameObject objbarTop = null;

        if (GlobalVariables.m_instance.GameIsReady)                                                                     //IF GLOBAL VARABLE GAME IS READY
        {
            if (remaningball <= 5)                                                                                      //IF REMANING BALL OF SELECTED PLAYER IN THE LIST <= 5
            {
                if (ingame)                                                                                             //IF SELECTED PLAYER IN THE LIST IS INGAME
                {
                    GlobalUI.m_instance.Top5Block.SetActive(true);                                                      //ACTIVE TOP5 GAMEOBJECT
                    objbarTop = Instantiate(PrefabTop5Bar, this.transform.position, Quaternion.identity) as GameObject; // ADD REMANING BALL BAR OF SELECTED PLAYER IN THE LIST, IN TOP5
                    objbarTop.transform.SetParent(IndexPositionInstantiateBar);                                         //MOVE TRANSFORM BAR IN INDEXPOSITION FOR UI
                    objbarTop.GetComponent <Top5> ().pseudo.text = playerName;                                          //ADD IN REMANING BALL BAR THE LOGIN IN PLAYER SELECTED
                    if (bingo)                                                                                          // IF PLAYER SELECTED IN THE LIST IS "BINGO"
                    {
                        objbarTop.GetComponent <Top5> ().remaning.text = "BINGO!";                                      //ADD TEXT "BINGO" IN REMANING BALLS BAR OF PLAYER
                    }
                    else
                    {
                        if (remaningball == 1)                          //IF REMANING BALLS OF SELECTED PLAYER IN THE LIST, IS EQUAL OF 1, CHANGE THE COLOR OF REMANING BALLS BAR, OF LOGIN AND TEXT.
                        {
                            objbarTop.GetComponent <Image> ().color         = TemplateColor.m_instance.ColorsList [GlobalVariables.m_instance.IDTemplate].ColorTop5BarOneBall;
                            objbarTop.GetComponent <Top5> ().remaning.color = TemplateColor.m_instance.ColorsList [GlobalVariables.m_instance.IDTemplate].ColorTop5BarTextOneBall;
                            objbarTop.GetComponent <Top5> ().pseudo.color   = TemplateColor.m_instance.ColorsList [GlobalVariables.m_instance.IDTemplate].ColorTop5BarTextOneBall;
                        }
                        objbarTop.GetComponent <Top5> ().remaning.text = remaningball.ToString();   //SHOW THE TEXT OF REMANING BALLS OF SELECTED PLAYER
                    }
                    objbarTop.transform.SetParent(IndexPositionInstantiateBar);                     //MOVE TRANSFORM BAR IN INDEXPOSITION FOR UI
                }
            }
            else                                                         //IF REMANING BALL OF SELECTED PLAYER IN THE LIST > 5
            {
                GlobalUI.m_instance.Top5Block.SetActive(false);          //DISABLE GAMEOBJECT TOP5
                foreach (Transform child in IndexPositionInstantiateBar) //SEARCH ALL REMANING BAR IN INDEX POSITION IN UI
                {
                    Destroy(child.gameObject);                           //AND DESTROY ALL REMANING BALLS BAR IN UI
                }
            }
        }
        //ADD NEW PLAYER IN THE LIST WITH NEW VALUES
        MPPlayer addlist = new MPPlayer();

        addlist.id             = idplayer;
        addlist.pseudo         = playerName;
        addlist.Master         = isMaster;
        addlist.Bingo          = bingo;
        addlist.InGame         = ingame;
        addlist.photonP        = photonP;
        addlist.NbrCardBoards  = nbrcards;
        addlist.BarTop         = objbarTop;
        addlist.RemainingBalls = remaningball;
        playersList.Add(addlist);

        foreach (MPPlayer player in playersList.OrderByDescending(p => p.RemainingBalls).ToArray())          //SEARCH IN THE LIST OF MASTERCLIENT, PLAYER BY PLAYER, WITH ORDER BY REMAINING BALLS
        {
            if (player.BarTop != null)
            {
                player.BarTop.GetComponent <RectTransform>().SetAsFirstSibling();                //ORDER BAR TOP5
            }
        }
        GameManager.m_instance.CountInRoom();                                                             //SHOW COUNT PLAYERS IN ROOM
        GlobalUI.m_instance.putInPlay.text = "$" + GlobalVariables.m_instance.PutInPlay.ToString("0.##"); //SHOW PUT IN PLAY MONEY'S
    }
Example #29
0
 public bool RemovePlayer(MPPlayer player)
 {
     return(RemovePlayer(player.StateInfo.Id));
 }
Example #30
0
 public void SetMyPlayer(MPPlayer myNewPlayer)
 {
     MyPlayer = myNewPlayer;
 }
Example #31
0
 void Client_AddPlayerToList(string playername, NetworkPlayer view)
 {
     MPPlayer tempplayer = new MPPlayer();
     tempplayer.PlayerName = playername;
     tempplayer.PlayerNetwork = view;
     PlayerList.Add(tempplayer);
     if (Network.player == view)
     {
         Debug.Log("Client_AddPlayerToList,if (Network.player == view), called");
         MyPlayer = tempplayer;
         GameObject play = Network.Instantiate(PlayerManagerPrefab, Vector3.zero, Quaternion.identity, 5) as GameObject;
         //play.GetComponent<PlayerManager>().thisplayer = MyPlayer; //Remove This Part
     }
 }
Example #32
0
 /// <summary>
 /// Will inform other users of our state change
 /// </summary>
 /// <param name="thePlayer">The player.</param>
 void OurUserStateChanged(MPPlayer thePlayer)
 {
     SendMessageToAll(_playerChangedState + " " + ((int)OurPlayer.GetState()));
 }