Ejemplo n.º 1
0
    void Start()
    {
        Inventario = GameObject.Find("Inventario");

        EssaOpcao = this.GetComponent <TextMeshProUGUI>();
        tempControleInventario = Inventario.GetComponent <ControleInventario>();
    }
Ejemplo n.º 2
0
 void Start()
 {
     TextoQuantidade        = this.GetComponentInChildren <TextMeshProUGUI>();
     Inventario             = GameObject.Find("Inventario").gameObject;
     tempControleInventario = Inventario.GetComponent <ControleInventario>();
     Opcao      = tempControleInventario.Opcao;
     ItemOpcoes = tempControleInventario.OpcoesItem;
 }
    public void FuncaoPegandoItem()
    {
        //Desligando Item Selecionado
        if (UltimoItemSelecionado != null)
        {
            //Retirando Outline
            Outline LarguraLinha = UltimoItemSelecionado.transform.GetChild(0).gameObject.GetComponent <Outline>();
            LarguraLinha.OutlineWidth = 0;

            //Deixando Nulo
            UltimoItemSelecionado = null;
        }

        if (Physics.Raycast(CameraPrincipal.ScreenPointToRay(Input.mousePosition).origin, CameraPrincipal.ScreenPointToRay(Input.mousePosition).direction,
                            out RaioPegar, PegarDistanciaMaxima, CamadaPegar, QueryTriggerInteraction.Collide))
        {
            Debug.DrawLine(CameraPrincipal.ScreenPointToRay(Input.mousePosition).origin, PontoFinalRaioMouse.point, Color.red);


            if (RaioPegar.collider.gameObject.tag == "Item" || RaioPegar.collider.gameObject.tag == "Moeda")
            {
                ItemSelecionado = RaioPegar.collider.gameObject;

                //Colocando OutLine
                Outline LarguraLinha = ItemSelecionado.transform.GetChild(0).gameObject.GetComponent <Outline>();
                LarguraLinha.OutlineWidth = 4;


                //So pode pegar item se o mouse estiver solto quando passar
                if (!Input.GetMouseButton(0))
                {
                    PodePegarItem = true;
                }

                //Nome Item
                Fundo_InfoNomeItem.gameObject.SetActive(true);
                MostrarNomeItemSelecionado();

                if (PodePegarItem)
                {
                    //Trava Jogador
                    PegandoItem = true;
                    //tempControleCamera.ControleAba=false;
                }

                if (PodePegarItem && Input.GetMouseButtonDown(0))
                {
                    //Pegando Item Padrao
                    if (RaioPegar.collider.gameObject.tag == "Item" && !Inventario.GetComponent <ControleInventario>().InventarioCheio_FaltaSlot)
                    {
                        ControleItem tempControleItem = RaioPegar.collider.gameObject.GetComponent <ControleItem>();
                        PegarInformacaoItem(tempControleItem.NomeItem, tempControleItem.TipoItem, tempControleItem.PesoItem, tempControleItem.QuantidadeItem, tempControleItem.ThumItem, tempControleItem.ItemAgrupavel, tempControleItem.IndiceRef3D);
                        Destroy(RaioPegar.collider.gameObject);
                        PegouItem = true;
                    }
                    if (RaioPegar.collider.gameObject.tag == "Moeda")
                    {
                        ControleItem       tempControleItem       = RaioPegar.collider.gameObject.GetComponent <ControleItem>();
                        ControleInventario tempControleInventario = Inventario.GetComponent <ControleInventario>();
                        tempControleInventario.Moedas += tempControleItem.QuantidadeMoeda;
                        Destroy(RaioPegar.collider.gameObject);
                        PegouItem = true;
                    }
                }
            }

            UltimoItemSelecionado = ItemSelecionado;
        }
        else
        {
            if (!PegouItem)
            {
                PegandoItem = false;

                //tempControleCamera.ControleAba=true;
                PodePegarItem = false;
            }
            Fundo_InfoNomeItem.gameObject.SetActive(false);
        }

        if (PegouItem && Input.GetMouseButtonUp(0))
        {
            PegandoItem = false;

            //tempControleCamera.ControleAba=true;
            PegouItem = false;
        }
    }