Esempio n. 1
0
    //sends a serialized representation of 2000 pipes and their height
    IEnumerator sendPipes()
    {
        yield return(new WaitForSeconds(.2f));

        if (isHost)
        {
            SerializePipes pipes = new SerializePipes(2000);
            Instance.Pipes = pipes.pipes;
            string sendPipes = 'p' + JsonUtility.ToJson(pipes);
            GameKit.Instance.sendData(sendPipes);
            //Host can start after sending pipe data
            if (match == null)
            {
                match = GameObject.Find("MatchManager").GetComponent <MatchManager>();
            }
            match.FriendConnected();
        }
        yield return(null);
    }
Esempio n. 2
0
 public void GotData(string status)
 {
     //got pipe info
     if (status[0] == 'p')
     {
         SerializePipes p = JsonUtility.FromJson <SerializePipes>(status.Substring(1));
         Instance.Pipes = p.pipes;
         //Non Host can start after recieving pipe data
         if (match == null)
         {
             match = GameObject.Find("MatchManager").GetComponent <MatchManager>();
         }
         match.FriendConnected();
     }
     //friend is ready
     else if (status[0] == 'r')
     {
         //get friend color inside ready message
         int fc;
         if (int.TryParse(status.Substring(1), out fc))
         {
             friendColor = fc;
         }
         GameKit.Instance.sendData("r" + Instance.SaveData.birdColor.ToString());
         friendReady = true;
         foundMatch  = true;
     }
     //friend gamestate
     else
     {
         if (match == null)
         {
             match = GameObject.Find("MatchManager").GetComponent <MatchManager>();
         }
         match.GotData(status);
     }
 }