Ejemplo n.º 1
0
    private void onData(int ConnectionId, int channelId, int recHostId, nMsg msg)
    {
        switch (msg.OP) //Server Recieves much data than the client
        {
        case NetOP.None:
            Debug.Log("Incorrect initialisation");
            break;

        case NetOP.Position:
            n_Position Decode = (n_Position)msg;
            //Player.NetworkInstance.ObjectID = (int)Decode.Position.x;
            //Player.ID = (int)Decode.Position.x;
            //checkMoving.PlayerID = Player.ID;
            //Test.transform.position = ((n_Position)msg).Position+OffsetDistance;
            break;

        case NetOP.SyncSceneObjects:
            Debug.Log("SceneObjects");
            UpdatedObjectContainer temp = (UpdatedObjectContainer)msg;
            checkMoving.SyncObjects(temp.SceneObjects);
            break;

        case NetOP.NewPlayer:
            nPlayerNew PlayerType = (nPlayerNew)msg;
            //  spawn.Spawn(true, PlayerType.ID);
            break;

        case NetOP.Action:
            nAction ActionToggle = (nAction)msg;
            crystalize.crystalize();
            break;
        }
    }
Ejemplo n.º 2
0
    // Start is called before the first frame update
    void Start()
    {
        //Work out what mode this should be functioning in
        // if (FindObjectOfType<Server>() == true)
        //{
        //   Serv = FindObjectOfType<Server>();
        //  Hosting = true;
        // }
        // else if (FindObjectOfType<Client>() == true) //Change when you're not working with both in one scene
        // {
        //   Cli = FindObjectOfType<Client>();
        //   Hosting = false;
        // }
        DontDestroyOnLoad(this);

        NetworkedObjects.AddRange(FindObjectsOfType <NetworkObjectScript>());
        TransmitList = new UpdatedObjectContainer();
        //UnityEngine.GameObject[] bob = SceneManager.GetActiveScene().GetRootGameObjects();

        // foreach(GameObject c in bob)
        // {
        //     if(c.GetComponent<NetworkObjectScript>()!=null)
        //    {
        //       Debug.Log("WHY");
        //       NetworkedObjects.Add(c.GetComponent<NetworkObjectScript>());
        //   }
        // }
    }