Пример #1
0
        protected override void OwnerUpdate()
        {
            base.OwnerUpdate();

            if (Input.GetKeyDown(KeyCode.O))
            {
                RPC("TestRPC", NetworkReceivers.Others);
            }

            if (Input.GetKeyDown(KeyCode.B))
            {
                AssignName("Brent");
            }
            else if (Input.GetKeyDown(KeyCode.F))
            {
                AssignName("Farris");
            }

            if (Input.GetKey(KeyCode.UpArrow))
            {
                transform.position += Vector3.up * 5.0f * Time.deltaTime;
            }

            if (Input.GetKey(KeyCode.DownArrow))
            {
                transform.position += Vector3.down * 5.0f * Time.deltaTime;
            }

            if (Input.GetKey(KeyCode.LeftArrow))
            {
                transform.position += Vector3.left * 5.0f * Time.deltaTime;
            }

            if (Input.GetKey(KeyCode.RightArrow))
            {
                transform.position += Vector3.right * 5.0f * Time.deltaTime;
            }

            if (Input.GetKeyDown(KeyCode.T))
            {
                cachedData = ServerSerialze(testNum++);
                Networking.WriteCustom(SERVER_ONLY, Networking.PrimarySocket, cachedData, true, NetworkReceivers.Server);
            }

            if (Input.GetKeyDown(KeyCode.Space))
            {
                number++;
                cat += "Cat";
            }
            else if (Input.GetKeyDown(KeyCode.V))
            {
                floatNumber += 50.35f;
            }

            if (Input.GetKeyDown(KeyCode.S))
            {
                BeardedManStudios.Network.Cache.Set <int>("test", 9);
            }

            if (Input.GetKeyDown(KeyCode.G))
            {
                BeardedManStudios.Network.Cache.Request <int>("test", (object x) =>
                {
                    Debug.Log(x);
                });
            }

            if (OwningNetWorker.IsServer && Input.GetKeyDown(KeyCode.N))
            {
                Networking.ChangeClientScene(OwningNetWorker, "ForgeWriteCustom");
#if UNITY_4_6 || UNITY_4_7
                Application.LoadLevel("ForgeWriteCustom");
#else
                Network.Unity.UnitySceneManager.LoadScene("ForgeWriteCustom");
#endif
            }
            else if (OwningNetWorker.IsServer && Input.GetKeyDown(KeyCode.M))
            {
                Networking.ChangeClientScene(OwningNetWorker, "ForgeHelloCubeResources");
#if UNITY_4_6 || UNITY_4_7
                Application.LoadLevel("ForgeHelloCubeResources");
#else
                Network.Unity.UnitySceneManager.LoadScene("ForgeHelloCubeResources");
#endif
            }

            if (Input.GetKeyDown(KeyCode.L))
            {
                dontLerp += 5.35f;
            }

            if (Input.GetKeyDown(KeyCode.C))
            {
                RPC("MessageGroupTest", NetworkReceivers.MessageGroup, (byte)9);
            }

            if (Input.GetKeyDown(KeyCode.Alpha0))
            {
                Debug.Log("Setting message group to 0");
                Networking.SetMyMessageGroup(OwningNetWorker, (ushort)0);
            }
            else if (Input.GetKeyDown(KeyCode.Alpha1))
            {
                Debug.Log("Setting message group to 1");
                Networking.SetMyMessageGroup(OwningNetWorker, (ushort)1);
            }
            else if (Input.GetKeyDown(KeyCode.Alpha2))
            {
                Debug.Log("Setting message group to 2");
                Networking.SetMyMessageGroup(OwningNetWorker, (ushort)2);
            }
            else if (Input.GetKeyDown(KeyCode.Alpha3))
            {
                Debug.Log("Setting message group to 3");
                Networking.SetMyMessageGroup(OwningNetWorker, (ushort)3);
            }

            if (OwningNetWorker.IsServer && Input.GetKeyDown(KeyCode.U))
            {
                AuthoritativeRPC("AuthMessage", OwningNetWorker, OwningNetWorker.Players[0], true, "World");
            }

            if (OwningNetWorker.IsServer && Input.GetKeyDown(KeyCode.L))
            {
                OwningNetWorker.BanPlayer(OwningNetWorker.Players[0], 500);
            }

            if (Input.GetKeyDown(KeyCode.Escape))
            {
                Networking.Disconnect();
                                #if UNITY_4_6 || UNITY_4_7
                Application.LoadLevel(0);
                                #else
                Network.Unity.UnitySceneManager.LoadScene(0);
                                #endif
            }
        }