コード例 #1
0
    // 레드팀(1팀) 조인
    public void RedTeamJoin(PhotonPlayer photonPlayer)
    {
        //플레이어가 이미 들어왔는데, 프리팹이 다시 생성되는걸 방지
        PlayerLeftRoom(photonPlayer);

        //플레이어 프리팹 생성, 리스트에 추가
        CurrentPlayerListPrefab = Instantiate(playerListingPrefab);
        PlayerListing playerListing = CurrentPlayerListPrefab.GetComponent <PlayerListing>();

        playerListing.ApplyPhotonPlayer(photonPlayer);
        playerListing.PhotonPlayer = photonPlayer;
        playerListings.Add(playerListing);

        // 플레이어 프리팹이 들어갈 자리의 자식들을 꺼버림 (선빼고)
        foreach (Transform tr in Team1ViewPort[Team1_playerCount].transform)
        {
            if (tr.name != "Line")
            {
                tr.gameObject.SetActive(false);
            }
        }

        // 프리펩 위치 설정
        playerListing.transform.SetParent(Team1ViewPort[Team1_playerCount].transform, false);
        playerListing.transform.localPosition = Vector3.zero;

        // bool 변수 체크. 스크립트에 팀과 번호 기록
        Team1_Check[Team1_playerCount] = true;
        playerListing.viewnum          = Team1_playerCount;
        playerListing.Team             = 'r';

        // 팀인원수 증가 및 팀 설정
        Team1_playerCount++;
        photonPlayer.SetTeam(PunTeams.Team.red);
    }
コード例 #2
0
    // 블루팀(2팀) 조인
    public void BlueTeamJoin(PhotonPlayer photonPlayer)
    {
        //플레이어가 이미 들어왔는데, 프리팹이 다시 생성되는걸 방지
        PlayerLeftRoom(photonPlayer);

        //플레이어 프리팹 생성, 리스트에 추가
        CurrentPlayerListPrefab = Instantiate(playerListingPrefab);
        PlayerListing playerListing = CurrentPlayerListPrefab.GetComponent <PlayerListing>();

        playerListing.ApplyPhotonPlayer(photonPlayer);
        playerListing.PhotonPlayer = photonPlayer;
        playerListings.Add(playerListing);

        foreach (Transform tr in Team2ViewPort[Team2_playerCount].transform)
        {
            if (tr.name != "Line")
            {
                tr.gameObject.SetActive(false);
            }
        }

        playerListing.transform.SetParent(Team2ViewPort[Team2_playerCount].transform, false);
        playerListing.transform.localPosition = Vector3.zero;

        Team2_Check[Team2_playerCount] = true;
        playerListing.viewnum          = Team2_playerCount;
        playerListing.Team             = 'b';

        Team2_playerCount++;
        photonPlayer.SetTeam(PunTeams.Team.blue);
    }
コード例 #3
0
    //  สร้างPrefab แสดงผลชื่อ ดึงผู้เล่นมาเก็บไว้ที่List รอการดำเนินการต่อไป
    private void PlayerJoinedRoom(PhotonPlayer photonPlayer)
    {
        if (photonPlayer == null)
        {
            return;
        }

        //PlayerLeftRoom(photonPlayer);
        //  เรียกPrefabมาวางที่ Player(s) List Panel
        GameObject playerListingObj = Instantiate(PlayerListingPrefab);

        playerListingObj.transform.SetParent(transform, false);
        //  กำหนดชื่อที่แสดงตาม ชื่อที่ผู้เล่นคนนั้นได้ป้อนเข้าระบบ Photon
        PlayerListing playerListing = playerListingObj.GetComponent <PlayerListing>();

        playerListing.photonView.viewID = PlayerListings.Count + 2;
        playerListing.ApplyPhotonPlayer(photonPlayer);

        //  เพิ่มเข้า List เพื่อใช้ดำเนินการต่อไป
        PlayerListings.Add(playerListing);
        int playerIndex = PlayerListings.IndexOf(playerListing);

        print("playerJoinedRoomIndex : " + playerIndex);
        Authorzation();
    }
コード例 #4
0
    private void PlayerJoinedRoom(PhotonPlayer photonPlayer)
    {
        if (photonPlayer == null)
        {
            return;
        }

        if (!PhotonNetwork.isMasterClient)
        {
            BtnState.gameObject.SetActive(false);
            BtnStart.gameObject.SetActive(false);
        }

        PlayerLeftRoom(photonPlayer);

        GameObject playerListingObj = Instantiate(PlayerListingPrefab);

        playerListingObj.transform.SetParent(transform, false);

        PlayerListing playerListing = playerListingObj.GetComponent <PlayerListing>();

        playerListing.ApplyPhotonPlayer(photonPlayer);

        PlayerListings.Add(playerListing);
    }
コード例 #5
0
    private void PlayerJoinedRoom(PhotonPlayer photonPlayer)
    {
        if (photonPlayer == null) return;
        PlayerLeftRoom(photonPlayer);

        GameObject playerListingObj = Instantiate(PlayerListingPrefab);
        playerListingObj.transform.SetParent(transform, false);

        PlayerListing playerListing = playerListingObj.GetComponent<PlayerListing>();
        playerListing.ApplyPhotonPlayer(photonPlayer);

        PlayerListings.Add(playerListing);
    }
コード例 #6
0
    void AddPlayer(Player newPlayer)
    {
        if (newPlayer == null)
        {
            return;
        }
        int index = m_playerListings.FindIndex(x => x.m_photonPlayer == newPlayer);

        if (index != -1)
        {
            return;
        }
        GameObject playerListingObj = Instantiate(m_playerListingPrefabs);

        playerListingObj.transform.SetParent(transform, false);

        PlayerListing playerListing = playerListingObj.GetComponent <PlayerListing>();

        playerListing.ApplyPhotonPlayer(newPlayer);
        m_playerListings.Add(playerListing);

        if (newPlayer.IsMasterClient)
        {
            playerListing.m_keyIcon.SetActive(true);
        }
        else
        {
            playerListing.m_keyIcon.SetActive(false);
        }
        if (PhotonNetwork.IsMasterClient)
        {
            if (newPlayer.IsMasterClient)
            {
                playerListing.m_kickButton.SetActive(false);
            }
            else
            {
                playerListing.m_kickButton.SetActive(true);
                playerListing.m_kickButton.GetComponent <Button>().onClick.AddListener(() => MainCanvasManager.m_instance.m_currentRoomCanvas.OnClickKickPlayer(playerListing));
            }
        }
        else
        {
            playerListing.m_kickButton.SetActive(false);
        }
    }
コード例 #7
0
    void PlayerJoinedRoom(PhotonPlayer photonPlayer)
    {
        if (photonPlayer == null)
        {
            return;
        }
        if (!photonPlayer.IsLocal)
        {
            AudioFW.Play("Joined");
        }
        GameObject playerListingsObj = Instantiate(playerListingPrefab);

        playerListingsObj.transform.SetParent(transform, false);
        PlayerListing playerListing = playerListingsObj.GetComponent <PlayerListing>();

        playerListing.ApplyPhotonPlayer(photonPlayer);
        playerListings.Add(playerListing);
    }
コード例 #8
0
ファイル: MatchPannel.cs プロジェクト: city0409/MainPlane
    private void PlayerJoinedRoom(PhotonPlayer photonPlayer)
    {
        if (photonPlayer == null)
        {
            return;
        }
        //same person joined room remove it
        PlayerLeftRoom(photonPlayer);

        GameObject playerListingOBJ = Instantiate(PlayerListingPrefab);

        playerListingOBJ.transform.SetParent(content.transform, false);
        PlayerListing playerListing = playerListingOBJ.GetComponent <PlayerListing>();

        playerListing.ApplyPhotonPlayer(photonPlayer);

        PlayerListings.Add(playerListing);
    }
コード例 #9
0
    internal void PlayerJoinedRoom(PhotonPlayer phoPlayer)
    {
        if (phoPlayer == null)
        {
            return;
        }
        PlayerLeftRoom(phoPlayer);

        GameObject playerListingObj = Instantiate(playerListingGameObject);

        playerListingObj.transform.SetParent(transform, false);

        PlayerListing playerlisting = playerListingObj.GetComponent <PlayerListing>();

        playerlisting.ApplyPhotonPlayer(phoPlayer);

        playerListings.Add(playerlisting);
    }
コード例 #10
0
    private void PlayerJoinedRoom(PhotonPlayer photonPlayer)
    {
        if (photonPlayer == null)
        {
            return;
        }

        PlayerLeftRoom(photonPlayer);   // чтоб не дублировались пользователи в лобби

        GameObject PlayerListingObj = Instantiate(PlayerListingPrefab);

        PlayerListingObj.transform.SetParent(transform, false);

        PlayerListing playerListing = PlayerListingObj.GetComponent <PlayerListing>();

        playerListing.ApplyPhotonPlayer(photonPlayer);

        PlayerListings.Add(playerListing);
    }
コード例 #11
0
    //place holder
    private void PlayerJoinedRoom(PhotonPlayer photonPlayer)
    {
        if (photonPlayer == null)
        {
            return;
        }

        PlayerLeftRoom(photonPlayer);           //in case OnjoinedRoom message is sent when player is already in room, this prevents  getting duplicates

        GameObject playerListingObj = Instantiate(PlayerListingPrefab);

        playerListingObj.transform.SetParent(transform, false);

        PlayerListing playerListing = playerListingObj.GetComponent <PlayerListing> ();

        playerListing.ApplyPhotonPlayer(photonPlayer);

        PlayerListings.Add(playerListing);
    }
コード例 #12
0
    /// <summary>
    /// When a player joins the room
    /// </summary>
    /// <param name="photonPlayer"></param>
    private void PlayerJoinedRoom(PhotonPlayer photonPlayer)
    {
        if (photonPlayer == null) //If there is no player, should never happen but just incase
        {
            return;
        }

        PlayerLeftRoom(photonPlayer);

        GameObject playerListingObject = Instantiate(PlayerListingPrefab);                //Instantaiting the prefab, player list that shows the player name

        playerListingObject.transform.SetParent(transform, false);                        //Sets the parent of the prefab to 'PlayerLayoutGroup'

        PlayerListing playerListing = playerListingObject.GetComponent <PlayerListing>(); //Gets the script component

        playerListing.ApplyPhotonPlayer(photonPlayer);

        PlayerListings.Add(playerListing); //Add the script to each prefab in player listings
    }
コード例 #13
0
    private void PlayerJoinedRoom(PhotonPlayer photonPlayer)
    {
        if (photonPlayer == null)                                     // I don't think this would ever happen but better be safe and secured :)
        {
            return;
        }

        PlayerLeftRoom(photonPlayer);

        GameObject playerListingObj = Instantiate(PlayerListingPrefab);

        playerListingObj.transform.SetParent(transform, false);

        PlayerListing playerListing = playerListingObj.GetComponent <PlayerListing>();

        playerListing.ApplyPhotonPlayer(photonPlayer);                  // This will set the text on the prefab as well.

        PlayerListings.Add(playerListing);
    }
コード例 #14
0
    private void PlayerJoinedRoom(PhotonPlayer photonPlayer)
    {
        if (photonPlayer == null)       //prevents duplicates
        {
            return;
        }

        PlayerLeftRoom(photonPlayer);

        GameObject playerListingObj = Instantiate(PlayerListingPrefab);

        playerListingObj.transform.SetParent(transform, false);

        PlayerListing playerListing = playerListingObj.GetComponent <PlayerListing>();       //get the playerlisting script from this gameobject

        //pass in the photon player
        playerListing.ApplyPhotonPlayer(photonPlayer);

        PlayerListings.Add(playerListing);
    }
コード例 #15
0
    private void PlayerJoinedRoom(PhotonPlayer photonPlayer)
    {
        if (photonPlayer == null)
        {
            return;
        }

        //preventing whenever a player join room messages is sent when the player is already in the room.
        PlayerLeftRoom(photonPlayer);

        GameObject playerListingObj = Instantiate(PlayerListingPrefab);

        playerListingObj.transform.SetParent(transform, false);

        PlayerListing playerListing = playerListingObj.GetComponent <PlayerListing>();

        playerListing.ApplyPhotonPlayer(photonPlayer);

        PlayerListings.Add(playerListing);
    }
コード例 #16
0
    //当玩家进入这个房间时
    public void PlayerJoinedRoom(PhotonPlayer player)
    {
        if (player == null)
        {
            return;
        }

        PlayerLeftRoom(player);

        //实例化名字条
        GameObject playerListItem = NGUITools.AddChild(this.gameObject, PlayerListingPrefab);

        this.GetComponent <UIGrid>().AddChild(playerListItem.transform);
        //更新名字条内容
        PlayerListing playerListing = playerListItem.GetComponent <PlayerListing>();

        playerListing.ApplyPhotonPlayer(player);

        //加入list
        PlayerList.Add(playerListing);
    }
コード例 #17
0
    // Called whenever a player has joined the room. Parameter player is the player that has joined the room.
    private void PlayerJoinedRoom(Player player)
    {
        if (player == null)
        {
            return;
        }

        // Remove the player from the list if the player is already in the room to avoid adding duplicate players
        // to the player layout group.
        PlayerLeftRoom(player);

        // Instantiate the player listing game object in the UI and set the parent equal to the player layout group.
        GameObject playerListingObject = Instantiate(PlayerListingPrefab);

        playerListingObject.transform.SetParent(transform, false);

        // Apply the player info to the player listing.
        PlayerListing playerListing = playerListingObject.GetComponent <PlayerListing>();

        playerListing.ApplyPhotonPlayer(player);

        // Add the player listing to the list of player listings.
        PlayerListings.Add(playerListing);
    }