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); } } } } }
public void setQueuedAction(GameObject newObjectToActUpon, InteractableObjectScript.InteractionType newInteraction) { queuedAction.objectToActUpon = newObjectToActUpon; if (newObjectToActUpon == null) { queuedAction.anActionIsQueued = false; } else { queuedAction.anActionIsQueued = true; // start moving towards object destinationPosition = new Vector3(queuedAction.objectToActUpon.transform.position.x, transform.position.y, queuedAction.objectToActUpon.transform.position.z); navMeshAgent.SetDestination(destinationPosition); navMeshAgent.isStopped = false; } queuedAction.interactionType = newInteraction; }