Update
This commit is contained in:
@@ -64,7 +64,7 @@ Material:
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Texture: {fileID: 2800000, guid: abc8c66608194874b8178aef8308f1b0, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
|
||||
@@ -1,5 +1,320 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &1015130845570826762
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 369056581300809980}
|
||||
- component: {fileID: 7178408408297164993}
|
||||
- component: {fileID: 7017130799328637960}
|
||||
- component: {fileID: 704565314883451722}
|
||||
m_Layer: 0
|
||||
m_Name: Canvas
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &369056581300809980
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1015130845570826762}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 5600986009105034028}
|
||||
- {fileID: 9065310572032428542}
|
||||
m_Father: {fileID: 6442306242859885696}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 1.5}
|
||||
m_SizeDelta: {x: 3, y: 1}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!223 &7178408408297164993
|
||||
Canvas:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1015130845570826762}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_RenderMode: 2
|
||||
m_Camera: {fileID: 0}
|
||||
m_PlaneDistance: 100
|
||||
m_PixelPerfect: 0
|
||||
m_ReceivesEvents: 1
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_VertexColorAlwaysGammaSpace: 0
|
||||
m_AdditionalShaderChannelsFlag: 25
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 0
|
||||
m_TargetDisplay: 0
|
||||
--- !u!114 &7017130799328637960
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1015130845570826762}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.CanvasScaler
|
||||
m_UiScaleMode: 0
|
||||
m_ReferencePixelsPerUnit: 100
|
||||
m_ScaleFactor: 1
|
||||
m_ReferenceResolution: {x: 800, y: 600}
|
||||
m_ScreenMatchMode: 0
|
||||
m_MatchWidthOrHeight: 0
|
||||
m_PhysicalUnit: 3
|
||||
m_FallbackScreenDPI: 96
|
||||
m_DefaultSpriteDPI: 96
|
||||
m_DynamicPixelsPerUnit: 1
|
||||
m_PresetInfoIsWorld: 1
|
||||
--- !u!114 &704565314883451722
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1015130845570826762}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.GraphicRaycaster
|
||||
m_IgnoreReversedGraphics: 1
|
||||
m_BlockingObjects: 0
|
||||
m_BlockingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
--- !u!1 &3389310839763427503
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 9065310572032428542}
|
||||
- component: {fileID: 970613594855946612}
|
||||
- component: {fileID: 707878100722238044}
|
||||
m_Layer: 0
|
||||
m_Name: Text (TMP)
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &9065310572032428542
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3389310839763427503}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 369056581300809980}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 3, y: 1}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &970613594855946612
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3389310839763427503}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &707878100722238044
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3389310839763427503}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Unity.TextMeshPro::TMPro.TextMeshProUGUI
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_text: 2
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
m_fontColor32:
|
||||
serializedVersion: 2
|
||||
rgba: 4278190080
|
||||
m_fontColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_enableVertexGradient: 0
|
||||
m_colorMode: 3
|
||||
m_fontColorGradient:
|
||||
topLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||
topRight: {r: 1, g: 1, b: 1, a: 1}
|
||||
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||
bottomRight: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_fontColorGradientPreset: {fileID: 0}
|
||||
m_spriteAsset: {fileID: 0}
|
||||
m_tintAllSprites: 0
|
||||
m_StyleSheet: {fileID: 0}
|
||||
m_TextStyleHashCode: -1183493901
|
||||
m_overrideHtmlColors: 0
|
||||
m_faceColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_fontSize: 0.3
|
||||
m_fontSizeBase: 0.3
|
||||
m_fontWeight: 400
|
||||
m_enableAutoSizing: 0
|
||||
m_fontSizeMin: 18
|
||||
m_fontSizeMax: 72
|
||||
m_fontStyle: 0
|
||||
m_HorizontalAlignment: 1
|
||||
m_VerticalAlignment: 256
|
||||
m_textAlignment: 65535
|
||||
m_characterSpacing: 0
|
||||
m_characterHorizontalScale: 1
|
||||
m_wordSpacing: 0
|
||||
m_lineSpacing: 0
|
||||
m_lineSpacingMax: 0
|
||||
m_paragraphSpacing: 0
|
||||
m_charWidthMaxAdj: 0
|
||||
m_TextWrappingMode: 1
|
||||
m_wordWrappingRatios: 0.4
|
||||
m_overflowMode: 0
|
||||
m_linkedTextComponent: {fileID: 0}
|
||||
parentLinkedComponent: {fileID: 0}
|
||||
m_enableKerning: 0
|
||||
m_ActiveFontFeatures: 6e72656b
|
||||
m_enableExtraPadding: 0
|
||||
checkPaddingRequired: 0
|
||||
m_isRichText: 1
|
||||
m_EmojiFallbackSupport: 1
|
||||
m_parseCtrlCharacters: 1
|
||||
m_isOrthographic: 1
|
||||
m_isCullingEnabled: 0
|
||||
m_horizontalMapping: 0
|
||||
m_verticalMapping: 0
|
||||
m_uvLineOffset: 0
|
||||
m_geometrySortingOrder: 0
|
||||
m_IsTextObjectScaleStatic: 0
|
||||
m_VertexBufferAutoSizeReduction: 0
|
||||
m_useMaxVisibleDescender: 1
|
||||
m_pageToDisplay: 1
|
||||
m_margin: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_isUsingLegacyAnimationComponent: 0
|
||||
m_isVolumetricText: 0
|
||||
m_hasFontAssetChanged: 0
|
||||
m_baseMaterial: {fileID: 0}
|
||||
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
||||
--- !u!1 &5484531426847444413
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 5600986009105034028}
|
||||
- component: {fileID: 3735294672569112020}
|
||||
- component: {fileID: 4710298513750601350}
|
||||
m_Layer: 0
|
||||
m_Name: Image
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &5600986009105034028
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5484531426847444413}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 369056581300809980}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 3, y: 1}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &3735294672569112020
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5484531426847444413}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &4710298513750601350
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5484531426847444413}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Image
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 0.7647059}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 21300000, guid: 65afb4cbeb47dc14ea879b97a296e19f, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!1 &5687887011233860168
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -28,9 +343,9 @@ Transform:
|
||||
m_GameObject: {fileID: 5687887011233860168}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -0.041, y: 0.408, z: 0.474}
|
||||
m_LocalScale: {x: 0.05, y: 0.05, z: 0.05}
|
||||
m_ConstrainProportionsScale: 1
|
||||
m_LocalPosition: {x: 0.041, y: 0.408, z: -0.45}
|
||||
m_LocalScale: {x: -0.42, y: 0.17, z: -0.4}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 6442306242859885696}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
@@ -127,6 +442,7 @@ GameObject:
|
||||
- component: {fileID: 8272839718325411334}
|
||||
- component: {fileID: 5770331367975928816}
|
||||
- component: {fileID: 4112854993683970537}
|
||||
- component: {fileID: 1849114922688404578}
|
||||
m_Layer: 0
|
||||
m_Name: xNPC
|
||||
m_TagString: Untagged
|
||||
@@ -148,6 +464,7 @@ Transform:
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 5863061020199015852}
|
||||
- {fileID: 369056581300809980}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!33 &7778427549192063289
|
||||
@@ -253,6 +570,12 @@ MonoBehaviour:
|
||||
firePoint: {fileID: 5863061020199015852}
|
||||
minShootDelay: 1
|
||||
maxShootDelay: 3
|
||||
alertSound: Enemy_Alert
|
||||
shootSound: Enemy_Shoot
|
||||
npcName: Guard
|
||||
persona: You are a grumpy guard protecting gold.
|
||||
talkRange: 4
|
||||
talkCooldown: 30
|
||||
--- !u!195 &5770331367975928816
|
||||
NavMeshAgent:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -302,3 +625,18 @@ Rigidbody:
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 112
|
||||
m_CollisionDetection: 0
|
||||
--- !u!114 &1849114922688404578
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7522161431095319480}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: ea510cea4b9ed1547ae4725a2ded949a, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::Hallucinate.UI.ChatBubble
|
||||
textDisplay: {fileID: 707878100722238044}
|
||||
canvasGroup: {fileID: 0}
|
||||
bubbleRect: {fileID: 5600986009105034028}
|
||||
|
||||
@@ -146074,6 +146074,52 @@ Mesh:
|
||||
- serializedVersion: 1
|
||||
m_IndexStart: 0
|
||||
m_IndexCount: 0
|
||||
--- !u!1 &1779903590
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1779903592}
|
||||
- component: {fileID: 1779903591}
|
||||
m_Layer: 0
|
||||
m_Name: Manager
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &1779903591
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1779903590}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: a859fc8e9ec10a347a3704b6045ca7e8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::Hallucinate.AI.GeminiService
|
||||
apiKey: AIzaSyC4DRm2dffDuDogYkY0Ag86p-EYLu67bDo
|
||||
geminiURL: https://generativelanguage.googleapis.com/v1beta/models/gemini-flash-latest:generateContent
|
||||
--- !u!4 &1779903592
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1779903590}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 14.19123, y: 0, z: 31.93528}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1781734490
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -150430,3 +150476,4 @@ SceneRoots:
|
||||
- {fileID: 1645920186}
|
||||
- {fileID: 640822033}
|
||||
- {fileID: 1158761166}
|
||||
- {fileID: 1779903592}
|
||||
|
||||
42
Assets/Scripts/AI NPC/ChatBubble.cs
Normal file
42
Assets/Scripts/AI NPC/ChatBubble.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using PrimeTween;
|
||||
|
||||
namespace Hallucinate.UI
|
||||
{
|
||||
public class ChatBubble : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TextMeshProUGUI textDisplay;
|
||||
[SerializeField] private CanvasGroup canvasGroup;
|
||||
[SerializeField] private RectTransform bubbleRect;
|
||||
|
||||
private Transform mainCameraTransform;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
mainCameraTransform = Camera.main.transform;
|
||||
canvasGroup.alpha = 0;
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
// Billboard effect
|
||||
transform.LookAt(transform.position + mainCameraTransform.rotation * Vector3.forward, mainCameraTransform.rotation * Vector3.up);
|
||||
}
|
||||
|
||||
public void Show(string text, float duration = 4f)
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
textDisplay.text = text;
|
||||
|
||||
// Animation using PrimeTween
|
||||
PrimeTween.Sequence.Create()
|
||||
.Group(Tween.Alpha(canvasGroup, 1f, 0.3f))
|
||||
.Group(Tween.Scale(bubbleRect, Vector3.zero, Vector3.one, 0.4f, Ease.OutBack))
|
||||
.Chain(Tween.Delay(duration))
|
||||
.Chain(Tween.Alpha(canvasGroup, 0f, 0.5f))
|
||||
.OnComplete(() => gameObject.SetActive(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/AI NPC/ChatBubble.cs.meta
Normal file
2
Assets/Scripts/AI NPC/ChatBubble.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea510cea4b9ed1547ae4725a2ded949a
|
||||
@@ -34,6 +34,16 @@ public class EnemyAI : MonoBehaviour
|
||||
public string shootSound = "Enemy_Shoot";
|
||||
private bool hasSpottedPlayer; // Để chỉ kêu alert 1 lần
|
||||
|
||||
[Header("Conversation")]
|
||||
public string npcName = "Guard";
|
||||
public string persona = "You are a grumpy guard protecting gold.";
|
||||
public float talkRange = 4f;
|
||||
public float talkCooldown = 30f;
|
||||
private float lastTalkTime;
|
||||
private bool isTalking;
|
||||
private EnemyAI talkingPartner;
|
||||
private Hallucinate.UI.ChatBubble chatBubble;
|
||||
|
||||
private float nextShootTime;
|
||||
private NavMeshAgent agent;
|
||||
|
||||
@@ -42,6 +52,7 @@ public class EnemyAI : MonoBehaviour
|
||||
private void Start()
|
||||
{
|
||||
agent = GetComponent<NavMeshAgent>();
|
||||
chatBubble = GetComponentInChildren<Hallucinate.UI.ChatBubble>(true);
|
||||
agent.speed = moveSpeed;
|
||||
|
||||
// Lưu lại vị trí ban đầu để làm tâm của khu vực tuần tra
|
||||
@@ -75,35 +86,69 @@ public class EnemyAI : MonoBehaviour
|
||||
|
||||
private void InitBehaviorTree()
|
||||
{
|
||||
// Player có artifact -> focus + shoot
|
||||
// Ưu tiên 1: Player có artifact -> focus + shoot (Cao nhất)
|
||||
var laserSequence = new Sequence(new List<Node>
|
||||
{
|
||||
new TaskNode(CheckHasArtifact),
|
||||
new TaskNode(ActionFocusAndShoot)
|
||||
});
|
||||
|
||||
// Thấy player -> chạy tới
|
||||
// Ưu tiên 2: Thấy player -> rượt đuổi
|
||||
var chaseSequence = new Sequence(new List<Node>
|
||||
{
|
||||
new TaskNode(CheckCanSeePlayer),
|
||||
new TaskNode(ActionMoveToPlayer)
|
||||
});
|
||||
|
||||
// Không thấy ai -> Tuần tra bằng NavMesh
|
||||
// Ưu tiên 3: Gần NPC khác -> nói chuyện (Mới)
|
||||
var talkSequence = new Sequence(new List<Node>
|
||||
{
|
||||
new TaskNode(CheckCanTalkToNPC),
|
||||
new TaskNode(ActionTalk)
|
||||
});
|
||||
|
||||
// Ưu tiên cuối: Tuần tra
|
||||
var patrolNode = new TaskNode(ActionPatrol);
|
||||
|
||||
behaviorTreeRoot = new Selector(new List<Node>
|
||||
{
|
||||
laserSequence,
|
||||
chaseSequence,
|
||||
talkSequence,
|
||||
patrolNode
|
||||
});
|
||||
}
|
||||
|
||||
#region CONDITIONS
|
||||
|
||||
private NodeState CheckCanTalkToNPC()
|
||||
{
|
||||
if (playerHasArtifact || hasSpottedPlayer) return NodeState.Failure;
|
||||
if (Time.time < lastTalkTime + talkCooldown) return NodeState.Failure;
|
||||
if (isTalking) return NodeState.Success;
|
||||
|
||||
// Tìm NPC gần nhất
|
||||
Collider[] hitColliders = Physics.OverlapSphere(transform.position, talkRange);
|
||||
foreach (var hit in hitColliders)
|
||||
{
|
||||
if (hit.gameObject != gameObject && hit.CompareTag("Enemy"))
|
||||
{
|
||||
EnemyAI other = hit.GetComponent<EnemyAI>();
|
||||
if (other != null && !other.isTalking && Time.time >= other.lastTalkTime + talkCooldown)
|
||||
{
|
||||
talkingPartner = other;
|
||||
return NodeState.Success;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NodeState.Failure;
|
||||
}
|
||||
|
||||
private NodeState CheckHasArtifact()
|
||||
{
|
||||
// Khi bị phát hiện hoặc player có artifact, ngắt lời ngay
|
||||
if (playerHasArtifact || hasSpottedPlayer) StopConversation();
|
||||
return playerHasArtifact ? NodeState.Success : NodeState.Failure;
|
||||
}
|
||||
|
||||
@@ -119,11 +164,12 @@ public class EnemyAI : MonoBehaviour
|
||||
{
|
||||
hasSpottedPlayer = true;
|
||||
AudioManager.Instance?.Play(alertSound, position: transform.position);
|
||||
StopConversation(); // Ngắt hội thoại khi thấy player
|
||||
}
|
||||
return NodeState.Success;
|
||||
}
|
||||
|
||||
hasSpottedPlayer = false; // Reset nếu player ra khỏi tầm mắt
|
||||
hasSpottedPlayer = false;
|
||||
return NodeState.Failure;
|
||||
}
|
||||
|
||||
@@ -131,6 +177,78 @@ public class EnemyAI : MonoBehaviour
|
||||
|
||||
#region ACTIONS
|
||||
|
||||
private NodeState ActionTalk()
|
||||
{
|
||||
if (talkingPartner == null) return NodeState.Failure;
|
||||
|
||||
if (!isTalking)
|
||||
{
|
||||
isTalking = true;
|
||||
agent.isStopped = true;
|
||||
|
||||
// Xoay về phía bạn
|
||||
FaceTarget(talkingPartner.transform.position);
|
||||
|
||||
// Bắt đầu hội thoại qua Gemini
|
||||
StartNPCConversation();
|
||||
}
|
||||
|
||||
return NodeState.Running;
|
||||
}
|
||||
|
||||
private void StartNPCConversation()
|
||||
{
|
||||
string prompt = $"You are {npcName}. You are talking to your fellow guard {talkingPartner.npcName}. " +
|
||||
"Keep it short (1 sentence). Topic: gold security or complaining about work.";
|
||||
|
||||
Hallucinate.AI.GeminiService.Instance.GetResponse(persona, prompt, (response) => {
|
||||
if (chatBubble != null) chatBubble.Show(response);
|
||||
|
||||
// Hẹn giờ kết thúc hội thoại
|
||||
Invoke(nameof(EndConversation), 5f);
|
||||
});
|
||||
|
||||
// Thông báo cho bạn diễn cũng dừng lại để "nghe"
|
||||
talkingPartner.OnPartnerTalked(this);
|
||||
}
|
||||
|
||||
public void OnPartnerTalked(EnemyAI partner)
|
||||
{
|
||||
isTalking = true;
|
||||
talkingPartner = partner;
|
||||
agent.isStopped = true;
|
||||
FaceTarget(partner.transform.position);
|
||||
|
||||
// Chờ bạn nói xong mới phản hồi (Tùy chọn: có thể thêm logic phản hồi ở đây)
|
||||
Invoke(nameof(EndConversation), 6f);
|
||||
}
|
||||
|
||||
private void EndConversation()
|
||||
{
|
||||
isTalking = false;
|
||||
lastTalkTime = Time.time;
|
||||
if (agent != null) agent.isStopped = false;
|
||||
talkingPartner = null;
|
||||
}
|
||||
|
||||
private void StopConversation()
|
||||
{
|
||||
if (!isTalking) return;
|
||||
CancelInvoke(nameof(EndConversation));
|
||||
EndConversation();
|
||||
if (chatBubble != null) chatBubble.Show("Suỵt! Có gì đó không ổn...", 2f);
|
||||
}
|
||||
|
||||
private void FaceTarget(Vector3 targetPos)
|
||||
{
|
||||
Vector3 dir = targetPos - transform.position;
|
||||
dir.y = 0;
|
||||
if (dir != Vector3.zero)
|
||||
{
|
||||
transform.rotation = Quaternion.LookRotation(dir);
|
||||
}
|
||||
}
|
||||
|
||||
private NodeState ActionPatrol()
|
||||
{
|
||||
// Debug.Log("Patrolling...");
|
||||
|
||||
76
Assets/Scripts/AI NPC/GeminiService.cs
Normal file
76
Assets/Scripts/AI NPC/GeminiService.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
namespace Hallucinate.AI
|
||||
{
|
||||
[Serializable]
|
||||
public class Part { public string text; }
|
||||
|
||||
[Serializable]
|
||||
public class Content { public Part[] parts; }
|
||||
|
||||
[Serializable]
|
||||
public class Candidate { public Content content; }
|
||||
|
||||
[Serializable]
|
||||
public class GeminiResponse { public Candidate[] candidates; }
|
||||
|
||||
public class GeminiService : MonoBehaviour
|
||||
{
|
||||
public static GeminiService Instance { get; private set; }
|
||||
|
||||
[SerializeField] private string apiKey = "AQ.Ab8RN6I2hU_p8yHiPNNHtWzYBiLugbPP22gC6lzTWaYEWj4v0g"; // Replace with your key
|
||||
[SerializeField] private string geminiURL = "https://generativelanguage.googleapis.com/v1beta/models/gemini-flash-latest:generateContent";
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance == null) { Instance = this; DontDestroyOnLoad(gameObject); }
|
||||
else { Destroy(gameObject); }
|
||||
}
|
||||
|
||||
public void GetResponse(string persona, string prompt, Action<string> onComplete)
|
||||
{
|
||||
StartCoroutine(PostRequest(persona, prompt, onComplete));
|
||||
}
|
||||
|
||||
private IEnumerator PostRequest(string persona, string prompt, Action<string> onComplete)
|
||||
{
|
||||
var jsonBody = $@"{{
|
||||
""systemInstruction"": {{""parts"": [{{ ""text"": ""{persona}"" }}]}},
|
||||
""contents"": [{{""parts"": [{{ ""text"": ""{prompt}"" }}]}}]
|
||||
}}";
|
||||
|
||||
var requestURL = $"{geminiURL}?key={apiKey}";
|
||||
|
||||
using (var request = new UnityWebRequest(requestURL, "POST"))
|
||||
{
|
||||
byte[] bodyRaw = Encoding.UTF8.GetBytes(jsonBody);
|
||||
request.uploadHandler = new UploadHandlerRaw(bodyRaw);
|
||||
request.downloadHandler = new DownloadHandlerBuffer();
|
||||
request.SetRequestHeader("Content-Type", "application/json");
|
||||
|
||||
yield return request.SendWebRequest();
|
||||
|
||||
if (request.result == UnityWebRequest.Result.Success)
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = JsonUtility.FromJson<GeminiResponse>(request.downloadHandler.text);
|
||||
if (response?.candidates != null && response.candidates.Length > 0)
|
||||
{
|
||||
onComplete?.Invoke(response.candidates[0].content.parts[0].text);
|
||||
}
|
||||
}
|
||||
catch (Exception e) { Debug.LogError($"[Gemini] JSON Parse Error: {e.Message}"); }
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"[Gemini] API Error: {request.error}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/AI NPC/GeminiService.cs.meta
Normal file
2
Assets/Scripts/AI NPC/GeminiService.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a859fc8e9ec10a347a3704b6045ca7e8
|
||||
@@ -1,44 +1,13 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.Networking;
|
||||
using System.Collections;
|
||||
using Hallucinate.Audio;
|
||||
|
||||
[Serializable]
|
||||
public class Part
|
||||
{
|
||||
public string text;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class Content
|
||||
{
|
||||
public Part[] parts;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class Candidate
|
||||
{
|
||||
public Content content;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class GeminiResponse
|
||||
{
|
||||
public Candidate[] candidates;
|
||||
}
|
||||
using Hallucinate.AI;
|
||||
|
||||
public class GerminiNPC : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private string apiKey = "AQ.Ab8RN6I2hU_p8yHiPNNHtWzYBiLugbPP22gC6lzTWaYEWj4v0g";
|
||||
[SerializeField]
|
||||
private string germiniURL =
|
||||
"https://generativelanguage.googleapis.com/v1beta/models/gemini-flash-latest:generateContent";
|
||||
|
||||
public string npcPersona =
|
||||
private string npcPersona =
|
||||
"Ngươi là một lão thợ rèn cọc cằn tên là Tom, ngươi rất ghét những kẻ mang phế liệu đến tiệm của mình. Chỉ trả lời ngắn gọn trong 2 câu, theo phong cách trung cổ.";
|
||||
|
||||
public string playerHeldItem = "Thanh kiếm rỉ sét";
|
||||
@@ -95,46 +64,17 @@ public class GerminiNPC : MonoBehaviour
|
||||
|
||||
private IEnumerator GetGerminiReponse()
|
||||
{
|
||||
var jsonBody = $@"{{
|
||||
""systemInstruction"": {{""parts"": [{{ ""text"": ""{npcPersona}"" }}]}},
|
||||
""contents"": [{{""parts"": [{{ ""text"": ""Ta muốn bán cho ông món đồ này: {playerHeldItem}""}}]}}]
|
||||
}}";
|
||||
string prompt = $"Ta muốn bán cho ông món đồ này: {playerHeldItem}";
|
||||
|
||||
Hallucinate.AI.GeminiService.Instance.GetResponse(npcPersona, prompt, (response) => {
|
||||
Debug.Log($"<color=green>Tom:</color> {response}");
|
||||
AudioManager.Instance?.Play(responseSound, position: transform.position);
|
||||
|
||||
// Nếu có ChatBubble gắn kèm thì hiển thị luôn
|
||||
var bubble = GetComponentInChildren<Hallucinate.UI.ChatBubble>(true);
|
||||
if (bubble != null) bubble.Show(response);
|
||||
});
|
||||
|
||||
// 1. Sửa tham số thành ?key= (trước đó là ?ket=)
|
||||
var requestURL = $"{germiniURL}?key={apiKey}";
|
||||
|
||||
// 2. Sử dụng requestURL (có chứa key) thay vì germiniURL gốc
|
||||
using (var request = new UnityWebRequest(requestURL, "POST"))
|
||||
{
|
||||
var bodyRaw = Encoding.UTF8.GetBytes(jsonBody);
|
||||
request.uploadHandler = new UploadHandlerRaw(bodyRaw);
|
||||
request.downloadHandler = new DownloadHandlerBuffer();
|
||||
request.SetRequestHeader("Content-Type", "application/json");
|
||||
|
||||
yield return request.SendWebRequest();
|
||||
|
||||
if (request.result == UnityWebRequest.Result.ProtocolError || request.result == UnityWebRequest.Result.ConnectionError)
|
||||
{
|
||||
Debug.LogError($"[Gemini Error] {request.error} - Response: {request.downloadHandler.text}");
|
||||
}
|
||||
else
|
||||
{
|
||||
var responseTEXT = request.downloadHandler.text;
|
||||
try
|
||||
{
|
||||
var geminiResponse = JsonUtility.FromJson<GeminiResponse>(responseTEXT);
|
||||
if (geminiResponse != null && geminiResponse.candidates != null && geminiResponse.candidates.Length > 0)
|
||||
{
|
||||
var npcResponse = geminiResponse.candidates[0].content.parts[0].text;
|
||||
Debug.Log($"<color=green>Tom:</color> {npcResponse}");
|
||||
AudioManager.Instance?.Play(responseSound, position: transform.position);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"[JSON Parse Error] {e.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user