Documentation about match time?

Options
Hello there,
I started creating a fps and it works really good with photon! :)

Now i want to know:

1.)
how to wait until another player got connected to the room and then start the match (I guess that is the RockPaperScissors demo and gets handled with the if (PhotonNetwork.room.PlayerCount == 2) starts the turnManager.StartTurn();)

2.)
how to end the match after a specific amount of time and display the "kills or points" (I don't know where to find a documentation about the part with the time (is it turnManager.turnDuration?) and where I should save the players points).

I bought MFP but unfortunately it's not working with unity 5.5 :-1:

Thank you :)

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @JannickL,

    Since your game is a FPS, I think you do not need the TurnManager as it is meant for Turn-Based games like RockPaperScissors but of course you can make use of it somehow.

    1) yes that should be it. you should check players count in the other players join callback.
    2)
    a. ending the game is part of your own specific logic, there is no predefined one and it's not really Photon related, for Photon you can just make the players leave the room when the game is over.
    b. you should save the game data on a separate server, a web based one preferably. You can make use of Photon's webhooks or webRPC of course but it is not really required.
  • JannickL
    JannickL
    edited December 2016
    Options
    This is what i'm trying for the time but when another player joins the room he still sees and start counting down from 300:

    This script is attached to every player:
    public float matchTime = 300f; // Match time
    
       private void Start()
      { 
         StartMatchTime();
      }
    
        private void StartMatchTime()
        {
            if (PhotonNetwork.isMasterClient) // only start when is masterclient
                photonView.RPC("RPC_StartMatchTime", PhotonTargets.AllBuffered, PhotonNetwork.time);
        }
    
        [PunRPC]
        void RPC_StartMatchTime(double matchTimeStart)
        {
            matchTime -= (float)(PhotonNetwork.time - matchTimeStart);
            StartCoroutine("MatchTimeCountdown");
        }
    
        private IEnumerator MatchTimeCountdown()
        {
            while (matchTime > 0f)
            {
                yield return new WaitForEndOfFrame();
                matchTime -= Time.deltaTime;
    
                if (matchTimeText != null)
                    matchTimeText.text = matchTime.ToString("F0");
            }
        }