diff --git a/Assets/Audio/SomeBG.wav b/Assets/Audio/SomeBG.wav new file mode 100644 index 0000000..f2d3ae7 Binary files /dev/null and b/Assets/Audio/SomeBG.wav differ diff --git a/Assets/Audio/SomeBG.wav.meta b/Assets/Audio/SomeBG.wav.meta new file mode 100644 index 0000000..af0f2c5 --- /dev/null +++ b/Assets/Audio/SomeBG.wav.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 27d0c23f9589e6044b0831b1fb3c4678 +AudioImporter: + externalObjects: {} + serializedVersion: 8 + 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: diff --git a/Assets/Prefabs/Characters/Enemies/Gobler.prefab b/Assets/Prefabs/Characters/Enemies/Gobler.prefab index a2a16b1..bacef7a 100644 --- a/Assets/Prefabs/Characters/Enemies/Gobler.prefab +++ b/Assets/Prefabs/Characters/Enemies/Gobler.prefab @@ -29,7 +29,7 @@ Transform: serializedVersion: 2 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_LocalScale: {x: 0.75, y: 0.75, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 243343966221896818} @@ -75,8 +75,8 @@ SpriteRenderer: m_AutoUVMaxDistance: 0.5 m_AutoUVMaxAngle: 89 m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 + m_SortingLayerID: 651355007 + m_SortingLayer: 4 m_SortingOrder: 0 m_Sprite: {fileID: -9095717837082945937, guid: 207ee8102dd4143d288186ef0be518ee, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} @@ -123,9 +123,9 @@ CapsuleCollider2D: m_UsedByEffector: 0 m_CompositeOperation: 0 m_CompositeOrder: 0 - m_Offset: {x: 0, y: 0} - m_Size: {x: 1, y: 2} - m_Direction: 0 + m_Offset: {x: 0.0000014055772, y: -0.87583154} + m_Size: {x: 0.7845726, y: 0.36333472} + m_Direction: 1 --- !u!50 &3688493226208381882 Rigidbody2D: serializedVersion: 5 @@ -141,15 +141,15 @@ Rigidbody2D: m_Mass: 1 m_LinearDamping: 0 m_AngularDamping: 0.05 - m_GravityScale: 1 + m_GravityScale: 0 m_Material: {fileID: 0} m_IncludeLayers: serializedVersion: 2 m_Bits: 0 m_ExcludeLayers: serializedVersion: 2 - m_Bits: 0 - m_Interpolate: 0 + m_Bits: 4294967295 + m_Interpolate: 1 m_SleepingMode: 1 m_CollisionDetection: 0 m_Constraints: 0 @@ -162,6 +162,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 243343966221896818} + - component: {fileID: 4923938647755769837} m_Layer: 0 m_Name: Gobler m_TagString: Untagged @@ -185,3 +186,20 @@ Transform: - {fileID: 2045680922754072471} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &4923938647755769837 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6411951171763069002} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a5c89455bac58d943a2e1e110d37a24d, type: 3} + m_Name: + m_EditorClassIdentifier: + WalkState: {fileID: 11400000, guid: 5cd5bb6e94e95cf4c961f0433390f59f, type: 2} + ChaseState: {fileID: 11400000, guid: 71a5afe255167e14cad7bb413bdef532, type: 2} + AttackState: {fileID: 11400000, guid: 0b9cc3e63ee0125479639c05b89977f8, type: 2} + ChaseDistance: 10 + AttackDistance: 1 diff --git a/Assets/Scenes/HomeTown.unity b/Assets/Scenes/HomeTown.unity index 30e40a8..bcac243 100644 --- a/Assets/Scenes/HomeTown.unity +++ b/Assets/Scenes/HomeTown.unity @@ -194,7 +194,7 @@ Transform: m_GameObject: {fileID: 308205144} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -3.4414895, y: -0.9161943, z: -20.03828} + m_LocalPosition: {x: -3.4414895, y: -0.4461943, z: -20.03828} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -306,7 +306,7 @@ Transform: m_GameObject: {fileID: 519420028} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -3.4414895, y: -0.9161943, z: -20.03828} + m_LocalPosition: {x: -3.4414895, y: -0.4461943, z: -20.03828} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -65434,6 +65434,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 1990193559} + - component: {fileID: 1990193560} m_Layer: 0 m_Name: World m_TagString: Untagged @@ -65457,85 +65458,103 @@ Transform: - {fileID: 1113405404} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &2108843205 -GameObject: +--- !u!82 &1990193560 +AudioSource: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 2108843208} - - component: {fileID: 2108843207} - - component: {fileID: 2108843206} - m_Layer: 0 - m_Name: EventSystem - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &2108843206 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2108843205} + m_GameObject: {fileID: 1990193558} m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3} - m_Name: - m_EditorClassIdentifier: - m_SendPointerHoverToParent: 1 - m_MoveRepeatDelay: 0.5 - m_MoveRepeatRate: 0.1 - m_XRTrackingOrigin: {fileID: 0} - m_ActionsAsset: {fileID: -944628639613478452, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_PointAction: {fileID: -1654692200621890270, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_MoveAction: {fileID: -8784545083839296357, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_SubmitAction: {fileID: 392368643174621059, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_CancelAction: {fileID: 7727032971491509709, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_LeftClickAction: {fileID: 3001919216989983466, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_MiddleClickAction: {fileID: -2185481485913320682, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_RightClickAction: {fileID: -4090225696740746782, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_ScrollWheelAction: {fileID: 6240969308177333660, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_TrackedDevicePositionAction: {fileID: 6564999863303420839, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3} - m_DeselectOnBackgroundClick: 1 - m_PointerBehavior: 0 - m_CursorLockBehavior: 0 - m_ScrollDeltaPerTick: 6 ---- !u!114 &2108843207 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2108843205} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3} - m_Name: - m_EditorClassIdentifier: - m_FirstSelected: {fileID: 0} - m_sendNavigationEvents: 1 - m_DragThreshold: 10 ---- !u!4 &2108843208 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2108843205} - serializedVersion: 2 - 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: 0} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + serializedVersion: 4 + OutputAudioMixerGroup: {fileID: 0} + m_audioClip: {fileID: 8300000, guid: 27d0c23f9589e6044b0831b1fb3c4678, type: 3} + m_Resource: {fileID: 8300000, guid: 27d0c23f9589e6044b0831b1fb3c4678, type: 3} + m_PlayOnAwake: 1 + m_Volume: 1 + m_Pitch: 1 + Loop: 1 + Mute: 0 + Spatialize: 0 + SpatializePostEffects: 0 + Priority: 24 + DopplerLevel: 1 + MinDistance: 1 + MaxDistance: 500 + Pan2D: 0 + rolloffMode: 0 + BypassEffects: 0 + BypassListenerEffects: 0 + BypassReverbZones: 0 + rolloffCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + panLevelCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + spreadCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + reverbZoneMixCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 --- !u!1001 &210807110740579273 PrefabInstance: m_ObjectHideFlags: 0 @@ -65546,11 +65565,11 @@ PrefabInstance: m_Modifications: - target: {fileID: 243343966221896818, guid: 6447e7f877b893f46bc4efe1ebc9fe9e, type: 3} propertyPath: m_LocalPosition.x - value: 0 + value: 16.78 objectReference: {fileID: 0} - target: {fileID: 243343966221896818, guid: 6447e7f877b893f46bc4efe1ebc9fe9e, type: 3} propertyPath: m_LocalPosition.y - value: 0 + value: -12.76 objectReference: {fileID: 0} - target: {fileID: 243343966221896818, guid: 6447e7f877b893f46bc4efe1ebc9fe9e, type: 3} propertyPath: m_LocalPosition.z @@ -65601,10 +65620,26 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 0} m_Modifications: + - target: {fileID: 1680573792925415762, guid: d00d92ab204198c489965b31a298b234, type: 3} + propertyPath: Builder + value: + objectReference: {fileID: 1814202916} - target: {fileID: 1680573792925415762, guid: d00d92ab204198c489965b31a298b234, type: 3} propertyPath: VfxDash value: objectReference: {fileID: 4566952472781634859, guid: daf6ae43ee06c424ba624a471e90b72c, type: 3} + - target: {fileID: 1680573792925415762, guid: d00d92ab204198c489965b31a298b234, type: 3} + propertyPath: MoveSpeed + value: 16 + objectReference: {fileID: 0} + - target: {fileID: 1680573792925415762, guid: d00d92ab204198c489965b31a298b234, type: 3} + propertyPath: DriftSpeed + value: 80 + objectReference: {fileID: 0} + - target: {fileID: 1680573792925415762, guid: d00d92ab204198c489965b31a298b234, type: 3} + propertyPath: DashMultiplier + value: 80 + objectReference: {fileID: 0} - target: {fileID: 1680573792925415762, guid: d00d92ab204198c489965b31a298b234, type: 3} propertyPath: 'ClassIndicators.Array.data[0]' value: @@ -65627,7 +65662,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 4060073025839678449, guid: d00d92ab204198c489965b31a298b234, type: 3} propertyPath: m_LocalPosition.y - value: -0.73 + value: -0.26 objectReference: {fileID: 0} - target: {fileID: 4060073025839678449, guid: d00d92ab204198c489965b31a298b234, type: 3} propertyPath: m_LocalPosition.z @@ -65665,12 +65700,16 @@ PrefabInstance: propertyPath: m_Name value: Player objectReference: {fileID: 0} + - target: {fileID: 9147163641451663911, guid: d00d92ab204198c489965b31a298b234, type: 3} + propertyPath: m_TagString + value: Player + objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] m_AddedComponents: - targetCorrespondingSourceObject: {fileID: 9147163641451663911, guid: d00d92ab204198c489965b31a298b234, type: 3} - insertIndex: -1 + insertIndex: 1 addedObject: {fileID: 1814202916} m_SourcePrefab: {fileID: 100100000, guid: d00d92ab204198c489965b31a298b234, type: 3} --- !u!1001 &5778659820767749594 @@ -65876,5 +65915,4 @@ SceneRoots: - {fileID: 1177372200} - {fileID: 2316236105731553357} - {fileID: 5778659820767749594} - - {fileID: 2108843208} - {fileID: 210807110740579273} diff --git a/Assets/Scriptables/AI.meta b/Assets/Scriptables/AI.meta new file mode 100644 index 0000000..f7d57c6 --- /dev/null +++ b/Assets/Scriptables/AI.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f97cfcba126037940a7935c0ca5213dd +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scriptables/AI/Enemy.meta b/Assets/Scriptables/AI/Enemy.meta new file mode 100644 index 0000000..77e8066 --- /dev/null +++ b/Assets/Scriptables/AI/Enemy.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 78b0e57b5fb1cbb4d8ddcd69c61a2833 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scriptables/AI/Enemy/EnemyAttackState01.asset b/Assets/Scriptables/AI/Enemy/EnemyAttackState01.asset new file mode 100644 index 0000000..574c20e --- /dev/null +++ b/Assets/Scriptables/AI/Enemy/EnemyAttackState01.asset @@ -0,0 +1,14 @@ +%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: 8dc550eabcee2e84e94ae0bc898d72b4, type: 3} + m_Name: EnemyAttackState01 + m_EditorClassIdentifier: diff --git a/Assets/Scriptables/AI/Enemy/EnemyAttackState01.asset.meta b/Assets/Scriptables/AI/Enemy/EnemyAttackState01.asset.meta new file mode 100644 index 0000000..c91e3f0 --- /dev/null +++ b/Assets/Scriptables/AI/Enemy/EnemyAttackState01.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0b9cc3e63ee0125479639c05b89977f8 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scriptables/AI/Enemy/EnemyChaseState01.asset b/Assets/Scriptables/AI/Enemy/EnemyChaseState01.asset new file mode 100644 index 0000000..d2052bd --- /dev/null +++ b/Assets/Scriptables/AI/Enemy/EnemyChaseState01.asset @@ -0,0 +1,15 @@ +%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: 5f2962a1dddd6484e913c62893d7e512, type: 3} + m_Name: EnemyChaseState01 + m_EditorClassIdentifier: + Speed: 10 diff --git a/Assets/Scriptables/AI/Enemy/EnemyChaseState01.asset.meta b/Assets/Scriptables/AI/Enemy/EnemyChaseState01.asset.meta new file mode 100644 index 0000000..538f517 --- /dev/null +++ b/Assets/Scriptables/AI/Enemy/EnemyChaseState01.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 71a5afe255167e14cad7bb413bdef532 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scriptables/AI/Enemy/EnemyWalkState01.asset b/Assets/Scriptables/AI/Enemy/EnemyWalkState01.asset new file mode 100644 index 0000000..d12762c --- /dev/null +++ b/Assets/Scriptables/AI/Enemy/EnemyWalkState01.asset @@ -0,0 +1,14 @@ +%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: e82366a8b141d1c4587e07f13e902f29, type: 3} + m_Name: EnemyWalkState01 + m_EditorClassIdentifier: diff --git a/Assets/Scriptables/AI/Enemy/EnemyWalkState01.asset.meta b/Assets/Scriptables/AI/Enemy/EnemyWalkState01.asset.meta new file mode 100644 index 0000000..4cfd2c6 --- /dev/null +++ b/Assets/Scriptables/AI/Enemy/EnemyWalkState01.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5cd5bb6e94e95cf4c961f0433390f59f +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scriptables/Player/PlayerMainController.cs b/Assets/Scriptables/Player/PlayerMainController.cs index 977503e..0a4e0d8 100644 --- a/Assets/Scriptables/Player/PlayerMainController.cs +++ b/Assets/Scriptables/Player/PlayerMainController.cs @@ -11,7 +11,7 @@ using UnityEngine.UI; [SelectionBase] public class Player : MonoBehaviour { [Header("Asset/Prefab")] - [SerializeField] public BuilderHandlerRunner Builder; + [SerializeField] public BuilderManager Builder; [Header("Movement")] [SerializeField] private Rigidbody2D RigidBody; @@ -46,7 +46,7 @@ public class Player : MonoBehaviour { private enum Directions { Left, Right, Up, Down } void Awake() { - Builder = GetComponent(); + Builder = GetComponent(); VfxDashHandler = new VfxHandlerBase(VfxDash, 5, 5); SetClass(1); } diff --git a/Assets/Scripts/Runtime/AI/Base/AgentController.cs b/Assets/Scripts/Runtime/AI/Base/AgentController.cs deleted file mode 100644 index 7f0c7cd..0000000 --- a/Assets/Scripts/Runtime/AI/Base/AgentController.cs +++ /dev/null @@ -1,17 +0,0 @@ -using UnityEngine; - -namespace AI.Base { - public abstract class AgentController : MonoBehaviour { - protected IState currentState; - - protected virtual void Update() { - currentState?.Tick(); - IState next = currentState?.CheckTransitions(); - if (next != null && next != currentState) { - currentState.OnExit(); - currentState = next; - currentState.OnEnter(); - } - } - } -} diff --git a/Assets/Scripts/Runtime/AI/Base/IState.cs b/Assets/Scripts/Runtime/AI/Base/IState.cs index a4ceb7d..1c2b896 100644 --- a/Assets/Scripts/Runtime/AI/Base/IState.cs +++ b/Assets/Scripts/Runtime/AI/Base/IState.cs @@ -1,8 +1,10 @@ -namespace AI.Base { - public interface IState { - void OnEnter(); - void Tick(); - void OnExit(); - IState CheckTransitions(); - } +using System.Runtime.InteropServices.WindowsRuntime; +using UnityEngine; + +public interface IState { + public void Initialize(Transform ownerTransform); + public void Start(); + public void Tick(); + public void Stop(); + public virtual IState GetNextState() => null; } diff --git a/Assets/Scripts/Runtime/AI/Base/StateManager.cs b/Assets/Scripts/Runtime/AI/Base/StateManager.cs new file mode 100644 index 0000000..df04086 --- /dev/null +++ b/Assets/Scripts/Runtime/AI/Base/StateManager.cs @@ -0,0 +1,34 @@ +using Unity.IO.LowLevel.Unsafe; +using UnityEngine; + +namespace AI.Base { + abstract public class StateManager : MonoBehaviour { + protected IState CurrentState; + + virtual protected void Update() { + CurrentState?.Tick(); + IState next = GetNextState(); + if (next != null && next != CurrentState) { + CurrentState.Stop(); + CurrentState = next; + CurrentState.Start(); + } + } + + abstract protected IState GetNextState(); + } + + public class StateNode : ScriptableObject, IState { + protected Transform Owner; + + virtual public void Initialize(Transform ownerTransform) { + Owner = ownerTransform; + } + + virtual public void Start() {} + virtual public void Stop() {} + virtual public void Tick() {} + + virtual public IState GetNextState() => this; + } +} diff --git a/Assets/Scripts/Runtime/AI/Base/AgentController.cs.meta b/Assets/Scripts/Runtime/AI/Base/StateManager.cs.meta similarity index 100% rename from Assets/Scripts/Runtime/AI/Base/AgentController.cs.meta rename to Assets/Scripts/Runtime/AI/Base/StateManager.cs.meta diff --git a/Assets/Scripts/Runtime/AI/StateMachines/EnemyAttackState.cs b/Assets/Scripts/Runtime/AI/StateMachines/EnemyAttackState.cs new file mode 100644 index 0000000..38efc1e --- /dev/null +++ b/Assets/Scripts/Runtime/AI/StateMachines/EnemyAttackState.cs @@ -0,0 +1,10 @@ +using AI.Base; +using System; +using UnityEngine; + + [CreateAssetMenu(menuName = "AI/Enemy/EnemyAttackState")] + public class EnemyAttackState : StateNode { + override public void Start() { Debug.Log("Entering Idle"); } + override public void Tick() { } + override public void Stop() { Debug.Log("Exiting Idle"); } + } diff --git a/Assets/Scripts/Runtime/AI/StateMachines/EnemyAttackState.cs.meta b/Assets/Scripts/Runtime/AI/StateMachines/EnemyAttackState.cs.meta new file mode 100644 index 0000000..ee6d6c4 --- /dev/null +++ b/Assets/Scripts/Runtime/AI/StateMachines/EnemyAttackState.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 8dc550eabcee2e84e94ae0bc898d72b4 \ No newline at end of file diff --git a/Assets/Scripts/Runtime/AI/StateMachines/EnemyChaseState.cs b/Assets/Scripts/Runtime/AI/StateMachines/EnemyChaseState.cs new file mode 100644 index 0000000..406718d --- /dev/null +++ b/Assets/Scripts/Runtime/AI/StateMachines/EnemyChaseState.cs @@ -0,0 +1,26 @@ +using AI.Base; +using System; +using UnityEngine; + + [CreateAssetMenu(menuName = "AI/Enemy/EnemyChaseState")] + public class EnemyChaseState : StateNode { + public float Speed = 3f; + + private Transform Player; + + override public void Start() { + Player = GameObject.FindGameObjectWithTag("Player").transform; + Debug.Log("Entering Chase"); + } + + override public void Tick() { + if (Owner != null && Player != null) { + Vector2 dir = (Player.position - Owner.position).normalized; + Owner.position += (Vector3)dir * Speed * Time.deltaTime; + } + } + + override public void Stop() { + Debug.Log("Exiting Chase"); + } + } diff --git a/Assets/Scripts/Runtime/AI/StateMachines/EnemyChaseState.cs.meta b/Assets/Scripts/Runtime/AI/StateMachines/EnemyChaseState.cs.meta new file mode 100644 index 0000000..36997a9 --- /dev/null +++ b/Assets/Scripts/Runtime/AI/StateMachines/EnemyChaseState.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 5f2962a1dddd6484e913c62893d7e512 \ No newline at end of file diff --git a/Assets/Scripts/Runtime/AI/StateMachines/EnemyStateMachine.cs b/Assets/Scripts/Runtime/AI/StateMachines/EnemyStateMachine.cs deleted file mode 100644 index 863c28e..0000000 --- a/Assets/Scripts/Runtime/AI/StateMachines/EnemyStateMachine.cs +++ /dev/null @@ -1,15 +0,0 @@ -using AI.Base; -using UnityEngine; - -namespace AI.StateMachines { - public class EnemyStateMachine : AgentController { - public IState IdleState; - public IState ChaseState; - - protected override void Start() { - base.Start(); - currentState = IdleState; - currentState?.OnEnter(); - } - } -} diff --git a/Assets/Scripts/Runtime/AI/StateMachines/EnemyStateMachine.cs.meta b/Assets/Scripts/Runtime/AI/StateMachines/EnemyStateMachine.cs.meta deleted file mode 100644 index 466caee..0000000 --- a/Assets/Scripts/Runtime/AI/StateMachines/EnemyStateMachine.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 71ab834a15cf8184ca8a951d8ea332bb \ No newline at end of file diff --git a/Assets/Scripts/Runtime/AI/StateMachines/EnemyStateManager.cs b/Assets/Scripts/Runtime/AI/StateMachines/EnemyStateManager.cs new file mode 100644 index 0000000..9eb4e75 --- /dev/null +++ b/Assets/Scripts/Runtime/AI/StateMachines/EnemyStateManager.cs @@ -0,0 +1,54 @@ +using AI.Base; +using UnityEngine; +using static TMPro.SpriteAssetUtilities.TexturePacker_JsonArray; + + public class EnemyStateManager : StateManager { + [Header("States")] + [SerializeField] public StateNode WalkState; + [SerializeField] public StateNode ChaseState; + [SerializeField] public StateNode AttackState; + + [Header("Attributes")] + [SerializeField] private float ChaseDistance = 10f; + [SerializeField] private float AttackDistance = 1f; + + private Transform Player; + + protected void Start() { + Player = GameObject.FindGameObjectWithTag("Player")?.transform; + WalkState.Initialize(this.transform); + ChaseState.Initialize(this.transform); + AttackState.Initialize(this.transform); + CurrentState = WalkState; + CurrentState.Start(); + } + + override protected IState GetNextState() { + if (Player == null) + return CurrentState; + + float dist = Vector2.Distance(transform.position, Player.position); + if (dist < AttackDistance) + return AttackState.GetNextState(); + else if (dist < ChaseDistance) + return ChaseState.GetNextState(); + else + return WalkState.GetNextState(); + } + + private void OnDrawGizmos() { + DrawChaseDistance(); + DrawAttackDistance(); + } + + private void DrawChaseDistance() { + Gizmos.color = CurrentState == (IState)ChaseState ? Color.yellow : Color.green; + Vector2 center = this.transform.position; + Gizmos.DrawWireSphere(center, ChaseDistance); + } + private void DrawAttackDistance() { + Gizmos.color = CurrentState == (IState)AttackState ? Color.red : Color.green; + Vector2 center = this.transform.position; + Gizmos.DrawWireSphere(center, AttackDistance); + } + } diff --git a/Assets/Scripts/Runtime/AI/StateMachines/EnemyStateManager.cs.meta b/Assets/Scripts/Runtime/AI/StateMachines/EnemyStateManager.cs.meta new file mode 100644 index 0000000..a41e6ec --- /dev/null +++ b/Assets/Scripts/Runtime/AI/StateMachines/EnemyStateManager.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: a5c89455bac58d943a2e1e110d37a24d \ No newline at end of file diff --git a/Assets/Scripts/Runtime/AI/StateMachines/EnemyWalkState.cs b/Assets/Scripts/Runtime/AI/StateMachines/EnemyWalkState.cs new file mode 100644 index 0000000..c8d7fe0 --- /dev/null +++ b/Assets/Scripts/Runtime/AI/StateMachines/EnemyWalkState.cs @@ -0,0 +1,12 @@ +using AI.Base; +using System; +using UnityEngine; + + [CreateAssetMenu(menuName = "AI/Enemy/EnemyWalkState")] + public class EnemyWalkState : StateNode { + + override public void Start() { Debug.Log("Entering Idle"); } + override public void Tick() { } + override public void Stop() { Debug.Log("Exiting Idle"); } + + } diff --git a/Assets/Scripts/Runtime/AI/StateMachines/EnemyWalkState.cs.meta b/Assets/Scripts/Runtime/AI/StateMachines/EnemyWalkState.cs.meta new file mode 100644 index 0000000..6a10cae --- /dev/null +++ b/Assets/Scripts/Runtime/AI/StateMachines/EnemyWalkState.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: e82366a8b141d1c4587e07f13e902f29 \ No newline at end of file diff --git a/Assets/Scripts/Runtime/Characters/Player/Building/BuilderSettings.cs b/Assets/Scripts/Runtime/Characters/Player/Building/BuilderSettings.cs index 08499e0..8c6a6dc 100644 --- a/Assets/Scripts/Runtime/Characters/Player/Building/BuilderSettings.cs +++ b/Assets/Scripts/Runtime/Characters/Player/Building/BuilderSettings.cs @@ -1,11 +1,28 @@ +using AI.Base; using UnityEngine; [CreateAssetMenu(menuName = "Custom/BuilderSettings")] -public class BuilderSettings : ScriptableObject { +public class BuilderSettings : ScriptableObject, IState { [Header("Build Prefabs")] public GameObject ObjToSpawn; public GameObject ObjAsPreview; [Header("VFX")] public GameObject Vfx; + + public void Initialize(Transform ownerTransform) { + throw new System.NotImplementedException(); + } + + public void Start() { + throw new System.NotImplementedException(); + } + + public void Stop() { + throw new System.NotImplementedException(); + } + + public void Tick() { + throw new System.NotImplementedException(); + } } diff --git a/Assets/Scripts/Runtime/Enemies.meta b/Assets/Scripts/Runtime/Enemies.meta new file mode 100644 index 0000000..eb1cc63 --- /dev/null +++ b/Assets/Scripts/Runtime/Enemies.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 22398a98badb3d8418a9b3cccc131ae6 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Runtime/GameManagement.meta b/Assets/Scripts/Runtime/GameManagement.meta new file mode 100644 index 0000000..6a1092a --- /dev/null +++ b/Assets/Scripts/Runtime/GameManagement.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b3faa1c4d29927b43b1e2c49d090a33d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Runtime/GameManagement/GameManager.cs b/Assets/Scripts/Runtime/GameManagement/GameManager.cs new file mode 100644 index 0000000..db789e8 --- /dev/null +++ b/Assets/Scripts/Runtime/GameManagement/GameManager.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +namespace Assets.Scripts.Runtime.GameManagement { + public class GameManager : MonoBehaviour { + public static bool IsPaused { get; private set; } + [SerializeField] private GameObject pauseMenuUI; + + void Update() { + if (Input.GetKeyDown(KeyCode.Escape)) + TogglePause(); + } + + public void TogglePause() { + IsPaused = !IsPaused; + Time.timeScale = IsPaused ? 0f : 1f; + AudioListener.pause = IsPaused; + pauseMenuUI.SetActive(IsPaused); + } + } +} diff --git a/Assets/Scripts/Runtime/GameManagement/GameManager.cs.meta b/Assets/Scripts/Runtime/GameManagement/GameManager.cs.meta new file mode 100644 index 0000000..76c7373 --- /dev/null +++ b/Assets/Scripts/Runtime/GameManagement/GameManager.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 7691458bb4726aa4da3d14211bfa3e4d \ No newline at end of file