Пример #1
0
    private void OnTriggerStay(Collider other)
    {
        Debug.Log("object collision");
        player = GameObject.FindGameObjectWithTag("Player");

        if (other.gameObject.Equals(player))
        {
            Debug.Log("Player collision");
            PlayerInputScript playerScript = player.GetComponent <PlayerInputScript>();
            if (playerScript.isAnActionQueued())
            {
                Debug.Log("Action queued");
                GameObject queuedObject = playerScript.getQueuedActionObject();
                if (queuedObject.Equals(transform.parent.gameObject))
                {
                    playerScript.stopMovement();
                    // TODO: make player look at parent object
                    InteractableObjectScript.InteractionType interaction = playerScript.getQueuedActionType();
                    playerScript.setQueuedAction(null, InteractableObjectScript.InteractionType.Examine); // reset queued action to stop this function running indefinitely

                    if (interaction == InteractableObjectScript.InteractionType.Combine)
                    {
                        if (!GameManagerScript.gameManager.combineActors(playerScript.combiningItem, transform.parent.GetComponent <InteractableObjectScript>()))
                        {
                            GameManagerScript.gameManager.conversationUI.GetComponent <ConversationScript>().showConversation(GameManagerScript.gameManager.failedItemCombinationConversationData);
                            //player.GetComponent<PlayerInputScript>().enableExamineObjectText("I can't combine those...");
                        }
                    }
                    else if (interaction == InteractableObjectScript.InteractionType.GoTo)
                    {
                        LeaveSceneScript leaveSceneScript = queuedObject.GetComponent <LeaveSceneScript>();
                        if (leaveSceneScript.adjacentSceneName == "map_screen")
                        {
                            GameManagerScript.gameManager.openMapScreen();
                        }
                        else
                        {
                            GameManagerScript.gameManager.fadeAndLoadScene(leaveSceneScript.adjacentSceneName);
                        }
                    }
                    else
                    {
                        objectScript.doAction(interaction);
                    }
                }
            }
        }
    }
Пример #2
0
 public void setHighlightedWorldObjectToSceneExit(LeaveSceneScript sceneExit)
 {
     // if the mouse is over a UI element, they shouldn't be able to highlight objects beneath UI
     if (mouseOverUI)
     {
         return;
     }
     setHighlightedWorldObjectToNull();
     highlightedSceneExit = sceneExit;
     UI_nameOfHighlightedObject.GetComponent <Text>().enabled = true;
     if (sceneExit.adjacentSceneName == "map_screen")
     {
         UI_nameOfHighlightedObject.GetComponent <Text>().text = "Leave";
     }
     else
     {
         UI_nameOfHighlightedObject.GetComponent <Text>().text = "Go to " + sceneExit.adjacentSceneName;
     }
     UI_nameOfHighlightedObject.transform.position = new Vector3(Input.mousePosition.x, Input.mousePosition.y + 20, Input.mousePosition.z);
 }
Пример #3
0
 public void stopHighlighingSceneExit()
 {
     UI_nameOfHighlightedObject.GetComponent <Text>().enabled = false;
     highlightedSceneExit = null;
 }