コード例 #1
0
        private void Update()
        {
            //Provjerava je li došlo do pogotka između
            //Bačenih kocki i ležećih cilindra
            CubeCylinderMatch();

            //Vrijedi za korištenje kocki.
            //Ako se kocka trenutno nosi i slijedi
            //njeno bacanje, potrebno je ponovno uključiti
            //opcije BoxCollider-a, Rigidbody-a.
            if (objectRaised == true)
            {
                if (Input.GetKeyDown("e"))
                {
                    raisedObject.tag = "Untagged";
                    raisedObject.GetComponent <BoxCollider>().enabled  = true;
                    raisedObject.GetComponent <Rigidbody>().useGravity = true;
                    raisedObject.transform.localEulerAngles            = new Vector3(0, 0, 0);
                    raisedObject.transform.parent = null;
                    objectRaised = false;
                    //Pričekaj da kocka padne kako bi ponovno mogla biti
                    //selektirana jer ne želimo da je korisniku tijekom
                    //nošenja stalno highlight-ana kocka
                    StartCoroutine("WaitCubeDrop");
                }
            }

            //Korištenje Inventory-a
            if (Input.GetKeyDown("i"))
            {
                InventorySound.Play();
                if (UiInventoryCanvas.activeInHierarchy == true)
                {
                    UiInventoryCanvas.SetActive(false);
                }
                else
                {
                    UiInventoryCanvas.SetActive(true);
                    objectManipulation.currentManipulationText.text = "Select Inventory Item By Entering Required ID";
                }
            }

            //Ako korisnik nije selektirao niti jedan objekt
            //sakri ponuđeni tekst za manipulaciju.
            if (isHovering == false)
            {
                //objectInfoTurnedOn = false;
                if (UiInventoryCanvas.activeInHierarchy == false)
                {
                    objectManipulation.currentManipulationText.text = "";
                }
            }

            //Vraća prvotne teksture selektiranih objekata
            if (_selection != null)
            {
                var selectionRenderer = _selection.GetComponent <Renderer>();

                SelectableObject selectedObject = _selection.GetComponent <SelectableObject>();


                Material[] materials = new Material[selectionRenderer.materials.Length];
                for (int i = 0; i < selectionRenderer.materials.Length; i++)
                {
                    materials[i] = selectedObject.GetDefaultMaterials()[i];
                }
                selectionRenderer.sharedMaterials = materials;

                _selection = null;
            }

            //Ciljnik za selektiranje točno na vertikalnoj i horizontalnoj sredini
            var ray = Camera.main.ViewportPointToRay(new Vector2(0.5f, 0.5f));
            //var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            //Ukoliko je fokusiran objekt koji ima box collider
            if (Physics.Raycast(ray, out hit))
            {
                //Udaljenost od fokusiranog objekta
                if (hit.distance <= 6)
                {
                    //Debug.Log("Objekt je fokusiran: " + hit.transform.name);

                    //Prikaži tekst manipulacije objekta
                    if (UiInventoryCanvas.activeInHierarchy == false)
                    {
                        objectManipulation.ShowFloatingText(hit.transform.name, hit.transform.tag);
                    }
                    var selection = hit.transform;

                    //Ukoliko je fokusirani objekt kategorije manipulacije
                    if (selection.tag.Contains(selectableTag))
                    {
                        isHovering = true;

                        //Fokusirani objekt dobiva žuti material
                        var selectionRenderer = selection.GetComponent <Renderer>();
                        if (selectionRenderer != null)
                        {
                            Material[] materials = new Material[selectionRenderer.materials.Length];
                            for (int i = 0; i < selectionRenderer.materials.Length; i++)
                            {
                                materials[i] = highlightMaterial;
                            }
                            selectionRenderer.sharedMaterials = materials;
                        }
                        _selection = selection;

                        //Ukoliko je za fokusirani objekt pritisnuta tipka e
                        if (Input.GetKeyDown("e"))
                        {
                            switch (hit.transform.tag)
                            {
                            case "ObjectSelectable_Switch":
                            {
                                AnimController ac = GameObject.Find("Switch").GetComponent <AnimController>();
                                ac.StartSwitchAnimation(this.switchTurnedOn);
                                SwitchSound.Play();

                                //Ukoliko je prekidač pritisnut tj. svjetlo upaljeno
                                if (this.switchTurnedOn)
                                {
                                    //Ugasi prekidač
                                    this.switchTurnedOn = false;
                                    var wallRenderer       = this.istocniZid.GetComponent <Renderer>();
                                    WallWithHidenInfo wall = this.istocniZid.GetComponent <WallWithHidenInfo>();
                                    //Vrati zidu stari materijal (sakrij skrivenu poruku) i ugasi UV lampu
                                    if (wallRenderer != null)
                                    {
                                        Material[] materials = new Material[wallRenderer.materials.Length];
                                        materials[0] = wall.GetDefaultMaterial();
                                        materials[1] = wall.GetDefaultMaterial();
                                        wallRenderer.sharedMaterials = materials;

                                        Light sl = GameObject.Find("UvLamp").GetComponent <Light>();
                                        sl.intensity = 0;
                                    }
                                }
                                else
                                {
                                    //Paljenje UV lampe i pokazivanje skrivene poruke
                                    this.switchTurnedOn = true;
                                    var wallRenderer       = this.istocniZid.GetComponent <Renderer>();
                                    WallWithHidenInfo wall = this.istocniZid.GetComponent <WallWithHidenInfo>();
                                    if (wallRenderer != null)
                                    {
                                        Material[] materials = new Material[wallRenderer.materials.Length];
                                        materials[0] = wall.GetDefaultMaterial();
                                        materials[1] = wall.hiddenMessageMaterial;
                                        wallRenderer.sharedMaterials = materials;

                                        Light sl = GameObject.Find("UvLamp").GetComponent <Light>();
                                        sl.intensity = 10f;
                                    }
                                }
                                break;
                            }

                            case "ObjectSelectable_Drawer":
                            {
                                if (hit.transform.name.Contains("Cube"))
                                {
                                    if (cubeDrawerOpened == false)
                                    {
                                        //Upali svjetlo u ladici da se bolje vidi papirić koji se tamo nalazi
                                        AnimController ac = GameObject.Find("DrawerCube").GetComponent <AnimController>();
                                        ac.StartDrawerAnimation(hit.transform.name);
                                        DrawerSound.Play();
                                        Light sl = GameObject.Find("DrawerCubeChildLight").GetComponent <Light>();
                                        sl.intensity     = 1.2f;
                                        cubeDrawerOpened = true;
                                    }
                                    break;
                                }
                                //Provjera je li ormarić zaključan
                                if (CurvedDrawerUnLocked)
                                {
                                    AnimController ac = GameObject.Find("CurvedDrawer").GetComponent <AnimController>();
                                    ac.StartDrawerAnimation(hit.transform.name);
                                    DrawerSound.Play();
                                }
                                else
                                {
                                    Debug.Log("Drawer is locked.");
                                }
                                break;
                            }

                            //Objekti koji se skupljaju u Inventory
                            case "ObjectSelectable_Inventory":
                            {
                                inventory.AddItem(new Item
                                    {
                                        itemType       = hit.transform.GetComponent <ItemWorld>().itemType,
                                        actionKey      = this.inventoryItemId.ToString(),
                                        inventoryImage = hit.transform.GetComponent <ItemWorld>().inventoryImage,
                                        id             = hit.transform.GetComponent <ItemWorld>().id
                                    });
                                InventoryPickUp.Play();
                                //Nakon što je objekt prikupljen potrebno ga je uništiti iz scene
                                Destroy(hit.transform.gameObject);
                                //Osvježi inventory kako bi prikazao novo prikupljeni objekt
                                //uiInventory.RefreshInventoryItems();
                                this.inventoryItemId++;
                                //Ugasi svjetlo u ladici
                                if (hit.transform.name == "SvahiliNote")
                                {
                                    Light sl = GameObject.Find("DrawerCubeChildLight").GetComponent <Light>();
                                    sl.intensity = 0;
                                }
                                break;
                            }

                            case "ObjectSelectable_Painting":
                            {
                                ////Podigni objekt
                                //Debug.Log("Objekt podignut");
                                //objektSlike.GetComponent<Rigidbody>().useGravity = false;
                                //objektSlike.GetComponent<Rigidbody>().detectCollisions = true;
                                //objektSlike.transform.parent = trenutniRoditelj.transform;
                                //objektSlike.transform.position = trenutniRoditeljManevriranje.transform.position;

                                //objektSlike.transform.localEulerAngles = new Vector3(0, 0, 0);

                                //Baci sliku na pod
                                objektSlike.GetComponent <Rigidbody>().useGravity = true;
                                //objektSlike.transform.localEulerAngles = new Vector3(0, 0, 30);
                                objektSlike.transform.parent = null;
                                objektSlike.tag = "Untagged";
                                WoodImpactSound.PlayDelayed(1);
                                break;
                            }

                            case "ObjectSelectable_Cube":
                            {
                                GameObject selectedCube = GameObject.Find(hit.transform.name);
                                //Ako kocka nije podignut, dopusti podizanje
                                //Sprijeci podizanje kocke ukoliko je već podignuta
                                if (objectRaised == false)
                                {
                                    //Podigni objekt
                                    //Debug.Log("Objekt podignut");
                                    //if (selectedCube.GetComponent<Rigidbody>()== null) {
                                    //    Rigidbody gameObjectsRigidBody = selectedCube.AddComponent<Rigidbody>();
                                    //}

                                    //Ugasi detektiranje kolizije kako ne bi zapinjao sa kockom prilikom nošenja
                                    selectedCube.GetComponent <Rigidbody>().useGravity       = false;
                                    selectedCube.GetComponent <Rigidbody>().detectCollisions = true;
                                    selectedCube.transform.parent   = trenutniRoditelj.transform;
                                    selectedCube.transform.position = trenutniRoditeljManevriranje.transform.position;

                                    selectedCube.transform.localEulerAngles = new Vector3(0, 0, 0);
                                    //selectedCube.GetComponent<BoxCollider>().enabled = false;
                                    objectRaised = true;
                                    raisedObject = selectedCube;
                                    CubeRaiseSound.Play();
                                    //Pričekaj da se kocka digne pa tek onda ugasi collider
                                    //Razlog tome je što cilindar za detektiranje kolizije
                                    //ne prepoznaje da je objekt maknut sa istog ukoliko ne postoji collider
                                    //Zato se čeka 0.1s da se kocka digne pa se tek onda collider ugasi
                                    StartCoroutine("WaitCubeRise");
                                }
                                else
                                {
                                    ////TODO: Ne treba biti označen kad ga bacam
                                    //selectedCube.GetComponent<Rigidbody>().useGravity = true;
                                    //selectedCube.transform.localEulerAngles = new Vector3(0, 0, 0);
                                    //selectedCube.transform.parent = null;
                                    //objectRaised = false;
                                    ////Light sl = GameObject.Find("Point Light_1").GetComponent<Light>();
                                    ////sl.intensity = 4;
                                }
                                break;
                            }

                            case "ObjectSelectable_Readable":
                            {
                                UiInventoryRead.SetActive(true);
                                Transform rawImage = UiInventoryRead.transform.GetChild(0).GetChild(0);
                                ItemWorld iw       = hit.transform.GetComponent <ItemWorld>();
                                rawImage.GetComponent <RawImage>().texture = iw.inventoryImage;
                                break;
                            }

                            default:
                                break;
                            }
                        }
                        //Detekcija lijevog klika miša
                        else if (Input.GetMouseButtonDown(0))
                        {
                            switch (hit.transform.tag)
                            {
                            //Manipulacija tipkama sefa.
                            case "ObjectSelectable_SafeButton":
                            {
                                if (safeIsOpened == false)
                                {
                                    //Pokreni animaciju tipke sefa
                                    ButtonSound.Play();
                                    AnimController ac = GameObject.Find("WallWithSafe").GetComponent <AnimController>();
                                    ac.PressButton(hit.transform.name[hit.transform.name.Length - 1].ToString());


                                    Light ul = GameObject.Find("UnsuccessLight").GetComponent <Light>();
                                    if (ul.intensity > 0)
                                    {
                                        ul.intensity = 0;
                                    }
                                    if (this.safePassword.Length < 4)
                                    {
                                        this.safePassword = this.safePassword + hit.transform.name[hit.transform.name.Length - 1].ToString();
                                    }
                                    if (this.safePassword.Length == 4)
                                    {
                                        bool validPass = Safe.CheckPassword(this.safePassword);
                                        //Ako je ispravna lozinka, upali zeleno svjetlo
                                        if (validPass)
                                        {
                                            Light l = GameObject.Find("SuccessLight").GetComponent <Light>();
                                            l.intensity = 11;

                                            Debug.Log("Pass is valid: " + this.safePassword);
                                            SafeOpenSound.Play();
                                            ac.OpenSafe();
                                            safeIsOpened = true;
                                            Light sl = GameObject.Find("SafeLight").GetComponent <Light>();
                                            sl.intensity = 3;
                                        }
                                        //Ako lozinka nije ispravna, upali crveno svjetlo
                                        else
                                        {
                                            ul.intensity = 11;

                                            StartCoroutine(objectManipulation.ShowWarningText("Invalid Password!"));

                                            Debug.Log("Pass is invalid: " + this.safePassword);
                                        }
                                        this.safePassword = "";
                                    }
                                }
                                break;
                            }
                            }
                        }
                    }
                    else
                    {
                        isHovering = false;
                    }
                }
                else
                {
                    isHovering = false;
                }
            }
            else
            {
                isHovering = false;
            }


            #region Inventory korištenje
            if (Input.GetKeyDown("1"))
            {
                if (UiInventoryCanvas.activeInHierarchy == true)
                {
                    InventoryKeyManipulation("1");
                }
            }
            else if (Input.GetKeyDown("2"))
            {
                if (UiInventoryCanvas.activeInHierarchy == true)
                {
                    InventoryKeyManipulation("2");
                }
            }
            else if (Input.GetKeyDown("3"))
            {
                if (UiInventoryCanvas.activeInHierarchy == true)
                {
                    InventoryKeyManipulation("3");
                }
            }
            else if (Input.GetKeyDown("4"))
            {
                if (UiInventoryCanvas.activeInHierarchy == true)
                {
                    InventoryKeyManipulation("4");
                }
            }
            else if (Input.GetKeyDown(KeyCode.Escape))
            {
                Cursor.visible = false;
                UiInventoryRead.SetActive(false);
            }
            #endregion
        }
コード例 #2
0
        private void Update()
        {
            //Provjerava je li došlo do pogotka između
            //Bačenih kocki i ležećih cilindra
            if (ropeDroped == false)
            {
                CubeCylinderMatch();
            }

            //Vrijedi za korištenje kocki.
            //Ako se kocka trenutno nosi i slijedi
            //njeno bacanje, potrebno je ponovno uključiti
            //opcije BoxCollider-a, Rigidbody-a.
            if (objectRaised == true)
            {
                if (Input.GetKeyDown("e"))
                {
                    raisedObject.tag = "Untagged";
                    raisedObject.GetComponent <BoxCollider>().enabled  = true;
                    raisedObject.GetComponent <Rigidbody>().useGravity = true;
                    raisedObject.transform.localEulerAngles            = new Vector3(0, 0, 0);
                    raisedObject.transform.parent = null;
                    objectRaised = false;
                    //Pričekaj da kocka padne kako bi ponovno mogla biti
                    //selektirana jer ne želimo da je korisniku tijekom
                    //nošenja stalno highlight-ana kocka
                    StartCoroutine("WaitCubeDrop");
                }
            }

            //Korištenje Inventory-a
            if (Input.GetKeyDown("i"))
            {
                InventorySound.Play();
                if (UiInventoryCanvas.activeInHierarchy == true)
                {
                    UiInventoryCanvas.SetActive(false);
                }
                else
                {
                    UiInventoryCanvas.SetActive(true);
                    objectManipulation.currentManipulationText.text = "Select Inventory Item By Entering Required ID";
                }
            }

            //Ako korisnik nije selektirao niti jedan objekt
            //sakri ponuđeni tekst za manipulaciju.
            if (isHovering == false)
            {
                //objectInfoTurnedOn = false;
                if (UiInventoryCanvas.activeInHierarchy == false)
                {
                    objectManipulation.currentManipulationText.text = "";
                }
            }

            //Vraća prvotne teksture selektiranih objekata
            if (_selection != null)
            {
                var selectionRenderer = _selection.GetComponent <Renderer>();

                SelectableObject selectedObject = _selection.GetComponent <SelectableObject>();


                Material[] materials = new Material[selectionRenderer.materials.Length];
                for (int i = 0; i < selectionRenderer.materials.Length; i++)
                {
                    materials[i] = selectedObject.GetDefaultMaterials()[i];
                }
                selectionRenderer.sharedMaterials = materials;

                _selection = null;
            }

            //Ciljnik za selektiranje točno na vertikalnoj i horizontalnoj sredini
            var ray = Camera.main.ViewportPointToRay(new Vector2(0.5f, 0.5f));
            //var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            //Ukoliko je fokusiran objekt koji ima box collider
            if (Physics.Raycast(ray, out hit))
            {
                //Udaljenost od fokusiranog objekta
                if (hit.distance <= 6)
                {
                    //Debug.Log("Objekt je fokusiran: " + hit.transform.name);

                    //Prikaži tekst manipulacije objekta
                    if (UiInventoryCanvas.activeInHierarchy == false)
                    {
                        objectManipulation.ShowFloatingText(hit.transform.name, hit.transform.tag);
                    }
                    var selection = hit.transform;

                    //Ukoliko je fokusirani objekt kategorije manipulacije
                    if (selection.tag.Contains(selectableTag))
                    {
                        isHovering = true;

                        //Fokusirani objekt dobiva žuti material
                        var selectionRenderer = selection.GetComponent <Renderer>();
                        if (selectionRenderer != null)
                        {
                            Material[] materials = new Material[selectionRenderer.materials.Length];
                            for (int i = 0; i < selectionRenderer.materials.Length; i++)
                            {
                                materials[i] = highlightMaterial;
                            }
                            selectionRenderer.sharedMaterials = materials;
                        }
                        _selection = selection;

                        //Ukoliko je za fokusirani objekt pritisnuta tipka e
                        if (Input.GetKeyDown("e"))
                        {
                            switch (hit.transform.tag)
                            {
                            case "ObjectSelectable_Switch":
                            {
                                if (this.switchTurnedOn == false)
                                {
                                    AnimController ac = GameObject.Find("Switch").GetComponent <AnimController>();
                                    ac.StartSwitchAnimation(this.switchTurnedOn);
                                    SwitchSound.Play();
                                    InvokeRepeating("Position", 0.0f, 0.00002f);
                                    hit.transform.tag = "Untagged";
                                    GameObject cube = GameObject.Find("Cube_Red");
                                    cube.tag            = "ObjectSelectable_Cube";
                                    cube                = GameObject.Find("Cube_Blue");
                                    cube.tag            = "ObjectSelectable_Cube";
                                    cube                = GameObject.Find("Cube_Green");
                                    cube.tag            = "ObjectSelectable_Cube";
                                    cube                = GameObject.Find("Cube_Orange");
                                    cube.tag            = "ObjectSelectable_Cube";
                                    this.switchTurnedOn = true;
                                }
                                break;
                            }

                            //Objekti koji se skupljaju u Inventory
                            case "ObjectSelectable_Inventory":
                            {
                                inventory.AddItem(new Item
                                    {
                                        itemType       = hit.transform.GetComponent <ItemWorld>().itemType,
                                        actionKey      = this.inventoryItemId.ToString(),
                                        inventoryImage = hit.transform.GetComponent <ItemWorld>().inventoryImage,
                                        id             = hit.transform.GetComponent <ItemWorld>().id
                                    });
                                InventoryPickUp.Play();
                                //Nakon što je objekt prikupljen potrebno ga je uništiti iz scene
                                Destroy(hit.transform.gameObject);

                                if (hit.transform.name == "Rope")
                                {
                                    this.ropeWithoutKey.SetActive(true);
                                }

                                //Osvježi inventory kako bi prikazao novo prikupljeni objekt
                                //uiInventory.RefreshInventoryItems();
                                this.inventoryItemId++;
                                break;
                            }

                            case "ObjectSelectable_Cube":
                            {
                                GameObject selectedCube = GameObject.Find(hit.transform.name);
                                //Ako kocka nije podignut, dopusti podizanje
                                //Sprijeci podizanje kocke ukoliko je već podignuta
                                if (objectRaised == false)
                                {
                                    //Podigni objekt
                                    //Debug.Log("Objekt podignut");
                                    //if (selectedCube.GetComponent<Rigidbody>()== null) {
                                    //    Rigidbody gameObjectsRigidBody = selectedCube.AddComponent<Rigidbody>();
                                    //}

                                    //Ugasi detektiranje kolizije kako ne bi zapinjao sa kockom prilikom nošenja
                                    selectedCube.GetComponent <Rigidbody>().useGravity       = false;
                                    selectedCube.GetComponent <Rigidbody>().detectCollisions = true;
                                    selectedCube.transform.parent   = trenutniRoditelj.transform;
                                    selectedCube.transform.position = trenutniRoditeljManevriranje.transform.position;

                                    selectedCube.transform.localEulerAngles = new Vector3(0, 0, 0);
                                    //selectedCube.GetComponent<BoxCollider>().enabled = false;
                                    objectRaised = true;
                                    raisedObject = selectedCube;
                                    CubeRaiseSound.Play();
                                    //Pričekaj da se kocka digne pa tek onda ugasi collider
                                    //Razlog tome je što cilindar za detektiranje kolizije
                                    //ne prepoznaje da je objekt maknut sa istog ukoliko ne postoji collider
                                    //Zato se čeka 0.1s da se kocka digne pa se tek onda collider ugasi
                                    StartCoroutine("WaitCubeRise");
                                }
                                else
                                {
                                    ////TODO: Ne treba biti označen kad ga bacam
                                    //selectedCube.GetComponent<Rigidbody>().useGravity = true;
                                    //selectedCube.transform.localEulerAngles = new Vector3(0, 0, 0);
                                    //selectedCube.transform.parent = null;
                                    //objectRaised = false;
                                    ////Light sl = GameObject.Find("Point Light_1").GetComponent<Light>();
                                    ////sl.intensity = 4;
                                }
                                break;
                            }

                            case "ObjectSelectable_Button":
                            {
                                AnimController ac = GameObject.Find("Shelf").GetComponent <AnimController>();
                                ac.PlayMorseCode();
                                morseCodeSound.PlayDelayed(0.7f);
                                break;
                            }

                            default:
                                break;
                            }
                        }
                        //Detekcija lijevog klika miša
                        else if (Input.GetMouseButtonDown(0))
                        {
                            switch (hit.transform.tag)
                            {
                            //Manipulacija tipkama sefa.
                            case "ObjectSelectable_SafeButton":
                            {
                                if (safeIsOpened == false)
                                {
                                    ButtonSound.Play();
                                    //Pokreni animaciju tipke sefa
                                    AnimController ac = GameObject.Find("PassMachine").GetComponent <AnimController>();
                                    ac.PressButton(hit.transform.name[hit.transform.name.Length - 1].ToString());


                                    Light ul = GameObject.Find("UnsuccessLight").GetComponent <Light>();
                                    if (ul.intensity > 0)
                                    {
                                        ul.intensity = 0;
                                    }
                                    if (this.safePassword.Length < 4)
                                    {
                                        this.safePassword = this.safePassword + hit.transform.name[hit.transform.name.Length - 1].ToString();
                                    }
                                    if (this.safePassword.Length == 4)
                                    {
                                        bool validPass = PassMachine.CheckPassword(this.safePassword);
                                        //Ako je ispravna lozinka, upali zeleno svjetlo
                                        if (validPass)
                                        {
                                            Light l = GameObject.Find("SuccessLight").GetComponent <Light>();
                                            l.intensity = 11;

                                            Debug.Log("Pass is valid: " + this.safePassword);
                                            AnimController acd = GameObject.Find("DrawerCube").GetComponent <AnimController>();
                                            acd.OpenCubeDrawerRoom2();
                                            DrawerSound.Play();
                                            Light sl = GameObject.Find("DrawerCubeChildLight").GetComponent <Light>();
                                            sl.intensity      = 1.2f;
                                            RemoteControl.tag = "ObjectSelectable_Inventory";
                                        }
                                        //Ako lozinka nije ispravna, upali crveno svjetlo
                                        else
                                        {
                                            ul.intensity = 11;
                                            StartCoroutine(objectManipulation.ShowWarningText("Invalid Password!"));
                                            Debug.Log("Pass is invalid: " + this.safePassword);
                                        }
                                        this.safePassword = "";
                                    }
                                }
                                break;
                            }
                            }
                        }
                    }
                    else
                    {
                        isHovering = false;
                    }
                }
                else
                {
                    isHovering = false;
                }
            }
            else
            {
                isHovering = false;
            }


            #region Inventory korištenje
            if (Input.GetKeyDown("1"))
            {
                //GameObject mainCamera = GameObject.FindWithTag("MainCamera");
                //GameObject player = GameObject.Find("FPC");
                //FPController D = player.GetComponent<FPController>();
                //D.gameEnded = true;
                //D.enabled = false;

                //PlayerControls pc = mainCamera.GetComponent<PlayerControls>();
                //pc.enabled = false;

                //RemoteControlCanvas.SetActive(true);

                //Cursor.visible = true;
                //Cursor.lockState = CursorLockMode.None;

                if (UiInventoryCanvas.activeInHierarchy == true)
                {
                    InventoryKeyManipulation("1");
                }
            }
            else if (Input.GetKeyDown("2"))
            {
                if (UiInventoryCanvas.activeInHierarchy == true)
                {
                    InventoryKeyManipulation("2");
                }
            }
            else if (Input.GetKeyDown("3"))
            {
                if (UiInventoryCanvas.activeInHierarchy == true)
                {
                    InventoryKeyManipulation("3");
                }
            }
            else if (Input.GetKeyDown("4"))
            {
                if (UiInventoryCanvas.activeInHierarchy == true)
                {
                    InventoryKeyManipulation("4");
                }
            }
            else if (Input.GetKeyDown(KeyCode.Escape))
            {
                RemoveRemoteCanvas();
            }
            #endregion
        }