add ckg
plantilla base para movimiento básico
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class characterDialogContentSystem : MonoBehaviour
|
||||
{
|
||||
public dialogContentSystem mainDialogContentSystem;
|
||||
|
||||
public electronicDevice mainElectronicDevice;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee17404a9d6945448ba953a9d81d6756
|
||||
timeCreated: 1578109477
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Dialog System/characterDialogContentSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,237 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using GameKitController.Audio;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
|
||||
[System.Serializable]
|
||||
public class completeDialogInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public int ID;
|
||||
|
||||
public bool playDialogWithoutPausingPlayerActions;
|
||||
|
||||
public bool playDialogsAutomatically = true;
|
||||
|
||||
public bool pausePlayerActionsInput;
|
||||
public bool pausePlayerMovementInput;
|
||||
|
||||
public bool canUseInputToSetNextDialog = true;
|
||||
|
||||
public bool showFullDialogLineOnInputIfTextPartByPart = true;
|
||||
|
||||
public bool showDialogLineWordByWord;
|
||||
|
||||
public float dialogLineWordSpeed = 0.5f;
|
||||
|
||||
public bool showDialogLineLetterByLetter;
|
||||
|
||||
public float dialogLineLetterSpeed = 0.03f;
|
||||
|
||||
public bool useCustomTextAnchorAndAligment;
|
||||
public TextAnchor textAnchor = TextAnchor.MiddleCenter;
|
||||
|
||||
public bool stopDialogIfPlayerDistanceTooFar;
|
||||
public float maxDistanceToStopDialog;
|
||||
public bool rewindLastDialogIfStopped;
|
||||
|
||||
public UnityEvent eventOnDialogStopped;
|
||||
|
||||
public bool playDialogOnTriggerEnter;
|
||||
public UnityEvent eventToPlayDialogOnTriggerEnter;
|
||||
|
||||
public List<dialogInfo> dialogInfoList = new List<dialogInfo> ();
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class dialogInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public int ID;
|
||||
|
||||
public string dialogOwnerName;
|
||||
|
||||
[TextArea (3, 10)] public string dialogContent;
|
||||
|
||||
public bool showPreviousDialogLineOnOptions;
|
||||
|
||||
public List<dialogLineInfo> dialogLineInfoList = new List<dialogLineInfo> ();
|
||||
|
||||
public UnityEvent eventOnDialog;
|
||||
|
||||
public bool useEventToSendPlayer;
|
||||
public eventParameters.eventToCallWithGameObject eventToSendPlayer;
|
||||
|
||||
public bool activateWhenDialogClosed;
|
||||
public bool activateRemoteTriggerSystem;
|
||||
public string remoteTriggerName;
|
||||
|
||||
public bool useNexLineButton = true;
|
||||
|
||||
public bool isEndOfDialog;
|
||||
|
||||
public bool changeToDialogInfoID;
|
||||
public int dialogInfoIDToActivate;
|
||||
|
||||
public bool useRandomDialogInfoID;
|
||||
public bool useRandomDialogRange;
|
||||
public Vector2 randomDialogRange;
|
||||
public List<int> randomDialogIDList = new List<int> ();
|
||||
|
||||
public bool checkConditionForNextLine;
|
||||
|
||||
public int dialogInfoIDToActivateOnConditionTrue;
|
||||
public int dialogInfoIDToActivateOnConditionFalse;
|
||||
|
||||
public UnityEvent eventToCheckConditionForNextLine;
|
||||
|
||||
public bool useEventToSendPlayerToCondition;
|
||||
public eventParameters.eventToCallWithGameObject eventToSendPlayerToCondition;
|
||||
|
||||
public bool disableDialogAfterSelect;
|
||||
public int dialogInfoIDToJump;
|
||||
public bool dialogInfoDisabled;
|
||||
|
||||
public bool setNextCompleteDialogID;
|
||||
|
||||
public bool setNewCompleteDialogID;
|
||||
public int newCompleteDialogID;
|
||||
|
||||
public float delayToShowNextDialogLine = 5;
|
||||
public float delayToShowThisDialogLine;
|
||||
|
||||
public bool useDialogLineSound;
|
||||
public AudioClip dialogLineSound;
|
||||
public AudioElement dialogLineAudioElement;
|
||||
|
||||
public bool useAnimations;
|
||||
public string animationName;
|
||||
public float delayToPlayAnimation;
|
||||
|
||||
public bool useDelayToDisableAnimation;
|
||||
public float delayToDisableAnimation;
|
||||
|
||||
public bool animationUsedOnPlayer;
|
||||
|
||||
public bool enableAnimatorLayer = true;
|
||||
public string animatorLayerToEnableName = "Dialogue";
|
||||
|
||||
public bool characterFollowPlayerAfterDialogEnd;
|
||||
|
||||
public void InitializeAudioElements ()
|
||||
{
|
||||
if (dialogLineSound != null) {
|
||||
dialogLineAudioElement.clip = dialogLineSound;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class dialogLineInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public int ID;
|
||||
[TextArea (3, 10)] public string dialogLineContent;
|
||||
|
||||
public int dialogInfoIDToActivate;
|
||||
|
||||
public bool useRandomDialogInfoID;
|
||||
public bool useRandomDialogRange;
|
||||
public Vector2 randomDialogRange;
|
||||
public List<int> randomDialogIDList = new List<int> ();
|
||||
|
||||
public bool activateRemoteTriggerSystem;
|
||||
public string remoteTriggerName;
|
||||
|
||||
public Button dialogLineButton;
|
||||
|
||||
public bool disableLineAfterSelect;
|
||||
|
||||
public bool lineDisabled;
|
||||
|
||||
public bool useStatToShowLine;
|
||||
public string statName;
|
||||
public bool statIsAmount;
|
||||
public float minStateValue;
|
||||
public bool boolStateValue;
|
||||
|
||||
public bool answerNotAvailable;
|
||||
public string extraDialogLineContent;
|
||||
|
||||
public bool checkConditionForNextLine;
|
||||
|
||||
public int dialogInfoIDToActivateOnConditionTrue;
|
||||
public int dialogInfoIDToActivateOnConditionFalse;
|
||||
|
||||
public UnityEvent eventToCheckConditionForNextLine;
|
||||
|
||||
public bool useEventToSendPlayerToCondition;
|
||||
public eventParameters.eventToCallWithGameObject eventToSendPlayerToCondition;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Dialog Info use for the localization system
|
||||
|
||||
[System.Serializable]
|
||||
public class completeDialogInfoTemplate
|
||||
{
|
||||
public string language;
|
||||
|
||||
[Space]
|
||||
|
||||
public List<simpleCompleteDialogInfo> completeDialogInfoList = new List<simpleCompleteDialogInfo> ();
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class simpleCompleteDialogInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public int ID;
|
||||
|
||||
[Space]
|
||||
|
||||
public List<simpleDialogInfo> dialogInfoList = new List<simpleDialogInfo> ();
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class simpleDialogInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public int ID;
|
||||
|
||||
public string dialogOwnerName;
|
||||
|
||||
[TextArea (3, 10)] public string dialogContent;
|
||||
|
||||
public AudioClip dialogLineSound;
|
||||
public AudioElement dialogLineAudioElement;
|
||||
|
||||
[Space]
|
||||
|
||||
public List<simpleDialogLineInfo> dialogLineInfoList = new List<simpleDialogLineInfo> ();
|
||||
|
||||
public void InitializeAudioElements ()
|
||||
{
|
||||
if (dialogLineSound != null) {
|
||||
dialogLineAudioElement.clip = dialogLineSound;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class simpleDialogLineInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public int ID;
|
||||
|
||||
[TextArea (3, 10)] public string dialogLineContent;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a68f2b79ebd24074c821e687f573037a
|
||||
timeCreated: 1555286236
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Dialog System/completeDialogInfo.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,522 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class dialogContentSystem : MonoBehaviour
|
||||
{
|
||||
public int dialogContentID;
|
||||
|
||||
public int dialogContentScene;
|
||||
|
||||
public List<completeDialogInfo> completeDialogInfoList = new List<completeDialogInfo> ();
|
||||
|
||||
public int currentDialogIndex;
|
||||
|
||||
public GameObject dialogOwner;
|
||||
|
||||
public bool showDialogOnwerName;
|
||||
|
||||
public bool dialogActive;
|
||||
|
||||
public bool dialogInProcess;
|
||||
|
||||
public bool playingExternalDialog;
|
||||
|
||||
public bool useEventsOnStartEndDialog;
|
||||
public UnityEvent eventOnStartDialog;
|
||||
public UnityEvent eventOnEndDialog;
|
||||
|
||||
public bool pauseAIOnDialogStart;
|
||||
public bool resumeAIOnDialogEnd;
|
||||
public bool interruptWanderAroundStateIfActiveOnDialogStart;
|
||||
public bool disableWanderAroundStateOnDialogEnd;
|
||||
|
||||
|
||||
public bool useAnimations;
|
||||
public Animator mainAnimator;
|
||||
public playerController mainPlayerController;
|
||||
|
||||
public bool playerAnimationsOnDialogEnabled = true;
|
||||
|
||||
public string dialogueActiveAnimatorName = "Dialogue Active";
|
||||
|
||||
|
||||
public GameObject newCharacterToAddDialog;
|
||||
|
||||
|
||||
public bool useDialogContentTemplate;
|
||||
public dialogContentTemplate mainDialogContentTemplate;
|
||||
|
||||
|
||||
GameObject currentPlayer;
|
||||
|
||||
Coroutine playDialogOnTriggerEnterCoroutine;
|
||||
|
||||
|
||||
Coroutine disableDialogCharacterAnimatorCoroutine;
|
||||
|
||||
|
||||
private void InitializeAudioElements ()
|
||||
{
|
||||
foreach (var completeDialogInfo in completeDialogInfoList)
|
||||
foreach (var dialogInfo in completeDialogInfo.dialogInfoList)
|
||||
dialogInfo.InitializeAudioElements ();
|
||||
}
|
||||
|
||||
private void Start ()
|
||||
{
|
||||
InitializeAudioElements ();
|
||||
}
|
||||
|
||||
public void setCurrentPlayer (GameObject newPlayer)
|
||||
{
|
||||
currentPlayer = newPlayer;
|
||||
}
|
||||
|
||||
public void activateDialog ()
|
||||
{
|
||||
if (dialogInProcess) {
|
||||
|
||||
bool canActivateDialog = false;
|
||||
|
||||
if (playingExternalDialog) {
|
||||
if (currentDialogIndex < completeDialogInfoList.Count && completeDialogInfoList [currentDialogIndex].playDialogWithoutPausingPlayerActions) {
|
||||
canActivateDialog = true;
|
||||
|
||||
dialogActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!canActivateDialog) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentPlayer == null) {
|
||||
print ("WARNING: current player hasn't been assigned, make sure to assign the function to set current player into the electronic device component");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
dialogActive = !dialogActive;
|
||||
|
||||
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
|
||||
|
||||
dialogSystem currentDialogSystem = null;
|
||||
|
||||
if (currentPlayerComponentsManager != null) {
|
||||
currentDialogSystem = currentPlayerComponentsManager.getMainDialogSystem ();
|
||||
}
|
||||
|
||||
if (dialogActive) {
|
||||
if (currentDialogSystem != null) {
|
||||
currentDialogSystem.setNewDialogContent (this);
|
||||
}
|
||||
} else {
|
||||
if (currentDialogSystem != null) {
|
||||
if (applyDamage.checkIfDead (currentPlayer)) {
|
||||
currentDialogSystem.closeDialogIfActive ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setDialogInProcessState (bool state)
|
||||
{
|
||||
dialogInProcess = state;
|
||||
|
||||
if (!dialogInProcess) {
|
||||
dialogActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void activateEventOnDialogStopped ()
|
||||
{
|
||||
if (currentDialogIndex < completeDialogInfoList.Count) {
|
||||
if (completeDialogInfoList [currentDialogIndex].playDialogWithoutPausingPlayerActions) {
|
||||
completeDialogInfoList [currentDialogIndex].eventOnDialogStopped.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setNextCompleteDialogIndex ()
|
||||
{
|
||||
currentDialogIndex++;
|
||||
|
||||
if (currentDialogIndex >= completeDialogInfoList.Count) {
|
||||
currentDialogIndex = completeDialogInfoList.Count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
public void setPrevioustCompleteDialogIndex ()
|
||||
{
|
||||
currentDialogIndex--;
|
||||
|
||||
if (currentDialogIndex < 0) {
|
||||
currentDialogIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void setCompleteDialogIndex (int newIndex)
|
||||
{
|
||||
currentDialogIndex = newIndex;
|
||||
|
||||
if (currentDialogIndex >= completeDialogInfoList.Count) {
|
||||
currentDialogIndex = completeDialogInfoList.Count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
public void setPlayingExternalDialogState (bool state)
|
||||
{
|
||||
playingExternalDialog = state;
|
||||
}
|
||||
|
||||
public void checkIfPlayDialogOnTriggerEnter ()
|
||||
{
|
||||
if (playDialogOnTriggerEnterCoroutine != null) {
|
||||
StopCoroutine (playDialogOnTriggerEnterCoroutine);
|
||||
}
|
||||
|
||||
playDialogOnTriggerEnterCoroutine = StartCoroutine (checkIfPlayDialogOnTriggerEnterCoroutine ());
|
||||
}
|
||||
|
||||
IEnumerator checkIfPlayDialogOnTriggerEnterCoroutine ()
|
||||
{
|
||||
yield return new WaitForEndOfFrame ();
|
||||
|
||||
if (completeDialogInfoList [currentDialogIndex].playDialogOnTriggerEnter) {
|
||||
completeDialogInfoList [currentDialogIndex].eventToPlayDialogOnTriggerEnter.Invoke ();
|
||||
}
|
||||
}
|
||||
|
||||
public void disableDialogCharacterAnimatorState (float delayAmount)
|
||||
{
|
||||
if (!useAnimations) {
|
||||
return;
|
||||
}
|
||||
|
||||
stopDisableDialogCharacterAnimatorStateCoroutine ();
|
||||
|
||||
disableDialogCharacterAnimatorCoroutine = StartCoroutine (disableDialogCharacterAnimatorStateCoroutine (delayAmount));
|
||||
}
|
||||
|
||||
public void stopDisableDialogCharacterAnimatorStateCoroutine ()
|
||||
{
|
||||
if (disableDialogCharacterAnimatorCoroutine != null) {
|
||||
StopCoroutine (disableDialogCharacterAnimatorCoroutine);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator disableDialogCharacterAnimatorStateCoroutine (float delayAmount)
|
||||
{
|
||||
yield return new WaitForSeconds (delayAmount);
|
||||
|
||||
setDialogAnimatorState (false);
|
||||
}
|
||||
|
||||
public void setDialogAnimatorState (bool state)
|
||||
{
|
||||
if (mainAnimator != null) {
|
||||
mainAnimator.SetBool (dialogueActiveAnimatorName, state);
|
||||
}
|
||||
|
||||
if (mainPlayerController != null) {
|
||||
mainPlayerController.setApplyRootMotionAlwaysActiveState (state);
|
||||
}
|
||||
}
|
||||
|
||||
public void enableAnimatorLayerWeight (string animatorLayerName)
|
||||
{
|
||||
if (mainPlayerController != null) {
|
||||
mainPlayerController.enableAnimatorLayerWeight (animatorLayerName);
|
||||
}
|
||||
}
|
||||
|
||||
public void checkEventsOnDialog (bool state)
|
||||
{
|
||||
if (useEventsOnStartEndDialog) {
|
||||
if (state) {
|
||||
eventOnStartDialog.Invoke ();
|
||||
} else {
|
||||
eventOnEndDialog.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkIfPauseOrResumeAI (bool state)
|
||||
{
|
||||
if (dialogOwner == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
playerComponentsManager mainPlayerComponentsManager = dialogOwner.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (mainPlayerComponentsManager != null) {
|
||||
AINavMesh mainAINavmesh = dialogOwner.GetComponent<AINavMesh> ();
|
||||
findObjectivesSystem mainFindObjectivesSystem = dialogOwner.GetComponent<findObjectivesSystem> ();
|
||||
|
||||
if (mainAINavmesh == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mainFindObjectivesSystem == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (state) {
|
||||
if (interruptWanderAroundStateIfActiveOnDialogStart) {
|
||||
mainFindObjectivesSystem.checkIfInterruptWanderState ();
|
||||
}
|
||||
|
||||
if (pauseAIOnDialogStart) {
|
||||
mainAINavmesh.pauseAI (true);
|
||||
}
|
||||
} else {
|
||||
if (resumeAIOnDialogEnd) {
|
||||
mainAINavmesh.pauseAI (false);
|
||||
}
|
||||
|
||||
if (disableWanderAroundStateOnDialogEnd) {
|
||||
mainFindObjectivesSystem.disableWanderState ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkIfAIFollowPlayerAfterDialogEnd (bool state)
|
||||
{
|
||||
if (dialogOwner == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
playerComponentsManager mainPlayerComponentsManager = dialogOwner.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (mainPlayerComponentsManager != null) {
|
||||
findObjectivesSystem mainFindObjectivesSystem = dialogOwner.GetComponent<findObjectivesSystem> ();
|
||||
|
||||
if (mainFindObjectivesSystem == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (state) {
|
||||
if (currentPlayer != null) {
|
||||
mainFindObjectivesSystem.addPlayerAsPartner (currentPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setDialogAnswerConditionCheckResult (bool state)
|
||||
{
|
||||
if (dialogActive) {
|
||||
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (currentPlayerComponentsManager != null) {
|
||||
dialogSystem currentDialogSystem = currentPlayerComponentsManager.getMainDialogSystem ();
|
||||
|
||||
if (currentDialogSystem != null) {
|
||||
currentDialogSystem.setDialogAnswerConditionCheckResult (state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setNextDialogWithConditionCheckResult (bool state)
|
||||
{
|
||||
if (dialogActive) {
|
||||
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (currentPlayerComponentsManager != null) {
|
||||
dialogSystem currentDialogSystem = currentPlayerComponentsManager.getMainDialogSystem ();
|
||||
|
||||
if (currentDialogSystem != null) {
|
||||
currentDialogSystem.setNextDialogWithConditionCheckResult (state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public completeDialogInfoTemplate getCompleteDialogInfoTemplateByLanguageName (string languageName)
|
||||
{
|
||||
for (int i = 0; i < mainDialogContentTemplate.completeDialogInfoTemplateList.Count; i++) {
|
||||
|
||||
if (mainDialogContentTemplate.completeDialogInfoTemplateList [i].language.Equals (languageName)) {
|
||||
return mainDialogContentTemplate.completeDialogInfoTemplateList [i];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getDialogContentID ()
|
||||
{
|
||||
return dialogContentID;
|
||||
}
|
||||
|
||||
public int getDialogContentScene ()
|
||||
{
|
||||
return dialogContentScene;
|
||||
}
|
||||
|
||||
public int getCurrentDialogIndex ()
|
||||
{
|
||||
return currentDialogIndex;
|
||||
}
|
||||
|
||||
//Editor functions
|
||||
public void addNewDialog ()
|
||||
{
|
||||
completeDialogInfo newCompleteDialogInfo = new completeDialogInfo ();
|
||||
|
||||
newCompleteDialogInfo.ID = completeDialogInfoList.Count;
|
||||
|
||||
completeDialogInfoList.Add (newCompleteDialogInfo);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void addNewLine (int dialogIndex)
|
||||
{
|
||||
dialogInfo newDialogInfo = new dialogInfo ();
|
||||
|
||||
newDialogInfo.ID = completeDialogInfoList [dialogIndex].dialogInfoList.Count;
|
||||
|
||||
completeDialogInfoList [dialogIndex].dialogInfoList.Add (newDialogInfo);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void addNewAnswer (int dialogIndex, int lineIndex)
|
||||
{
|
||||
dialogLineInfo newDialogLineInfo = new dialogLineInfo ();
|
||||
|
||||
newDialogLineInfo.ID = completeDialogInfoList [dialogIndex].dialogInfoList [lineIndex].dialogLineInfoList.Count;
|
||||
|
||||
completeDialogInfoList [dialogIndex].dialogInfoList [lineIndex].dialogLineInfoList.Add (newDialogLineInfo);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void assignIDToDialog (int newID)
|
||||
{
|
||||
dialogContentID = newID;
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void assignDialogContentScene (int newScene)
|
||||
{
|
||||
dialogContentScene = newScene;
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void setDialogOwnerGameObject (GameObject newOwner)
|
||||
{
|
||||
dialogOwner = newOwner;
|
||||
|
||||
if (newOwner != null) {
|
||||
mainPlayerController = newOwner.GetComponentInChildren<playerController> ();
|
||||
|
||||
if (mainPlayerController != null) {
|
||||
dialogOwner = mainPlayerController.gameObject;
|
||||
|
||||
mainAnimator = mainPlayerController.getCharacterAnimator ();
|
||||
|
||||
Transform previousParent = transform.parent;
|
||||
|
||||
transform.SetParent (mainPlayerController.transform.parent);
|
||||
|
||||
transform.localPosition = Vector3.zero;
|
||||
transform.localRotation = Quaternion.identity;
|
||||
|
||||
transform.SetParent (previousParent);
|
||||
|
||||
followObjectPositionSystem newFollowObjectPositionSystem = GetComponent<followObjectPositionSystem> ();
|
||||
|
||||
if (newFollowObjectPositionSystem != null) {
|
||||
newFollowObjectPositionSystem.setObjectToFollowFromEditor (dialogOwner.transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void addDialogToCharacterManually ()
|
||||
{
|
||||
if (newCharacterToAddDialog != null) {
|
||||
|
||||
setDialogOwnerGameObject (newCharacterToAddDialog);
|
||||
|
||||
newCharacterToAddDialog = null;
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
}
|
||||
|
||||
public void addDialogContentToTemplate ()
|
||||
{
|
||||
if (mainDialogContentTemplate == null) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (mainDialogContentTemplate != null) {
|
||||
completeDialogInfoTemplate newCompleteDialogInfoTemplate = new completeDialogInfoTemplate ();
|
||||
|
||||
newCompleteDialogInfoTemplate.language = "English";
|
||||
|
||||
for (int i = 0; i < completeDialogInfoList.Count; i++) {
|
||||
completeDialogInfo currentCompleteDialogInfo = completeDialogInfoList [i];
|
||||
|
||||
simpleCompleteDialogInfo newSimpleCompleteDialogInfo = new simpleCompleteDialogInfo ();
|
||||
|
||||
newSimpleCompleteDialogInfo.Name = currentCompleteDialogInfo.Name;
|
||||
newSimpleCompleteDialogInfo.ID = currentCompleteDialogInfo.ID;
|
||||
|
||||
for (int j = 0; j < currentCompleteDialogInfo.dialogInfoList.Count; j++) {
|
||||
dialogInfo currentDialogInfo = currentCompleteDialogInfo.dialogInfoList [j];
|
||||
|
||||
simpleDialogInfo newSimpleDialogInfo = new simpleDialogInfo ();
|
||||
|
||||
newSimpleDialogInfo.Name = currentDialogInfo.Name;
|
||||
newSimpleDialogInfo.ID = currentDialogInfo.ID;
|
||||
newSimpleDialogInfo.dialogOwnerName = currentDialogInfo.dialogOwnerName;
|
||||
newSimpleDialogInfo.dialogContent = currentDialogInfo.dialogContent;
|
||||
newSimpleDialogInfo.dialogLineSound = currentDialogInfo.dialogLineSound;
|
||||
newSimpleDialogInfo.dialogLineAudioElement = currentDialogInfo.dialogLineAudioElement;
|
||||
|
||||
for (int k = 0; k < currentDialogInfo.dialogLineInfoList.Count; k++) {
|
||||
dialogLineInfo currentDialogLineInfo = currentDialogInfo.dialogLineInfoList [k];
|
||||
|
||||
simpleDialogLineInfo newSimpleDialogLineInfo = new simpleDialogLineInfo ();
|
||||
|
||||
newSimpleDialogLineInfo.Name = currentDialogLineInfo.Name;
|
||||
newSimpleDialogLineInfo.ID = currentDialogLineInfo.ID;
|
||||
newSimpleDialogLineInfo.dialogLineContent = currentDialogLineInfo.dialogLineContent;
|
||||
|
||||
newSimpleDialogInfo.dialogLineInfoList.Add (newSimpleDialogLineInfo);
|
||||
}
|
||||
|
||||
newSimpleCompleteDialogInfo.dialogInfoList.Add (newSimpleDialogInfo);
|
||||
}
|
||||
|
||||
newCompleteDialogInfoTemplate.completeDialogInfoList.Add (newSimpleCompleteDialogInfo);
|
||||
}
|
||||
|
||||
mainDialogContentTemplate.completeDialogInfoTemplateList.Add (newCompleteDialogInfoTemplate);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Update Dialog Content Object " + gameObject.name, gameObject);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9fdf783067d618f479f4353a0453fd4a
|
||||
timeCreated: 1555193873
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Dialog System/dialogContentSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu (fileName = "Dialog Content Template", menuName = "GKC/Create Dialog Content Template", order = 51)]
|
||||
public class dialogContentTemplate : ScriptableObject
|
||||
{
|
||||
public string Name;
|
||||
public int ID = 0;
|
||||
|
||||
[Space]
|
||||
|
||||
public List<completeDialogInfoTemplate> completeDialogInfoTemplateList = new List<completeDialogInfoTemplate> ();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f44fe21053ee2c24fa0ee98984769875
|
||||
timeCreated: 1639451667
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Dialog System/dialogContentTemplate.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,194 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class dialogManager : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool dialogSystemEnabled = true;
|
||||
|
||||
public int dialogScene;
|
||||
|
||||
public bool saveCurrentDialogContentToSaveFile = true;
|
||||
|
||||
public LayerMask layerToPlaceObjects;
|
||||
|
||||
[Space]
|
||||
[Header ("Dialog Content System List Settings")]
|
||||
[Space]
|
||||
|
||||
public List<dialogContentSystem> dialogContentSystemList = new List<dialogContentSystem> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Prefabs List")]
|
||||
[Space]
|
||||
|
||||
public GameObject dialogContentPrefab;
|
||||
public GameObject externalDialogPrefab;
|
||||
|
||||
[HideInInspector] public GameObject lastObjectInstantiated;
|
||||
|
||||
|
||||
public const string mainManagerName = "Dialog Manager";
|
||||
|
||||
public static string getMainManagerName ()
|
||||
{
|
||||
return mainManagerName;
|
||||
}
|
||||
|
||||
|
||||
private static dialogManager _dialogManagerInstance;
|
||||
|
||||
public static dialogManager Instance { get { return _dialogManagerInstance; } }
|
||||
|
||||
bool instanceInitialized;
|
||||
|
||||
public void getComponentInstance ()
|
||||
{
|
||||
if (instanceInitialized) {
|
||||
// print ("already initialized manager");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (_dialogManagerInstance != null && _dialogManagerInstance != this) {
|
||||
Destroy (this.gameObject);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_dialogManagerInstance = this;
|
||||
|
||||
instanceInitialized = true;
|
||||
}
|
||||
|
||||
void Awake ()
|
||||
{
|
||||
getComponentInstance ();
|
||||
}
|
||||
|
||||
public void getAllDialogContentSystemOnLevel ()
|
||||
{
|
||||
dialogContentSystemList.Clear ();
|
||||
|
||||
dialogContentSystem [] newDialogContentSystemList = FindObjectsOfType<dialogContentSystem> ();
|
||||
|
||||
foreach (dialogContentSystem currentDialogContentSystem in newDialogContentSystemList) {
|
||||
if (!dialogContentSystemList.Contains (currentDialogContentSystem)) {
|
||||
dialogContentSystemList.Add (currentDialogContentSystem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void getAllDialogContentOnLevelAndAssignInfo ()
|
||||
{
|
||||
getAllDialogContentSystemOnLevel ();
|
||||
|
||||
int dialogContentID = 0;
|
||||
|
||||
for (int i = 0; i < dialogContentSystemList.Count; i++) {
|
||||
if (dialogContentSystemList [i] != null) {
|
||||
|
||||
dialogContentSystemList [i].assignIDToDialog (dialogContentID);
|
||||
|
||||
dialogContentSystemList [i].assignDialogContentScene (dialogScene);
|
||||
|
||||
dialogContentID++;
|
||||
}
|
||||
}
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void clearDialogContentList ()
|
||||
{
|
||||
dialogContentSystemList.Clear ();
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public dialogContentSystem getDialogContentSystem (int dialogContentID, int dialogContentScene)
|
||||
{
|
||||
int dialogContentSystemListCount = dialogContentSystemList.Count;
|
||||
|
||||
//Return the element on scene currently found by ID
|
||||
for (int i = 0; i < dialogContentSystemListCount; i++) {
|
||||
dialogContentSystem currentDialogContentSystem = dialogContentSystemList [i];
|
||||
|
||||
if (currentDialogContentSystem != null) {
|
||||
if (currentDialogContentSystem.getDialogContentScene () == dialogContentScene && currentDialogContentSystem.getDialogContentID () == dialogContentID) {
|
||||
|
||||
return currentDialogContentSystem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void instantiateDialogContentSystem ()
|
||||
{
|
||||
instantateObjectOnLevel (dialogContentPrefab);
|
||||
}
|
||||
|
||||
public void instantiateExternalDialogSystem ()
|
||||
{
|
||||
instantateObjectOnLevel (externalDialogPrefab);
|
||||
}
|
||||
|
||||
public void instantateObjectOnLevel (GameObject objectToInstantiate)
|
||||
{
|
||||
Vector3 positionToInstantiate = Vector3.zero;
|
||||
|
||||
Camera currentCameraEditor = GKC_Utils.getCameraEditor ();
|
||||
|
||||
if (currentCameraEditor != null) {
|
||||
Vector3 editorCameraPosition = currentCameraEditor.transform.position;
|
||||
Vector3 editorCameraForward = currentCameraEditor.transform.forward;
|
||||
|
||||
RaycastHit hit;
|
||||
|
||||
if (Physics.Raycast (editorCameraPosition, editorCameraForward, out hit, Mathf.Infinity, layerToPlaceObjects)) {
|
||||
positionToInstantiate = hit.point + Vector3.up * 0.05f;
|
||||
}
|
||||
}
|
||||
|
||||
if (objectToInstantiate) {
|
||||
|
||||
GameObject newCameraTransformElement = (GameObject)Instantiate (objectToInstantiate, positionToInstantiate, Quaternion.identity);
|
||||
newCameraTransformElement.name = objectToInstantiate.name;
|
||||
|
||||
lastObjectInstantiated = newCameraTransformElement;
|
||||
|
||||
} else {
|
||||
print ("WARNING: prefab gameObject is empty, make sure it is assigned correctly");
|
||||
}
|
||||
}
|
||||
|
||||
public GameObject getLastObjectInstantiated ()
|
||||
{
|
||||
return lastObjectInstantiated;
|
||||
}
|
||||
|
||||
public void addDialogContentToCharacter (Transform newDialogContentParent, GameObject newDialogContentOwner)
|
||||
{
|
||||
instantiateDialogContentSystem ();
|
||||
|
||||
GameObject newDialogContentGameObject = getLastObjectInstantiated ();
|
||||
|
||||
dialogContentSystem newDialogContentSystem = newDialogContentGameObject.GetComponent<dialogContentSystem> ();
|
||||
|
||||
if (newDialogContentSystem != null) {
|
||||
newDialogContentSystem.setDialogOwnerGameObject (newDialogContentOwner);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Update Dialog Manager " + gameObject.name, gameObject);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3d956ce0de474c4ca07fb0c0d16f8d1
|
||||
timeCreated: 1573362175
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Dialog System/dialogManager.cs
|
||||
uploadId: 814740
|
||||
1513
Assets/Game Kit Controller/Scripts/Dialog System/dialogSystem.cs
Normal file
1513
Assets/Game Kit Controller/Scripts/Dialog System/dialogSystem.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 276a09d6b7bd5be4283e9dc3c5446d88
|
||||
timeCreated: 1555193067
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Dialog System/dialogSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,114 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class externalDialogTriggerSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool setNewDialogIndex;
|
||||
public int newDialogIndex;
|
||||
|
||||
public bool checkDialogContentSystemID;
|
||||
public int IDToCheck;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public dialogContentSystem mainDialogContentSystem;
|
||||
public electronicDevice mainElectronicDevice;
|
||||
|
||||
[Space]
|
||||
[Header ("Set Object Manually Settings")]
|
||||
[Space]
|
||||
|
||||
public bool assignObjectManually;
|
||||
public GameObject playerToConfigure;
|
||||
|
||||
public bool searchPlayerOnSceneIfNotAssigned;
|
||||
|
||||
|
||||
public void activateDialogByCharacter (GameObject newCharacter)
|
||||
{
|
||||
characterDialogContentSystem currentCharacterDialogContentSystem = newCharacter.GetComponent<characterDialogContentSystem> ();
|
||||
|
||||
if (currentCharacterDialogContentSystem != null) {
|
||||
mainDialogContentSystem = currentCharacterDialogContentSystem.mainDialogContentSystem;
|
||||
|
||||
if (!checkDialogContentSystemID || mainDialogContentSystem.getDialogContentID () == IDToCheck) {
|
||||
|
||||
mainElectronicDevice = currentCharacterDialogContentSystem.mainElectronicDevice;
|
||||
|
||||
activateDialog ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void activateDialog ()
|
||||
{
|
||||
if (assignObjectManually) {
|
||||
if (playerToConfigure == null) {
|
||||
if (searchPlayerOnSceneIfNotAssigned) {
|
||||
findPlayerOnScene ();
|
||||
}
|
||||
}
|
||||
|
||||
if (playerToConfigure == null) {
|
||||
print ("WARNING: no object has been assigned manually on external dialog trigger system");
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
startDialog ();
|
||||
}
|
||||
|
||||
public void activateDialogToPlayer (GameObject playerToCheck)
|
||||
{
|
||||
playerToConfigure = playerToCheck;
|
||||
|
||||
if (playerToConfigure == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
startDialog ();
|
||||
}
|
||||
|
||||
void startDialog ()
|
||||
{
|
||||
if (mainDialogContentSystem != null) {
|
||||
mainDialogContentSystem.setPlayingExternalDialogState (true);
|
||||
|
||||
if (setNewDialogIndex) {
|
||||
mainDialogContentSystem.setCompleteDialogIndex (newDialogIndex);
|
||||
}
|
||||
}
|
||||
|
||||
if (mainElectronicDevice != null) {
|
||||
mainElectronicDevice.setPlayerManually (playerToConfigure);
|
||||
|
||||
if (mainDialogContentSystem.dialogInProcess) {
|
||||
playerComponentsManager currentPlayerComponentsManager = playerToConfigure.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (currentPlayerComponentsManager != null) {
|
||||
dialogSystem currentDialogSystem = currentPlayerComponentsManager.getMainDialogSystem ();
|
||||
|
||||
if (currentDialogSystem != null) {
|
||||
currentDialogSystem.inputPlayNextDialogWioutPausingPlayer ();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mainElectronicDevice.activateDevice ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void findPlayerOnScene ()
|
||||
{
|
||||
if (searchPlayerOnSceneIfNotAssigned) {
|
||||
playerToConfigure = GKC_Utils.findMainPlayerOnScene ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9f24ec67cdbece344ba0a0c3f888975a
|
||||
timeCreated: 1576251479
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Dialog System/externalDialogTriggerSystem.cs
|
||||
uploadId: 814740
|
||||
Reference in New Issue
Block a user