Commit b8c9087a authored by Abdulrahman Mohammed's avatar Abdulrahman Mohammed

Fix Dialogue System

parent 5dfbad4f
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using AL_Arcade.DialogueSystem.Scripts;
using ALArcade.ArabicTMP;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using static UnityEngine.Windows.WebCam.VideoCapture;
namespace AL_Arcade.DialogueSystem.Scripts
{
......@@ -12,7 +13,7 @@ namespace AL_Arcade.DialogueSystem.Scripts
{
[Header("UI References")] [SerializeField]
private Transform dialogueContainer;
[SerializeField] InGameAIChatPanel InGameAIChatPanel;
[SerializeField] private GameObject dialoguePrefabEN;
[SerializeField] private GameObject dialoguePrefabAR;
[SerializeField] private GameObject replyPrefab;
......@@ -20,7 +21,6 @@ namespace AL_Arcade.DialogueSystem.Scripts
[SerializeField] private Transform replyContainer;
[SerializeField] private CanvasGroup dialogueCanvasGroup;
[SerializeField] private RectTransform FreeUseDialogue;
[Header("Settings")] [SerializeField] private Language currentLanguage = Language.English;
[SerializeField] private float textSpeed = 0.03f;
[SerializeField] private float fadeInDuration = 0.3f;
......@@ -31,6 +31,7 @@ namespace AL_Arcade.DialogueSystem.Scripts
// Current dialogue state
private DialogueMessageBase currentMessage;
private DialogueTrigger currentMessageForEvent;
public GameObject currentDialogueUI;
private List<GameObject> activeReplyButtons = new List<GameObject>();
private bool isTyping = false;
......@@ -76,10 +77,6 @@ namespace AL_Arcade.DialogueSystem.Scripts
dialogueCanvasGroup.alpha = 0;
}
void Start()
{
}
#region Audio Skip Functionality
/// <summary>
/// Stops any currently playing dialogue audio
......@@ -90,6 +87,9 @@ namespace AL_Arcade.DialogueSystem.Scripts
{
voiceAudioSource.Stop();
Debug.Log("[DialogueManager] Stopped current dialogue audio");
if(currentDialogueUI != null) LayoutRebuilder.ForceRebuildLayoutImmediate(currentDialogueUI.GetComponent<RectTransform>());
}
}
......@@ -118,9 +118,26 @@ namespace AL_Arcade.DialogueSystem.Scripts
}
#endregion
bool isAudioPlay;
void Update()
{
if (IsDialogueAudioPlaying() )
{
if (!isAudioPlay)
{
currentMessageForEvent.StartEventWhenAudioPlay?.Invoke();
isAudioPlay = true;
}
}
else
{
if (isAudioPlay)
{
currentMessageForEvent.StartEventWhenAudioStop?.Invoke();
isAudioPlay = false;
}
}
// Handle advance input
if (canAdvance && !isTyping && Input.GetKeyDown(advanceKey))
{
......@@ -158,7 +175,28 @@ namespace AL_Arcade.DialogueSystem.Scripts
}
}
}
public void ClosePanel()
{
// If audio is playing, stop it first
if (IsDialogueAudioPlaying())
{
StopCurrentDialogueAudio();
return; // Don't advance yet, just stop the audio
}
// If typing, complete the typing
if (isTyping)
{
CompleteTyping();
return;
}
// Otherwise advance dialogue if possible
if (canAdvance && currentMessage != null && (currentMessage.replies == null || currentMessage.replies.Count == 0))
{
AdvanceDialogue();
}
}
public void StartDialogue(DialogueSequence sequence)
{
......@@ -178,19 +216,19 @@ namespace AL_Arcade.DialogueSystem.Scripts
FreeUseDialogue.gameObject.SetActive(false);
}
public void StartDialogue(DialogueMessageBase firstMessage)
public void StartDialogue(DialogueMessageBase firstMessage, DialogueTrigger dialogueTrigger)
{
if (firstMessage == null)
{
Debug.LogError("Invalid dialogue message!");
return;
}
currentMessageForEvent = dialogueTrigger;
ShowDialogueUI(true);
DisplayMessage(firstMessage);
FreeUseDialogue.gameObject.SetActive(false);
}
GameObject prefabToUse;
private void DisplayMessage(DialogueMessageBase message)
{
if (message == null)
......@@ -225,7 +263,6 @@ namespace AL_Arcade.DialogueSystem.Scripts
// Create appropriate prefab
GameObject prefabToUse = currentLanguage == Language.English ? dialoguePrefabEN : dialoguePrefabAR;
currentDialogueUI = Instantiate(prefabToUse, dialogueContainer);
// Setup the dialogue UI
DialogueUI dialogueUI = currentDialogueUI.GetComponent<DialogueUI>();
if (dialogueUI != null)
......@@ -392,8 +429,12 @@ namespace AL_Arcade.DialogueSystem.Scripts
}
}
private IEnumerator FadeCanvas(bool fadeIn)
public void FadeCanvasGroup()
{
EndDialogue();
StopCurrentDialogueAudio();
}
IEnumerator FadeCanvas(bool fadeIn)
{
float targetAlpha = fadeIn ? 1 : 0;
float startAlpha = dialogueCanvasGroup.alpha;
......
......@@ -5,6 +5,7 @@ using System.Collections;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Profiling;
using UnityEngine.UI;
namespace AL_Arcade.DialogueSystem.Scripts
......@@ -246,7 +247,6 @@ namespace AL_Arcade.DialogueSystem.Scripts
Debug.Log("[InGameAIChatPanel] CharArea slide out complete");
});
}
private void SlideInAITextPanel()
{
if (isAITextPanelVisible) return;
......@@ -264,7 +264,12 @@ namespace AL_Arcade.DialogueSystem.Scripts
Debug.Log("[InGameAIChatPanel] AITextPanel slide in complete");
});
}
public void SlideOutPanel()
{
aiTextPanelTweener = aiTextPanel.DOAnchorPos(new Vector2(offScreenXPosition, aiTextPanel.anchoredPosition.y), slideDuration)
.SetEase(slideEaseType);
DialogueManager.Instance.StopCurrentDialogueAudio();
}
private void SlideOutAITextPanel()
{
if (!isAITextPanelVisible) return;
......@@ -312,9 +317,13 @@ namespace AL_Arcade.DialogueSystem.Scripts
StopRecordingAndSend();
}
}
private void StartRecording()
{
if (recordButtonImage.GetComponent<Animator>().isActiveAndEnabled)
{
recordButtonImage.GetComponent<Animator>().enabled = false ;
Record();
}
Debug.Log("[InGameAIChatPanel] Starting recording...");
// Stop any currently playing dialogue audio
......@@ -336,16 +345,20 @@ namespace AL_Arcade.DialogueSystem.Scripts
isRecording = true;
// Update button visual
Record();
Debug.Log("[InGameAIChatPanel] Recording started");
}
public void Record()
{
if (recordButtonImage != null && recordingSprite != null)
{
recordButtonImage.GetComponent<Animator>().enabled = false;
recordButtonImage.transform.DOScale(Scale, Duration).SetLoops(-1, LoopType.Yoyo).SetEase(ease);
recordButtonImage.transform.parent.GetComponent<Image>().color = color;
recordButtonImage.sprite = recordingSprite;
}
Debug.Log("[InGameAIChatPanel] Recording started");
}
private void StopRecordingAndSend()
{
if (recordedClip == null)
......@@ -561,7 +574,9 @@ namespace AL_Arcade.DialogueSystem.Scripts
// Update AI text
if (aiText != null)
{
aiTextPanel.gameObject.SetActive(true);
aiText.arabicText = responseText;
LayoutRebuilder.ForceRebuildLayoutImmediate(aiText.GetComponent<RectTransform>());
}
// Report to GameContextBuilder
......
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
// Base class for dialogue messages
public abstract class DialogueMessageBase : ScriptableObject
{
public abstract class DialogueMessageBase : ScriptableObject
{
[Header("Character Information")] public Sprite characterSprite;
public string characterName;
[Header("Message Content")] [TextArea(3, 5)]
[Header("Message Content")]
[TextArea(3, 5)]
public string messageText;
public AudioClip voiceClip;
[Header("Dialogue Flow")] public List<DialogueReply> replies = new List<DialogueReply>();
public DialogueMessageBase nextMessage; // Used when there are no replies
}
}
......
fileFormatVersion: 2
guid: 042826771a175c8408f552cf50122d50
guid: e5402d6783fbfe64cae90a0c60135a42
TextureImporter:
internalIDToNameTable:
- first:
213: 3448575855859882003
second: Anan02_0
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
......@@ -23,12 +20,9 @@ TextureImporter:
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
......@@ -37,16 +31,16 @@ TextureImporter:
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
filterMode: -1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 2
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
......@@ -60,17 +54,12 @@ TextureImporter:
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 4
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
......@@ -80,103 +69,24 @@ TextureImporter:
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: WindowsStoreApps
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites:
- serializedVersion: 2
name: Anan02_0
rect:
serializedVersion: 2
x: 349
y: 44
width: 1018
height: 1852
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
customData:
outline: []
physicsShape: []
tessellationDetail: -1
bones: []
spriteID: 3185485387dcbdf20800000000000000
internalID: 3448575855859882003
vertices: []
indices:
edges: []
weights: []
sprites: []
outline: []
customData:
physicsShape: []
bones: []
spriteID:
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable:
Anan02_0: 3448575855859882003
mipmapLimitGroupName:
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 012efde35b7a4f248b1c73f321a378a6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: e034dea1540af6142bc2a6421b1fff73
guid: 2543d780cc1105143977b050117e46be
PrefabImporter:
externalObjects: {}
userData:
......
......@@ -10,7 +10,7 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9fa73e80dba941a3901cb680b6419c69, type: 3}
m_Name: DialogueMessage_AR
m_Name: Intro
m_EditorClassIdentifier: Assembly-CSharp::DialogueMessageArabic
characterSprite: {fileID: 3448575855859882003, guid: 042826771a175c8408f552cf50122d50, type: 3}
characterName:
......@@ -33,3 +33,33 @@ MonoBehaviour:
voiceClip: {fileID: 8300000, guid: e59ce108f286c9945a63133a67a8fd9e, type: 3}
replies: []
nextMessage: {fileID: 0}
StartEventWhenAudioPlay:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 0}
m_TargetAssemblyTypeName:
m_MethodName:
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName:
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
StartEventWhenAudioStop:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 0}
m_TargetAssemblyTypeName:
m_MethodName:
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName:
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9fa73e80dba941a3901cb680b6419c69, type: 3}
m_Name: Safety Systems
m_EditorClassIdentifier: Assembly-CSharp::DialogueMessageArabic
characterSprite: {fileID: 3448575855859882003, guid: 042826771a175c8408f552cf50122d50, type: 3}
characterName:
messageText: "\u0623\u0646\u0638\u0645\u0629 \u0627\u0644\u0623\u0645\u0627\u0646
\u0641\u064A \u0627\u0644\u0633\u064A\u0627\u0631\u0629 \r\n\u0644\u0645\u0627
\u0627\u0644\u0639\u0631\u0628\u064A\u0629 \u0628\u062A\u062E\u0628\u0637 \u0641\u064A
\u062D\u0627\u062C\u0629\u060C \u0628\u064A\u062D\u0635\u0644 \u062A\u0648\u0642\u0641
\u0645\u0641\u0627\u062C\u0626\u060C \u0648\u062F\u0647 \u0628\u064A\u0639\u0645\u0644
\u0642\u0648\u0629 \u0635\u062F\u0645\u0629 \u0643\u0628\u064A\u0631\u0629 \u0639\u0644\u0649
\u062C\u0633\u0645 \u0627\u0644\u0633\u0627\u0626\u0642. \u0639\u0644\u0634\u0627\u0646
\u0643\u062F\u0647 \u0644\u0627\u0632\u0645 \u064A\u0628\u0642\u0649 \u0641\u064A\u0647
\u0623\u0646\u0638\u0645\u0629 \u0623\u0645\u0627\u0646 \u0628\u062A\u062D\u0645\u064A
\u0627\u0644\u0633\u0627\u0626\u0642 \u0648\u0642\u062A \u0627\u0644\u062A\u0635\u0627\u062F\u0645.\r\n\r\n\u0623\u0648\u0644
\u062D\u0627\u062C\u0629: \u062D\u0632\u0627\u0645 \u0627\u0644\u0623\u0645\u0627\u0646
\r\n\r\n\u062D\u0632\u0627\u0645 \u0627\u0644\u0623\u0645\u0627\u0646 \u0647\u0648
\u0623\u0647\u0645 \u0648\u0623\u0648\u0644 \u0648\u0633\u064A\u0644\u0629 \u062D\u0645\u0627\u064A\u0629
\u0641\u064A \u0627\u0644\u0639\u0631\u0628\u064A\u0629.\r\n\u0648\u0638\u064A\u0641\u062A\u0647
\u0625\u0646\u0647:\r\n\r\n\u064A\u0645\u0633\u0643 \u062C\u0633\u0645 \u0627\u0644\u0633\u0627\u0626\u0642
\u0641\u064A \u0645\u0643\u0627\u0646\u0647.\r\n\r\n\u064A\u0645\u0646\u0639
\u0625\u0646 \u062C\u0633\u0645\u0647 \u064A\u0637\u064A\u0631 \u0644\u0642\u062F\u0627\u0645
\u0628\u0633\u0628\u0628 \u0642\u0648\u0629 \u0627\u0644\u062A\u0635\u0627\u062F\u0645.\r\n\r\n\u064A\u062E\u0644\u064A
\u062A\u0648\u0642\u0641 \u0627\u0644\u062C\u0633\u0645 \u064A\u062A\u0645 \u0628\u0634\u0643\u0644
\u062A\u062F\u0631\u064A\u062C\u064A \u0628\u062F\u0644 \u0645\u0627 \u064A\u0643\u0648\u0646
\u062A\u0648\u0642\u0641 \u0641\u062C\u0627\u0626\u064A \u0648\u0645\u0624\u0630\u064A.\r\n\r\n\u064A\u0639\u0646\u064A
\u0641\u064A \u062D\u0627\u0644\u0629 \u0627\u0644\u062A\u0635\u0627\u062F\u0645\u060C
\u0627\u0644\u062D\u0632\u0627\u0645 \u0628\u064A\u0645\u0646\u0639 \u0625\u0646
\u0627\u0644\u0633\u0627\u0626\u0642 \u064A\u062E\u0628\u0637 \u0641\u064A \u0627\u0644\u0637\u0627\u0631\u0629
\u0623\u0648 \u0627\u0644\u0632\u062C\u0627\u062C.\r\n\r\n\u062A\u0627\u0646\u064A
\u062D\u0627\u062C\u0629: \u0627\u0644\u0648\u0633\u0627\u062F\u0629 \u0627\u0644\u0647\u0648\u0627\u0626\u064A\u0629
\r\n\r\n\u0627\u0644\u0648\u0633\u0627\u062F\u0629 \u0627\u0644\u0647\u0648\u0627\u0626\u064A\u0629
\u0628\u062A\u0641\u062A\u062D \u0641\u064A \u0623\u062C\u0632\u0627\u0621 \u0635\u063A\u064A\u0631\u0629
\u062C\u062F\u064B\u0627 \u0645\u0646 \u0627\u0644\u062B\u0627\u0646\u064A\u0629
\u0645\u0639 \u0627\u0644\u062A\u0635\u0627\u062F\u0645.\r\n\u062F\u0648\u0631\u0647\u0627
\u0625\u0646\u0647\u0627:\r\n\r\n\u062A\u0633\u062A\u0642\u0628\u0644 \u062C\u0633\u0645
\u0627\u0644\u0633\u0627\u0626\u0642 \u0628\u062F\u0644 \u0645\u0627 \u064A\u062E\u0628\u0637
\u0641\u064A \u0627\u0644\u0637\u0627\u0631\u0629 \u0623\u0648 \u0627\u0644\u062A\u0627\u0628\u0644\u0648\u0647.\r\n\r\n\u062A\u0648\u0632\u0639
\u0642\u0648\u0629 \u0627\u0644\u0635\u062F\u0645\u0629 \u0639\u0644\u0649 \u0645\u0633\u0627\u062D\u0629
\u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u062C\u0633\u0645.\r\n\r\n\u062A\u0642\u0644\u0644
\u062C\u062F\u064B\u0627 \u0625\u0635\u0627\u0628\u0627\u062A \u0627\u0644\u0648\u062C\u0647
\u0648\u0627\u0644\u0635\u062F\u0631.\r\n\r\n\u0644\u064A\u0647 \u0627\u0644\u0643\u0644\u0627\u0645
\u062F\u0647 \u0645\u0647\u0645\u061F\r\n\r\n\u0645\u0646 \u063A\u064A\u0631
\u0627\u0644\u062D\u0632\u0627\u0645 \u0648\u0627\u0644\u0648\u0633\u0627\u062F\u0629
\u0627\u0644\u0647\u0648\u0627\u0626\u064A\u0629 \r\n\r\n\u0627\u0644\u062C\u0633\u0645
\u0628\u064A\u0637\u064A\u0631 \u0644\u0642\u062F\u0627\u0645 \u0641\u062C\u0623\u0629.\r\n\r\n\u0627\u0644\u0625\u0635\u0627\u0628\u0627\u062A
\u0628\u062A\u0643\u0648\u0646 \u062E\u0637\u064A\u0631\u0629 \u062C\u062F\u064B\u0627
\u062E\u0635\u0648\u0635\u064B\u0627 \u0644\u0644\u0631\u0623\u0633 \u0648\u0627\u0644\u0635\u062F\u0631.\r\n\r\n\u0648\u0645\u0639
\u0648\u062C\u0648\u062F\u0647\u0645:\r\n\r\n\u0642\u0648\u0629 \u0627\u0644\u0635\u062F\u0645\u0629
\u0628\u062A\u062A\u0648\u0632\u0639.\r\n\r\n\u0627\u0644\u062C\u0633\u0645 \u0628\u064A\u062A\u0648\u0642\u0641
\u0628\u0634\u0643\u0644 \u062A\u062F\u0631\u064A\u062C\u064A.\r\n\r\n\u0646\u0633\u0628\u0629
\u0627\u0644\u0625\u0635\u0627\u0628\u0629 \u0628\u062A\u0642\u0644 \u0628\u0634\u0643\u0644
\u0643\u0628\u064A\u0631 \u062C\u062F\u064B\u0627."
voiceClip: {fileID: 8300000, guid: 79123de0246689642b2f3835bde269dc, type: 3}
replies: []
nextMessage: {fileID: 0}
fileFormatVersion: 2
guid: bc77febe9a3acd8469048286b799e278
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 79123de0246689642b2f3835bde269dc
AudioImporter:
externalObjects: {}
serializedVersion: 7
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using UnityEngine.Events;
namespace AL_Arcade.DialogueSystem.Scripts
{
public class DialogueTrigger : MonoBehaviour
{
{
[Header("Dialogue")]
public DialogueSequence dialogueSequence;
public DialogueMessageBase singleMessage;
......@@ -20,6 +21,10 @@ namespace AL_Arcade.DialogueSystem.Scripts
private bool playerInRange = false;
private bool hasTriggered = false;
[Header("Unity Event")]
public UnityEvent StartEventWhenAudioPlay;
public UnityEvent StartEventWhenAudioStop;
void Start()
{
if (interactionPrompt != null)
......@@ -71,7 +76,7 @@ namespace AL_Arcade.DialogueSystem.Scripts
if (dialogueSequence != null)
DialogueManager.Instance.StartDialogue(dialogueSequence);
else if (singleMessage != null)
DialogueManager.Instance.StartDialogue(singleMessage);
DialogueManager.Instance.StartDialogue(singleMessage,this);
}
hasTriggered = true;
......@@ -79,5 +84,5 @@ namespace AL_Arcade.DialogueSystem.Scripts
if (interactionPrompt != null)
interactionPrompt.SetActive(false);
}
}
}
}
\ No newline at end of file
......@@ -8,6 +8,8 @@ namespace DavidJalbert
public class TinyCarAudio : MonoBehaviour
{
public TinyCarController carController;
[SerializeField] float AudioSourceVolume = 1f;
[Header("Engine audio")]
[Tooltip("Looping engine sound clip.")]
public AudioClip engineSoundClip;
......@@ -62,7 +64,7 @@ namespace DavidJalbert
sourceEngine.playOnAwake = false;
sourceEngine.loop = true;
sourceEngine.clip = engineSoundClip;
sourceEngine.volume = 1;
sourceEngine.volume = AudioSourceVolume;
sourceEngine.Play();
......@@ -122,10 +124,14 @@ namespace DavidJalbert
float bumpForceValue = Mathf.Lerp(bumpMinForce, bumpMaxForce, carController.getSideHitForce());
float bumpVolume = bumpMassValue * bumpForceValue;
if (bumpVolume > 0)
{
if(sourceBump.isActiveAndEnabled)
{
sourceBump.volume = bumpVolume;
sourceBump.Play();
}
}
}
float grindVolume = 0;
......
This diff is collapsed.
using DavidJalbert;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CarExplode : MonoBehaviour
{
[SerializeField] TinyCarExplosiveBody tinyCarExplosiveBody;
[SerializeField] GameObject ExplodeMessege;
private void OnEnable()
{
tinyCarExplosiveBody.explode();
ExplodeMessege.SetActive(true);
Invoke(nameof(restore), 7);
}
void restore()
{
tinyCarExplosiveBody.restore();
}
}
fileFormatVersion: 2
guid: fe401ffbded6ff34fbd01b2c0c825bad
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -5,7 +5,6 @@ using UnityEngine.UI;
public class PotentialKineticEnergyScript : MonoBehaviour
{
[SerializeField] TinyCarController Car;
[SerializeField] Transform SphereCast;
[SerializeField] LayerMask GroundLayer;
......@@ -20,10 +19,26 @@ public class PotentialKineticEnergyScript : MonoBehaviour
float _triggerHeight;
float _peakPotential;
bool _inTrigger;
bool isExplode;
private void Start()
{
isExplode = false;
}
private void OnCollisionEnter(Collision collision)
{
if (Car.getBody().velocity.magnitude > 1) ThermalSlider.value += 5;
if (collision.collider.attachedRigidbody && Input.GetAxis("Vertical") != 0)
{
ThermalSlider.value += 5;
if (!isExplode)
{
GetComponentInParent<CarExplode>().enabled = true;
isExplode = true;
}
}
}
private void OnTriggerEnter(Collider other)
{
......
using UnityEngine;
using System.Collections;
public class layerCullDistances : MonoBehaviour
{
void Start()
{
Camera camera = GetComponent<Camera>();
float[] distances = new float[32];
distances[10] = 15;
camera.layerCullDistances = distances;
}
}
fileFormatVersion: 2
guid: 2378c39f3154f49498d4ec64433c15ed
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment