Example #1
0
    //Casts a ray to see if we hit an NPC and, if so, we interact
    void TryInteract()
    {
        RaycastHit rHit;

        if (Physics.Raycast(transform.position, transform.forward, out rHit, 2))
        {
            //In this example, we will try to interact with any collider the raycast finds

            //Lets grab the NPC's DialogueAssign script... if there's any
            VIDE_Assign assigned;
            if (rHit.collider.GetComponent <VIDE_Assign>() != null)
            {
                assigned = rHit.collider.GetComponent <VIDE_Assign>();
            }
            else
            {
                return;
            }

            if (!diagUI.dialogue.isLoaded)
            {
                //... and use it to begin the conversation
                diagUI.Begin(assigned);
            }
            else
            {
                //If conversation already began, let's just progress through it
                diagUI.NextNode();
            }
        }
    }
Example #2
0
    // Update is called once per frame
    public void Update()
    {
        //Only allow player to move and turn if there are no dialogs loaded

        /* if (!diagUI.dialogue.isLoaded)
         * {
         *   transform.Rotate(0, Input.GetAxis("Mouse X") * 5, 0);
         *   float move = Input.GetAxisRaw("Vertical");
         *   transform.position += transform.forward * 5 * move * Time.deltaTime;
         * }*/

        if (diagUI.dialogue.isLoaded && Input.GetMouseButtonDown(0))
        {
            diagUI.NextNode();
        }



        if (Input.GetMouseButtonDown(1))
        {
            MoverPersonaje();
        }
    }
Example #3
0
    public void TryInteract()
    {
        if (theOnlyHero == null)
        {
            theOnlyHero = GameObject.FindGameObjectWithTag("Player").GetComponent <HeroesMovement>();
        }
        if (diagUI == null)
        {
            diagUI = GameObject.Find("LocalDataSingleton").transform.GetComponentInChildren <exampleUI>();
        }
        Vector2 choosenOne = GeneralDir == Vector2.zero ? GameObject.FindGameObjectWithTag("Player").GetComponent <HeroesMovement>().directionOfHero : GeneralDir;

        RaycastHit2D rHit = Physics2D.Raycast((Vector2)theOnlyHero.transform.position + choosenOne, choosenOne, 1.0f);

        if (rHit.collider != null)
        {
            //In this example, we will try to interact with any collider the raycast finds
            //Lets grab the NPC's DialogueAssign script... if there's any

            VIDE_Assign assigned;
            if (rHit.collider.GetComponent <VIDE_Assign>() != null)
            {
                assigned = rHit.collider.GetComponent <VIDE_Assign>();
            }
            else
            {
                return;
            }

            if (!diagUI.dialogue.isLoaded)
            {
                //... and use it to begin the conversation
                diagUI.Begin(assigned);
                LocalDataSingleton.instance.talking = true;
            }
            else
            {
                //If conversation already began, let's just progress through it
                diagUI.NextNode();
            }
//#if UNITY_ANDROID
//            if (rHit.collider.GetComponent<minUIExample>() != null && !LocalDataSingleton.instance.talking)
//            {
//                LocalDataSingleton.instance.talking = true;
//                rHit.collider.GetComponent<minUIExample>().dialogue.BeginDialogue(rHit.collider.GetComponent <VIDE_Assign>());
//                Debug.Log("AC");
//            }
//#endif
        }
    }