示例#1
0
 // Use this for initialization
 void Start()
 {
     MyCore = GameObject.FindObjectOfType <NetworkCore>();
     if (MyCore == null)
     {
         throw new System.Exception("There is no network core in the scene!");
     }
     IsServer = MyCore.IsServer;
     IsClient = MyCore.IsClient;
     StartCoroutine(SlowStart());
 }
示例#2
0
 // Start is called before the first frame update
 public void Awake()
 {
     MyId   = gameObject.GetComponent <NetworkID>();
     MyCore = GameObject.FindObjectOfType <NetworkCore>();
     if (MyCore == null)
     {
         throw new System.Exception("ERROR: There is no network core on the scene.");
     }
     if (MyId == null)
     {
         throw new System.Exception("ERROR: There is no network ID on this object");
     }
     StartCoroutine(SlowStart());
 }
示例#3
0
        // Use this for initialization
        void Start()
        {
            //UDPGameObjectMessages = new ExclusiveString();
            //GameObjectMessages = new ExclusiveString();
            MyCore = GameObject.FindObjectOfType <NetworkCore>();
            if (MyCore == null)
            {
                throw new System.Exception("There is no network core in the scene!");
            }
            IsServer = MyCore.IsServer;
            IsClient = MyCore.IsClient;

            StartCoroutine(SlowStart());
        }
示例#4
0
 //type will be either COMMAND or UPDATE to know if its coming from server or client. Clients send COMMAND, server sends UPDATE.
 //Will block commands from server, or updates from clients.
 //var is identifier of what is being changed
 //This is the receiving side of a command/update
 public void Net_Update(string type, string var, string value)
 {
     //Get components for network behaviours
     //Destroy self if owner connection is done.
     try
     {
         if (MyCore.IsServer && MyCore.Connections.ContainsKey(Owner) == false && Owner != -1)
         {
             MyCore.NetDestroyObject(NetId);
         }
     }
     catch (System.NullReferenceException)
     {
         //Has not been initialized yet.  Ignore.
     }
     try
     {
         if (MyCore == null)
         {
             MyCore = GameObject.FindObjectOfType <NetworkCore>();
         }
         if ((MyCore.IsServer && type == "COMMAND") ||
             (MyCore.IsClient && type == "UPDATE"))
         {
             //Get all gameObjects
             NetworkComponent[] myNets = gameObject.GetComponents <NetworkComponent>();
             for (int i = 0; i < myNets.Length; i++)
             {
                 //Send in var and value so all objects are updated
                 myNets[i].HandleMessage(var, value);
             }
         }
     }
     catch (System.Exception e)
     {
         Debug.Log("Caught Exception: " + e.ToString());
         //This can happen if myCore has not been set.
         //I am not sure how this is possible, but it should be good for the next round.
     }
 }
示例#5
0
 // Start is called before the first frame update
 void Start()
 {
     myCore = GameObject.FindObjectOfType <NETWORK_ENGINE.NetworkCore>();
     StartCoroutine(panelSwitch());
 }