Esempio n. 1
0
 public PlayerListModel GetPlayerListModel(TNet.Player p)
 {
     return(new PlayerListModel()
     {
         Name = p.name,
         TeamID = p.dataNode.GetChild <int>(NetworkManager.NODE_TeamId),
         Kills = p.dataNode.GetChild <int>(NetworkManager.NODE_Kills),
         Deaths = p.dataNode.GetChild <int>(NetworkManager.NODE_Deaths)
     });
 }
    public override void OnInspectorGUI()
    {
        TNObject obj = target as TNObject;

        if (Application.isPlaying)
        {
            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.LabelField("Channel", obj.channelID.ToString());
            EditorGUILayout.LabelField("ID", obj.uid.ToString());

            if (obj.owner != null)
            {
                EditorGUILayout.LabelField("Owner", obj.owner.name + " (" + obj.ownerID + ")");
            }
            else
            {
                EditorGUILayout.LabelField("Owner", obj.ownerID.ToString());
            }

            TNet.Player host = TNManager.GetHost(TNManager.lastChannelID);
            EditorGUILayout.LabelField("Host", (host != null) ? host.name : "<none>");
            if (obj.parent != null)
            {
                EditorGUILayout.ObjectField("Parent", obj.parent, typeof(TNObject), true);
            }
            EditorGUI.EndDisabledGroup();
        }
        else
        {
            serializedObject.Update();
            SerializedProperty sp = serializedObject.FindProperty("id");
            EditorGUILayout.PropertyField(sp, new GUIContent("ID"));
            serializedObject.ApplyModifiedProperties();

            PrefabType type = PrefabUtility.GetPrefabType(obj.gameObject);
            if (type == PrefabType.Prefab)
            {
                return;
            }

            if (obj.uid == 0)
            {
                EditorGUILayout.HelpBox("Object ID of '0' means this object must be dynamically instantiated via TNManager.Instantiate.", MessageType.Info);
            }
            else
            {
                TNObject[] tnos = FindObjectsOfType <TNObject>();

                foreach (TNObject o in tnos)
                {
                    if (o == obj || o.parent != null)
                    {
                        continue;
                    }

                    if (o.uid == obj.uid)
                    {
                        EditorGUILayout.HelpBox("This ID is shared with other TNObjects. A unique ID is required in order for RFCs to function properly.", MessageType.Error);
                        break;
                    }
                }
            }
        }
    }
Esempio n. 3
0
 /// <summary>
 /// Sent when some player leaves the channel the player is in.
 /// </summary>
 /// <param name="player">Player.</param>
 public void OnNetworkPlayerLeave(TNet.Player player)
 {
     // This could be where you would destroy their avatar, or you could use the DestroyRemotePlayer approach.
 }
Esempio n. 4
0
 public void RPC(string functionName, TNet.Player player, params object[] objects)
 {
     Debug.Log("Calling " + functionName);
     tno.Send(functionName, player, objects);
 }
Esempio n. 5
0
 /// <summary>
 /// Happens when another player joins the channel the player is in.
 /// </summary>
 /// <param name="newPlayer">New player.</param>
 public void OnNetworkPlayerJoin(TNet.Player newPlayer)
 {
     //  Bec
     // Create Player -> CreateNetworkPlayer()
     Debug.Log(newPlayer.name);
 }