Пример #1
0
    public void LightGameObject(string strJSONparameters)
    {
        JsonParametersLightGameObject jsonParametersLightGameObject = JsonUtility.FromJson <JsonParametersLightGameObject>(strJSONparameters);
        GameObject gameObject = GameObject.Find(jsonParametersLightGameObject.ObjectName);
        Light      light      = (Light)gameObject.GetComponent("Light");

        light.enabled = jsonParametersLightGameObject.IsLight;
    }
Пример #2
0
    void Update()
    {
        opendoor.gameObjectForOpen      = null;
        Using1.gameObjectForShader      = null;
        Switch.chosenGameObject         = null;
        ActiveObject.chosenGameObject   = null;
        OnDoor.chosenGameObject         = null;
        ActivateScript.chosenGameObject = null;
        OnChose.chosenGameObject        = null;
        ObjectClicker.chosenGameObject  = null;

        Vector3 Direction = RaycastS.TransformDirection(Vector3.forward);

        if (Physics.Raycast(RaycastS.position, Direction, out Hit, 1000f))
        {
            if (Hit.collider.material.staticFriction == 0.2f)
            {
                //Using1 usingScript = Hit.collider.gameObject.GetComponent<Using1>();
                //if (usingScript)
                //{
                //    Using1.gameObjectForShader = Hit.collider.gameObject;
                //}

                opendoor opendoorScript = Hit.collider.gameObject.GetComponent <opendoor>();
                if (opendoorScript)
                {
                    opendoor.gameObjectForOpen = Hit.collider.gameObject;
                }

                Switch switchScript = Hit.collider.gameObject.GetComponent <Switch>();
                if (switchScript)
                {
                    Switch.chosenGameObject = Hit.collider.gameObject;
                }
            }

            ActiveObject activeObjectScript = Hit.collider.gameObject.GetComponent <ActiveObject>();
            if (activeObjectScript)
            {
                ActiveObject.chosenGameObject = Hit.collider.gameObject;
            }

            OnDoor onDoorScript = Hit.collider.gameObject.GetComponent <OnDoor>();
            if (onDoorScript)
            {
                OnDoor.chosenGameObject = Hit.collider.gameObject;
            }
            OnChose onChoseScript = Hit.collider.gameObject.GetComponent <OnChose>();
            if (onChoseScript)
            {
                OnChose.chosenGameObject = Hit.collider.gameObject;
            }
            ObjectClicker onClikerScript = Hit.collider.gameObject.GetComponent <ObjectClicker>();
            if (onClikerScript)
            {
                ObjectClicker.chosenGameObject = Hit.collider.gameObject;
            }

            ActivateScript activateScript = Hit.collider.gameObject.GetComponent <ActivateScript>();
            if (activateScript)
            {
                ActivateScript.chosenGameObject = Hit.collider.gameObject;
            }
        }
        //  ManageTaskDialog();

        //if (Input.GetMouseButtonDown(0)) //left
        //{
        //    eProject.CallServerMethod_DoAction("1e106acb-e6d3-41f5-865e-4eafb8b329d5", "c176dc43-0a07-4ae7-ba40-556735982901", 1);
        //}
        if (Input.GetKeyDown(KeyCode.LeftControl))
        {
            //Cursor.visible = !Cursor.visible;

            //if(Cursor.lockState == CursorLockMode.None)
            //    Cursor.lockState = CursorLockMode.Locked;
            //else if (Cursor.lockState == CursorLockMode.Locked)
            //    Cursor.lockState = CursorLockMode.None;

            //MouseLook scriptMouseLook = gameObject.GetComponent<MouseLook>();
            //scriptMouseLook.enabled = !(scriptMouseLook.enabled);

            MouseLook scriptMouseLook = gameObject.GetComponent <MouseLook>();
            if (Cursor.visible == true)
            {
                Cursor.visible          = false;
                Cursor.lockState        = CursorLockMode.Locked;
                scriptMouseLook.enabled = true;
            }
            else
            {
                Cursor.visible          = true;
                Cursor.lockState        = CursorLockMode.None;
                scriptMouseLook.enabled = false;
            }
        }
        if (Input.GetKeyDown(KeyCode.L))
        {
            gameObjectLight.SetActive(!gameObjectLight.activeSelf);

            //var listener = new UnityEventListener
            //{
            //    EventType = "keyDown",
            //    IdObject = Guid.Empty,
            //    KeyCode = "L"
            //};
            //listener.SendEvent();

            GameObject     gameObjectUnityApi = GameObject.Find("UnityAPI");
            UnityApiScript unityApiScript     = gameObjectUnityApi.GetComponent <UnityApiScript>();

            JsonParametersRotateGameObject jsonParametersRotateGameObject = new JsonParametersRotateGameObject
            {
                ObjectName = "Door_Дверь РУВН",
                Angle      = new Vector3(0, 20, 0),
                IsSpecific = true
            };
            string json = JsonUtility.ToJson(jsonParametersRotateGameObject);

            unityApiScript.RotateGameObject(json);


            //List<JsonButton> btns = new List<JsonButton>();
            //for (int i=0; i<5; i++)
            //{
            //    JsonButton jsonButton = new JsonButton
            //    {
            //        Name = "Команда № " + i.ToString(),
            //        Value = i
            //    };
            //    btns.Add(jsonButton);
            //}

            //unityApiScript.CreateDialog(btns);


            List <CodeValuePair>     codeValuePairs = new List <CodeValuePair>();
            List <int>               codes          = new List <int>();
            List <string>            values         = new List <string>();
            Dictionary <int, string> keyValuePairs  = new Dictionary <int, string>();
            for (int i = 0; i < 5; i++)
            {
                int    key   = i;
                string value = "Команда № " + i.ToString();
                keyValuePairs.Add(key, value);
                codeValuePairs.Add(new CodeValuePair {
                    Code = key, Value = value
                });
                codes.Add(key);
                values.Add(value);
            }


            DialogData jsonDialog = new DialogData
            {
                DialogCode  = 1,
                DialogTitle = "Сумка с причиндалами",
                //    KeyValuePairs = keyValuePairs,
                //   CodeValuePairs = codeValuePairs
                Codes  = codes,
                Values = values
            };
            string strJsonDialog = JsonUtility.ToJson(jsonDialog);


            unityApiScript.CreateDialog(strJsonDialog);
        }

        if (Input.GetKeyDown(KeyCode.O))
        {
            //GameObject gameObjectUnityApi = GameObject.Find("UnityAPI");
            //UnityApiScript unityApiScript = gameObjectUnityApi.GetComponent<UnityApiScript>();

            //JsonParametersRotateGameObject jsonParametersRotateGameObject = new JsonParametersRotateGameObject
            //{
            //    ObjectName = "Door_Дверь РУВН",
            //    Angle = 135f,
            //    IsSpecific = true
            //};
            //string json = JsonUtility.ToJson(jsonParametersRotateGameObject);

            //unityApiScript.RotateGameObject(json);

            GameObject     gameObjectUnityApi = GameObject.Find("UnityAPI");
            UnityApiScript unityApiScript     = gameObjectUnityApi.GetComponent <UnityApiScript>();

            JsonParametersLightGameObject jsonParametersLightGameObject = new JsonParametersLightGameObject
            {
                ObjectName = "Твердое тело1 818",
                IsLight    = true
            };
            string json1 = JsonUtility.ToJson(jsonParametersLightGameObject);

            unityApiScript.LightGameObject(json1);
        }

        if (Input.GetKeyDown(KeyCode.P))
        {
            //GameObject gameObjectUnityApi = GameObject.Find("UnityAPI");
            //UnityApiScript unityApiScript = gameObjectUnityApi.GetComponent<UnityApiScript>();

            //JsonParametersRotateGameObject jsonParametersRotateGameObject = new JsonParametersRotateGameObject
            //{
            //    ObjectName = "Door_Дверь РУВН",
            //    Angle = 135f,
            //    IsSpecific = true
            //};
            //string json = JsonUtility.ToJson(jsonParametersRotateGameObject);

            //unityApiScript.RotateGameObject(json);

            //GameObject gameObjectUnityApi = GameObject.Find("UnityAPI");
            //UnityApiScript unityApiScript = gameObjectUnityApi.GetComponent<UnityApiScript>();

            //JsonParametersLightGameObject jsonParametersLightGameObject = new JsonParametersLightGameObject
            //{
            //    ObjectName = "Твердое тело1 818",
            //    IsLight = false
            //};
            //string json1 = JsonUtility.ToJson(jsonParametersLightGameObject);

            //unityApiScript.LightGameObject(json1);

            GameObject            AssetManager          = GameObject.Find("AssetManager");
            NonCachingLoadExample NonCachingLoadExample = AssetManager.GetComponent <NonCachingLoadExample>();
            AddAssetParameter     addAssetParameter     = new AddAssetParameter
            {
                bundleURL = "D:/Training3dProjects/Training_v7/Assets/AssetBundles/cubeasset",
                assetName = "D:/Training3dProjects/Training_v7/Assets/Scenes/Resources_2018.12.26/Cube.prefab"//"A20", };
            };

            string json1 = JsonUtility.ToJson(addAssetParameter);
            NonCachingLoadExample.LoadAsset(json1);
        }

        if (Input.GetKeyDown(KeyCode.G))
        {
            //GameObject gameObjectUnityApi = GameObject.Find("UnityAPI");
            //UnityApiScript unityApiScript = gameObjectUnityApi.GetComponent<UnityApiScript>();

            //JsonParametersRotateGameObject jsonParametersRotateGameObject = new JsonParametersRotateGameObject
            //{
            //    ObjectName = "Door_Дверь РУВН",
            //    Angle = 135f,
            //    IsSpecific = true
            //};
            //string json = JsonUtility.ToJson(jsonParametersRotateGameObject);

            //unityApiScript.RotateGameObject(json);

            GameObject     gameObjectUnityApi = GameObject.Find("UnityAPI");
            UnityApiScript unityApiScript     = gameObjectUnityApi.GetComponent <UnityApiScript>();

            JsonParametersPositionGameObject jsonParametersPositionGameObject = new JsonParametersPositionGameObject
            {
                ObjectName = "Твердое тело1 88",
                Position   = new Vector3(0.5f, 0f, 0f),
                SetNew     = false
            };
            string json = JsonUtility.ToJson(jsonParametersPositionGameObject);

            unityApiScript.ChangePositionObject(json);
        }

        if (Input.GetKeyDown(KeyCode.J))
        {
            MouseLook scriptMouseLook = gameObject.GetComponent <MouseLook>();
            Zoom      scriptZoom      = GameObject.Find("Player").GetComponent <Zoom>();


            GameObject mainCamera     = GameObject.Find("Main Camera");
            Dialogue   dialogueScript = mainCamera.GetComponent <Dialogue>();

            if (dialogueScript.ShowDialogue == true)
            {
                //Cursor.visible = false;
                //Cursor.lockState = CursorLockMode.Locked;
                scriptMouseLook.enabled = true;
                scriptZoom.enabled      = true;
            }
            else
            {
                // Cursor.visible = true;
                // Cursor.lockState = CursorLockMode.None;
                scriptMouseLook.enabled = false;
                scriptZoom.enabled      = false;
            }



            if (dialogueScript.ShowDialogue == true)
            {
                dialogueScript.ShowDialogue = false;
            }
            else
            {
                DialogueNode node0 = new DialogueNode();
                node0.NpcText  = "Я: -Здравствуйте, диспетчерская?\n";
                node0.NpcText += "Диспетчер: -Здравствуйте, диспетчер Иванов, слушаю.";
                Answer ans0_1 = new Answer
                {
                    Text     = "Я: - Прошу снять напряжение с КТП-10/0,4 с номером 86732. Потребители уведомлены о снятии напряжения.\nДиспетчер: - Снимаю напряжение с КТП-10/0,4 с номером 86732.",
                    ToNode   = 0,
                    SpeakEnd = true,

                    ActionRef        = "e9477766-93dc-497d-a7e0-91ab73dcaab5",
                    ElementRef       = Guid.Empty.ToString(),
                    InventoryItemRef = "41a454ad-e7cb-4785-a4d5-d969f42abb81"
                };
                Answer ans0_2 = new Answer
                {
                    Text     = "Я: - Вы сняли напряжение?\nДиспетчер: - Да, напряжение с КТП-10/0,4 снято.",
                    ToNode   = 0,
                    SpeakEnd = true,

                    ActionRef        = "e474abb8-b273-48ec-b138-131c28ca0826",
                    ElementRef       = Guid.Empty.ToString(),
                    InventoryItemRef = "41a454ad-e7cb-4785-a4d5-d969f42abb81"
                };
                Answer ans0_3 = new Answer
                {
                    Text     = "Я: - Прошу подать напряжение на КТП 10/0,4. с номером 86732 \"Считаю, КТП 10/0.4 под напряжением\"\nДиспетчер: - Напряжение подано",
                    ToNode   = 0,
                    SpeakEnd = true,

                    ActionRef        = "e20b60e8-b7a1-4ed0-ba4b-c315c0d20149",
                    ElementRef       = Guid.Empty.ToString(),
                    InventoryItemRef = "41a454ad-e7cb-4785-a4d5-d969f42abb81"
                };
                Answer ans0_4 = new Answer
                {
                    Text     = "Я: - Прошу снять напряжение с КТП-10/0,4 с номером 843432. Потребители уведомлены о снятии напряжения.\nДиспетчер: - Снимаю напряжение с КТП-10/0,4 с номером 843432.",
                    ToNode   = 0,
                    SpeakEnd = true,

                    ActionRef        = "06a9e850-b562-4209-b98d-765fa8b7d071",
                    ElementRef       = "",
                    InventoryItemRef = "41a454ad-e7cb-4785-a4d5-d969f42abb81"
                };
                Answer ans0_5 = new Answer
                {
                    Text     = "Я: - Прошу подать напряжение на КТП-10/0,4 с номером 321455. \"Считаю, КТП 10 / 0.4 под напряжением\"\nДиспетчер: - Напряжение подано",
                    ToNode   = 0,
                    SpeakEnd = true,

                    ActionRef        = "604640b3-f525-4e48-a051-8e008d9dd286",
                    ElementRef       = "",
                    InventoryItemRef = "41a454ad-e7cb-4785-a4d5-d969f42abb81"
                };
                node0.PlayerAnswer = new Answer[] { ans0_1, ans0_2, ans0_3, ans0_4, ans0_5 };

                //DialogueNode node1 = new DialogueNode();
                //node1.NpcText = "Выполняю снятие напряжения с КТП-10/0,4.";
                //node1.PlayerAnswer = new Answer[] { ans0_2, ans0_3, ans0_4, ans0_5 };

                //DialogueNode node2 = new DialogueNode();
                //node2.NpcText = "Подтверждаю о снятии напряжения с КТП-10/0,4.";
                //node2.PlayerAnswer = new Answer[] { ans0_3, ans0_4, ans0_5 };

                //DialogueNode node3 = new DialogueNode();
                //node3.NpcText = "Подано напряжение на КТП 10/0,4.";
                //node3.PlayerAnswer = new Answer[] { ans0_5 };

                dialogueScript._currentNode = 0;
                dialogueScript.node         = new DialogueNode[] { node0 };
                dialogueScript.ShowDialogue = true;
            }
        }

        //if (Input.GetKeyDown(KeyCode.Space))
        //{
        //    MouseLook scriptMouseLook = gameObject.GetComponent<MouseLook>();
        //    if (Cursor.visible == true)
        //    {
        //        Cursor.visible = false;
        //        Cursor.lockState = CursorLockMode.Locked;
        //        scriptMouseLook.enabled = true;
        //    }
        //    else
        //    {
        //        Cursor.visible = true;
        //        Cursor.lockState = CursorLockMode.None;
        //        scriptMouseLook.enabled = false;
        //    }
        //
        //
        //    GameObject gameObjectUnityApi = GameObject.Find("UnityAPI");
        //    Actions unityApiScript = gameObjectUnityApi.GetComponent<Actions>();
        //    Actions.show = !Actions.show;
        //
        //}
    }