Ejemplo n.º 1
0
    IEnumerator SetTimer()
    {
        int time = 0;

        while (!networkscript.IsConnected() && time <= 5)
        {
            TimeText.text = time.ToString();
            time++;
            yield return(new WaitForSeconds(1f));
        }
        if (networkscript.IsConnected())//연결 성공, 다음 씬으로 이동
        {
            SceneManager.LoadScene("InGameScene", LoadSceneMode.Single);
        }
        else //시간초과 서버 연결 실패
        {
            PopupMenu.ShowPopupText("Server is not ready to play", 5f);
            CancelMatching();
        }
    }
Ejemplo n.º 2
0
    //연결 확인 (InvokeRepeat로 연결 될 때 까지 반복 호출 된다)
    void CheckConnection()
    {
        if (networkScript.IsConnected() && GameStarted == false)
        {
            //클라이언트와 연결 됨
            SceneText.GetComponent <Text>().text = "Game Start!";
            GameStarted = true;

            //랜덤으로 선/후 턴 결정 (0:선턴, 1:후턴)
            Turn = (short)Random.Range(0, 2);   //(0,2)로 해야 0~1사이로 나온다 앞이 시작이고, 뒤가 갯수라 보면 됨

            SendData[0] = (byte)Turn;

            //클라이언트에 결과 전송
            networkScript.Send(SendData, 1);

            //상태변경 (wait -> select...)
            CurrentState = Turn == 0 ? GameState.SelectWeapon : GameState.SelectArmor;

            CancelInvoke();
        }
    }