Esempio n. 1
0
 private void RPC_SetUpPlayer(int ParentIndex, string displayName)
 {
     //Debug.LogError("Dummy Error");
     ParentObject = PhotonView.Find(ParentIndex).gameObject;
     if (ParentPlayer == null)
     {
         ParentPlayer = ParentObject.GetComponent <NetPlayer>();
     }
     if (LocalPlayer == null)
     {
         LocalPlayer = ParentPlayer.LocalPlayer;
     }
     //ParentPlayer = GetComponentInParent<NetPlayer>();
     //if (LocalPlayer == null && ParentPlayer.LocalPlayer != null)
     //    LocalPlayer = ParentPlayer.LocalPlayer;
     //SetTeamNum(TeamNum);
     TextName.text = displayName;
     PNT.ForceStart();
     if (LocalPlayer == ParentPlayer)
     {
         TextName.gameObject.SetActive(false);
     }
     if (LocalPlayer.GetTeamNum() != ParentPlayer.GetTeamNum())
     {
         TextName.gameObject.SetActive(false);
     }
     SetTeamNum(TeamNum);
 }
Esempio n. 2
0
    public void SetUpPlayer(NetPlayer ParentNetObject)
    {
        ParentPlayer = ParentNetObject;
        if (LocalPlayer == null && ParentPlayer.LocalPlayer != null)
        {
            LocalPlayer = ParentPlayer.LocalPlayer;
        }
        PV.RPC("RPC_UpdateLocalPlayer", RpcTarget.AllBuffered, ParentNetObject.GetComponent <PhotonView>().ViewID);

        gameObject.name = ParentPlayer.name.Split('#')[0];
        Code            = ParentPlayer.CodeNumbers;
        UpdateName(gameObject.name);
        PV.RPC("RPC_UpdateCode", RpcTarget.All, Code);
        TeamNum = ParentPlayer.GetTeamNum();
        transform.GetComponentInChildren <LookAtPostionFollow>().UnParent();
        PV.RPC("RPC_UpdateTeamNum", RpcTarget.All, TeamNum);
        //PV.RPC("RPC_SetUpPlayer", RpcTarget.AllBuffered);
        //SetTeamNum(TeamNum);

        if (DisplayName == "")
        {
            DisplayName = (string)PhotonNetwork.LocalPlayer.CustomProperties["DisplayName"];
        }
        TextName.text = DisplayName;
        if (LocalPlayer == ParentPlayer)
        {
            TextName.gameObject.SetActive(false);
        }
        if (LocalPlayer.GetTeamNum() != ParentPlayer.GetTeamNum())
        {
            TextName.gameObject.SetActive(false);
        }

        if (LocalPlayer != null && SetLocalPlayerCalled)
        {
            PlayerLocalSet = true;
            PV.RPC("RPC_UpdateLocalSet", RpcTarget.AllBuffered, PlayerLocalSet);
        }
    }
Esempio n. 3
0
    public Transform GrabSpawnPoint(int viewID)
    {
        Transform ReturnTransform = null;
        // Figure out who is asking
        NetPlayer ThisPlayer = PhotonView.Find(viewID).GetComponent <NetPlayer>();

        // Find All Players
        NetPlayer[] Players = FindObjectsOfType <NetPlayer>();

        // Find players on players team
        List <NetPlayer> TeamPlayers = new List <NetPlayer>();

        foreach (NetPlayer NP in Players)
        {
            if (NP.GetTeamNum() == ThisPlayer.GetTeamNum())
            {
                TeamPlayers.Add(NP);
            }
        }

        // find the players by view id
        List <NetPlayer> TeamPlayersByViewID = new List <NetPlayer>();

        for (int I = 0; I < TeamPlayers.Count; I++)
        {
            NetPlayer temp = null;
            // Find Next Lower Player
            foreach (NetPlayer NP in TeamPlayers)
            {
                // If the temp is null
                if (temp == null)
                {
                    // Add current player if it is not contained
                    if (!TeamPlayersByViewID.Contains(NP))
                    {
                        temp = NP;
                    }
                }
                // If the NP is lower then the temp
                if (temp != null && temp.GetTeamNum() > NP.GetTeamNum() && !TeamPlayersByViewID.Contains(NP))
                {
                    temp = NP;
                }
            }
            // Add player to list
            if (!TeamPlayersByViewID.Contains(temp))
            {
                TeamPlayersByViewID.Add(temp);
            }
        }
        // All the players should be sorted
        int index = TeamPlayersByViewID.IndexOf(ThisPlayer);

        if (index == -1)
        {
            index = Random.Range(0, 3);
        }

        // Set the return transform
        if (ThisPlayer.GetTeamNum() == 1)
        {
            ReturnTransform = BlueSpawns[index].transform;
        }
        if (ThisPlayer.GetTeamNum() == 2)
        {
            ReturnTransform = RedSpawns[index].transform;
        }
        //else
        //{
        //    Debug.Log("No Spawn Selected");
        //}
        return(ReturnTransform);
    }
Esempio n. 4
0
 public void CreateTeamEntry(string text)
 {
     //print("Create Entry Team");
     //CmdCreateEntry(gameObject.name, text, "Team" + NP.GetTeamNum(), this.gameObject);
     PV.RPC("RPC_CreateEntry", RpcTarget.All, NP.DisplayName, text, "Team" + NP.GetTeamNum(), PV.ViewID);
 }