Esempio n. 1
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.K))
        {
            switch (mode)
            {
            case (Mode.none):
                break;

            case (Mode.server):
            {
                Vector3 pos = Vector3.left * 3f + Vector3.forward * 2f * count;
                CEventSystem.Broadcast(ServerEventChannel.channel, ServerEventChannel.subchannel, new SpawnBox(pos));
                count++;
                break;
            }

            case (Mode.client):
            {
                Vector3 pos = Vector3.right * 3f + Vector3.forward * 2f * count;
                CEventSystem.Broadcast(ServerEventChannel.channel, ServerEventChannel.subchannel, new SpawnBox(pos));
                count++;
                break;
            }
            }
        }

        if (Input.GetKeyDown(KeyCode.J))
        {
            GameObject local = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            local.name = "local";
            local.transform.position = Random.insideUnitSphere * 5f;
            local.AddNetComponent <TestGUIDObjectLocal>();
        }
    }
Esempio n. 2
0
        /// <summary>
        /// Process a network event broadcast, and push it into the event system
        /// </summary>
        /// <param name="netEvent"></param>
        private static void ProcessNetworkEventBroadcast(NetworkEventBroadcast netEvent)
        {
            Enum            channel = netEvent.channel, subchannel = netEvent.subchannel;
            NetworkedCEvent e = netEvent.e;

            e.sendToServer = false;
            CEventSystem.Broadcast(channel, subchannel, e);
        }
        public void Fire(WeaponFireEvent fireEvent)
        {
            RaycastHit hit;

            if (Physics.Raycast(fireEvent.ray, out hit, Mathf.Infinity, layerMask))
            {
                CEventSystem.Broadcast(Ship.ShipChannel.shipChannel, Ship.ShipChannel.shipSubchannel, new Ship.TargetEvent(hit.point));
            }
        }
Esempio n. 4
0
        private void Start()
        {
            gameObject.AddComponent <NetworkServer>();
            NetworkClient.Create(gameObject, IP);

            gameObject.AddComponent <ServerDebugListener>();

            CEventSystem.Broadcast(ServerEventChannel.channel, ServerEventChannel.subchannel, new ServerDebugListener.ServerDebugEvent("This is a server debug event"));
            CEventSystem.Broadcast(ServerEventChannel.channel, ServerEventChannel.subchannel, new ServerDebugListener.ClientDebugEvent("This is a client debug event"));
        }
Esempio n. 5
0
        void Update()
        {
            //if (Input.GetKeyDown(KeyCode.Escape))
            //{
            //    SceneManager.LoadScene(SceneManager.GetActiveScene().name);
            //}

            Vector2 input = Vector2.zero;

            if (Input.GetKey(KeyCode.W))
            {
                input.y += 1f;
            }
            if (Input.GetKey(KeyCode.S))
            {
                input.y -= 1f;
            }
            if (Input.GetKey(KeyCode.A))
            {
                input.x -= 1f;
            }
            if (Input.GetKey(KeyCode.D))
            {
                input.x += 1f;
            }

            if (input.sqrMagnitude > 1f)
            {
                input = input.normalized;
            }

            //Sets the target input for the movement controller that receive this event.
            CEventSystem.Broadcast(EventChannel.input, playerNumber, new SetTargetInputEvent(input));

            //Adds an inpulse event to the movement controller that receives this event.
            if (Input.GetKeyDown(KeyCode.Space))
            {
                CEventSystem.Broadcast(EventChannel.input, playerNumber, new InpulseEvent(Vector3.up * 10f));
            }

            Vector2 viewInput = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"));

            CEventSystem.Broadcast(EventChannel.input, playerNumber, new LookInputEvent(viewInput));

            if (Input.GetKeyDown(KeyCode.LeftShift))
            {
                CEventSystem.Broadcast(EventChannel.input, playerNumber, new CrouchToggleEvent());
            }
        }
Esempio n. 6
0
        private void PrivateInit(int owner)
        {
            init = false;

            this.owner = owner;

            isOwner = owner == NetworkClient.ClientNumber;

            if (owner == NetworkClient.ClientNumber)
            {
                NetBehaviourTracker.AddNetBehaviour(this);
                var spawn = GetSpawn();
                if (spawn != null)
                {
                    CEventSystem.Broadcast(NetBehaviourSpawner.Channel.channel, NetBehaviourSpawner.Channel.subchannel, spawn);
                }
            }
        }
Esempio n. 7
0
 protected override void Init()
 {
     CEventSystem.Broadcast(ServerEventChannel.channel, ServerEventChannel.subchannel, new SpawnRemoveEvent(GUID, transform.position));
     this.num     = guid.id;
     posLastFrame = transform.position;
 }