예제 #1
0
    private void Update()
    {
        if (playerInRange)
        {
            if (canInteract)
            {
                HandleInteractivesUI();
            }
            _canDesactivate = true;

            if (Input.GetButtonDown("Fire2"))
            {
                if (dialogTrigger.ReturnState() == DialogState.unactive)
                {
                    dialogTrigger.TriggerDialog();
                }
                else if (dialogTrigger.ReturnState() == DialogState.active && dialogTrigger.dialog.isTyped != true)
                {
                    dialogTrigger.DisplayNextSentence();
                }
            }
        }
        else
        {
            if (dialogTrigger.ReturnState() == DialogState.active && _canDesactivate)
            {
                dialogTrigger.EndDialog();
            }
            _canDesactivate = false;
        }
    }
예제 #2
0
 private void OnTriggerExit2D(Collider2D collision)
 {
     if (collision.CompareTag("Player"))
     {
         if (_dialogTrigger)
         {
             _dialogTrigger.EndDialog();
         }
     }
 }
예제 #3
0
 // Update is called once per frame
 void Update()
 {
     if (isGameOver)
     {
     }
     else
     {
         if (!peasantsSpawned && cameraHandler.gameIsReady)
         {
             SpawnPeasants();
             peasantsSpawned = true;
         }
         if (currentPeasant != peasants.Count)
         {
             if (peasantsSpawned && !inDialog && Vector3.Distance(peasants[currentPeasant].transform.position, destination.position) <= 0.1)
             {
                 inDialog = true;
                 StartDialog(peasants[currentPeasant]);
             }
             else if (peasantsSpawned)
             {
                 peasants[currentPeasant].GetComponent <MovementHandler>().destination = destination.position;
             }
             if (peasantsSpawned && inDialog)
             {
                 if (dialogTrigger.dialogue.sentences.Length + 1 == dialogTrigger.currentSentenceCounter)
                 {
                     dialogTrigger.EndDialog();
                     inDialog = false;
                     peasants[currentPeasant].GetComponent <MovementHandler>().destination = spawnPoint.position;
                     for (var i = peasants.Count - 1; i > currentPeasant + 1; i--)
                     {
                         peasants[i].GetComponent <MovementHandler>().destination.x = peasants[i - 1].GetComponent <MovementHandler>().destination.x;
                     }
                     //peasants[currentPeasant].transform.rotation = Quaternion.LookRotation(Vector3.forward, Vector3.up);
                     currentPeasant++;
                 }
             }
         }
         if (peasantsSpawned && currentPeasant == peasants.Count)
         {
             if (Input.GetMouseButtonDown(0))
             {
                 cameraHandler.selectChoice = true;
             }
         }
     }
 }