Exemple #1
0
        // Update is called once per frame
        void Update()
        {
            if (Input.GetMouseButtonDown(0))
            {
                Vector2      mouseWorldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                RaycastHit2D hit           = Physics2D.Raycast(mouseWorldPos, Vector2.zero);

                //try
                //{
                if (hit)
                {
                    if (hit.transform.name == "Bill" || hit.transform.name == "Jane")
                    {
                        lastClicked = hit.transform.gameObject;
                        Debug.Log("Clicked an NPC");
                        dialogueSetup = (Dialogue_Setup)lastClicked.GetComponent("Dialogue_Setup");
                        DialogueButtonPressed();
                        Grid_Helper.inventory.OpenInventory();
                    }
                }
                else
                {
                    if (lastClicked)
                    {
                        dialogueSetup = (Dialogue_Setup)lastClicked.GetComponent("Dialogue_Setup");
                        Grid_Helper.dialogueData.DisplayDialoguePanel(false);
                        Grid_Helper.inventory.CloseInventory();
                    }
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// Finds the closest dialogue.
 /// </summary>
 public void FindClosestDialogue(GameObject player)
 {
     // IF we are not already engaged in a dialogue.
     if (!IsActionKeyDialogued)
     {
         // Preset a distance variable to detect the closest action key dialogue.
         float _dist = -1f;
         // Loop through all the Dialogue_Setups.
         for (int i = 0; i < ListOfActionKeyDialogues.Count; i++)
         {
             // See which one is the closest.
             float dist = Vector2.Distance(player.transform.position, ListOfActionKeyDialogues [i].transform.position);
             // IF this is the first time in here. Also this takes care of 1 Interactive NPC in the List.
             // ELSE IF we have more interactive npcs and we need to compare distance to see which is closest.
             if (_dist == -1f)
             {
                 // Set the shortest distance.
                 _dist = dist;
                 // Set the closest action key dialogue.
                 closestDialogue = ListOfActionKeyDialogues [i];
             }
             else if (dist < _dist)
             {
                 // Set the shortest distance.
                 _dist = dist;
                 // Set the closest action key dialogue.
                 closestDialogue = ListOfActionKeyDialogues [i];
             }
         }
         // We are now engaged in a dialogue.
         IsActionKeyDialogued = true;
     }
 }
Exemple #3
0
 public void SetDialogueSetup(Dialogue_Setup newDialogueSetup)
 {
     dialogueSetup = newDialogueSetup;
 }
Exemple #4
0
 /// <summary>
 /// Removes from dialogue list.
 /// </summary>
 public void RemoveFromDialogueList(Dialogue_Setup dialogueSetup)
 {
     ListOfActionKeyDialogues.Remove(dialogueSetup);
 }
Exemple #5
0
 /// <summary>
 /// Adds to dialogue list.
 /// </summary>
 public void AddToDialogueList(Dialogue_Setup dialogueSetup)
 {
     ListOfActionKeyDialogues.Add(dialogueSetup);
 }
Exemple #6
0
 /// <summary>
 /// Sets the closest dialogue.
 /// </summary>
 public void SetClosestDialogue(Dialogue_Setup newClosestDialogue)
 {
     closestDialogue = newClosestDialogue;
 }