Exemple #1
0
 private void _AddNetBehaviour(NetBehaviour netBehaviour)
 {
     lock (currentNetBehaviours)
     {
         currentNetBehaviours.Add(netBehaviour);
     }
 }
Exemple #2
0
 private void _RemoveNetBehaviour(NetBehaviour netBehaviour)
 {
     lock (currentNetBehaviours)
     {
         currentNetBehaviours.Remove(netBehaviour);
     }
 }
Exemple #3
0
        protected override void RunByOwner()
        {
            //error check
            if (movementController == null)
            {
                return;
            }

            int          platformID        = -1;
            NetBehaviour platformBehaviour = platformController?.platform?.GetComponent <NetBehaviour>();

            if (platformBehaviour != null)
            {
                platformID = platformBehaviour.id;
            }

            if (Vector3.Distance(movementController.localPosition, oldPosition) > 0.01f || Vector2.Distance(movementController.targetInput, targetInput) > 0.01f)
            {
                BroadcastToSelfUdp(new NetworkMovementControllerSync(platformID, movementController.localPosition, movementController.localVelocity, movementController.targetInput, NetTime.time));
                oldPosition = movementController.localPosition;
                targetInput = movementController.targetInput;
                synced      = false;
            }
            else
            {
                if (!synced)
                {
                    synced = true;
                    BroadcastToSelfUdp(new NetworkMovementControllerSync(platformID, movementController.localPosition, Vector3.zero, movementController.targetInput, NetTime.time));
                }
            }
        }
    // Start is called before the first frame update
    void Start()
    {
        m_BallProjComp = m_Ball.GetComponent <BallPhysics>();
        Assert.IsNotNull(m_BallProjComp, "No Projectile Compononet Found");

        m_NetBehaviour = m_Net.GetComponent <NetBehaviour>();
        Assert.IsNotNull(m_NetBehaviour, "No Net Behaviour Found");
    }
    public void NewConnectionReceived(IPEndPoint endpoint)
    {
        GameObject   playerobj = Instantiate(PlayerPrefab, new Vector3(0, 0, 0), Quaternion.identity);
        InputHandler io        = playerobj.GetComponent <InputHandler>();
        NetBehaviour playerNet = playerobj.GetComponent <NetBehaviour>();

        NetAggregator.Instance.PlayerObjs.Add(playerNet);
        PlayerInput.Add(endpoint, io);
    }
 public static void AddNetComponent <T>(this GameObject gameObject) where T : NetBehaviour
 {
     new NetGUID((x) => NetBehaviour.Create <T>(gameObject, NetworkClient.ClientNumber, x));
 }
Exemple #7
0
 public void UnRegisterObject(NetBehaviour netObject)
 {
     NetObjects.Remove(netObject);
 }
Exemple #8
0
 public void RegisterObject(NetBehaviour netObject)
 {
     NetObjects.Add(netObject);
 }
Exemple #9
0
 public static void RemoveNetBehaviour(NetBehaviour netBehaviour)
 {
     instance?._RemoveNetBehaviour(netBehaviour);
 }
Exemple #10
0
 public static void AddNetBehaviour(NetBehaviour netBehaviour)
 {
     instance?._AddNetBehaviour(netBehaviour);
 }