コード例 #1
0
    public void SetPlayer()
    {
        //GameObject tmpRoadGenerator;

        //마스터만 로드제네레이터를 생성한다
        if (PhotonNetwork.isMasterClient)
        {
            GameObject tmpRoadGenerator = PhotonNetwork.Instantiate("Prefabs/RoadGenerator", Vector3.zero,
                                                                    Quaternion.identity, 0);

            //만약 생성이 되어 있다면
            roadGenerator = tmpRoadGenerator.GetComponent <RoadGenerator>();
        }

        //만약 생성이 되어 있다면
        //roadGenerator = tmpRoadGenerator.GetComponent<RoadGenerator>();

        int num = PlayerPrefs.GetInt("SELECTPLAYER", 0);

        Player[] tmpPlayer = FindRankPlayer();

        //TODO : 랜덤하게 위치를 바꿔줘야 할것
        //Player.transform.position = Vector3.zero;
        if (tmpPlayer.Length >= 1)
        {
            //가장 늦은 플레이어 위치 값에 더 해준 위치값
            Vector3 tmpPos = tmpPlayer[tmpPlayer.Length - 1].transform.position;

            tmpPos += new Vector3(2f, 0, 0);

            //포톤뷰로 캐릭터 생성
            player = PhotonNetwork.Instantiate("Prefabs/" + characterArray[num].name, tmpPos, Quaternion.identity, 0);
        }
        else
        {
            //포톤뷰로 캐릭터 생성
            player = PhotonNetwork.Instantiate("Prefabs/" + characterArray[num].name, Vector3.zero, Quaternion.identity, 0);
        }

        player.name = characterArray[num].name;

        if (PhotonNetwork.connected)
        {
            Vector3 tmpPos = player.transform.position;

            mainCamera.GetComponent <Camerafollow>().OriginPosition(tmpPos);
        }

        if (PhotonNetwork.connected && PhotonNetwork.isMasterClient)
        {
            roadGenerator.InitializationRoad();
        }
    }