diff --git a/ProjektUnity/Assets/Enemy 2.meta b/ProjektUnity/Assets/Enemy 2.meta new file mode 100644 index 0000000..19b94aa --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 82bf254122ef80449b51a95c33815d86 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjektUnity/Assets/Enemy 2/BasicEnemy.meta b/ProjektUnity/Assets/Enemy 2/BasicEnemy.meta new file mode 100644 index 0000000..65a2cfb --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/BasicEnemy.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9ee5721d58b55084a940198d9fd3cffc +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjektUnity/Assets/Enemy 2/BasicEnemy/BasicEnemy.cs b/ProjektUnity/Assets/Enemy 2/BasicEnemy/BasicEnemy.cs new file mode 100644 index 0000000..71c0e79 --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/BasicEnemy/BasicEnemy.cs @@ -0,0 +1,74 @@ +using System.Collections; +using System.Collections.Generic; +using Unity.VisualScripting; +using UnityEditor; +using UnityEditor.Callbacks; +using UnityEngine; +using UnityEngine.Timeline; + +public class BasicEnemy : MonoBehaviour +{ + + [Header("References")] + public Transform parentTransform; + public Player playerData; + public BasicEnemyStateController sc; + + [Header("Settings")] + + public float distance; + public float moveSpeed; + + [Header("Internal")] + + public Vector2 targetPosition; + public Vector2 currentTargetVector; + public int randomNumber; + public Vector2 currentVelocity; + + void Awake() + { + currentTargetVector = new Vector2(Random.Range(0,2)*2-1, Random.Range(0,2)*2-1); + } + + void Start() + { + + } + + void Update() + { + + if(Input.GetKeyDown(KeyCode.Q)) + { + RandomNeighborVector(); + CalculateTargetPosition(); + } + + MoveToPosition(); + + } + + void CalculateTargetPosition() + { + targetPosition = playerData.playerPosition + currentTargetVector * distance; + } + + void RandomNeighborVector() + { + if(Random.Range(0,2) == 0) + { + currentTargetVector.x = currentTargetVector.x - (currentTargetVector.x * 2); + } + else + { + currentTargetVector.y = currentTargetVector.y - (currentTargetVector.y * 2); + } + } + + void MoveToPosition() + { + parentTransform.position = Vector2.SmoothDamp(transform.position, targetPosition, ref currentVelocity, moveSpeed * Time.deltaTime); + } + +} diff --git a/ProjektUnity/Assets/Enemy 2/BasicEnemy/BasicEnemy.cs.meta b/ProjektUnity/Assets/Enemy 2/BasicEnemy/BasicEnemy.cs.meta new file mode 100644 index 0000000..a2ed3f7 --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/BasicEnemy/BasicEnemy.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 11a55b423f5f68e4a8bcb85bf693a99b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjektUnity/Assets/Enemy 2/BasicEnemy/BasicEnemy.prefab b/ProjektUnity/Assets/Enemy 2/BasicEnemy/BasicEnemy.prefab new file mode 100644 index 0000000..c4dcb0d --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/BasicEnemy/BasicEnemy.prefab @@ -0,0 +1,258 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &5948914820988570729 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 241451934901582234} + - component: {fileID: 5646867998537817824} + - component: {fileID: 9060708803304430808} + m_Layer: 0 + m_Name: BasicEnemy + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &241451934901582234 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5948914820988570729} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 2554130532733664191} + - {fileID: 6332410247729874135} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!50 &5646867998537817824 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5948914820988570729} + m_BodyType: 1 + m_Simulated: 1 + m_UseFullKinematicContacts: 0 + m_UseAutoMass: 0 + m_Mass: 1 + m_LinearDrag: 0 + m_AngularDrag: 0.05 + 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_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 4 +--- !u!61 &9060708803304430808 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5948914820988570729} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_IsTrigger: 0 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0, y: 0} + m_SpriteTilingProperty: + border: {x: 0, y: 0, z: 0, w: 0} + pivot: {x: 0, y: 0} + oldSize: {x: 0, y: 0} + newSize: {x: 0, y: 0} + adaptiveTilingThreshold: 0 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 1, y: 1} + m_EdgeRadius: 0 +--- !u!1 &7636422298849904476 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 6332410247729874135} + - component: {fileID: 7103501296239490851} + - component: {fileID: 3882792213140454294} + m_Layer: 0 + m_Name: EnemyBrain + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &6332410247729874135 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7636422298849904476} + 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: 241451934901582234} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &7103501296239490851 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7636422298849904476} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 11a55b423f5f68e4a8bcb85bf693a99b, type: 3} + m_Name: + m_EditorClassIdentifier: + parentTransform: {fileID: 241451934901582234} + playerData: {fileID: 11400000, guid: 1eb106af6b01cff45878a6564b04fa81, type: 2} + distance: 7.5 + moveSpeed: 250 + targetPosition: {x: 0, y: 0} + currentTargetVector: {x: 0, y: 0} + randomNumber: 0 + currentVelocity: {x: 0, y: 0} +--- !u!114 &3882792213140454294 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7636422298849904476} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 89c349a0b8dd3744ca4a6a956c37a102, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1 &8588625269083370808 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2554130532733664191} + - component: {fileID: 1853365547513339295} + m_Layer: 0 + m_Name: EnemySprite + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &2554130532733664191 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8588625269083370808} + 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: 241451934901582234} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!212 &1853365547513339295 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8588625269083370808} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 0 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 2747690628134850419, guid: b670ab75dde984907b8570040daa08c5, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 1, y: 0.8828125} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 diff --git a/ProjektUnity/Assets/Enemy 2/BasicEnemy/BasicEnemy.prefab.meta b/ProjektUnity/Assets/Enemy 2/BasicEnemy/BasicEnemy.prefab.meta new file mode 100644 index 0000000..0003c8e --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/BasicEnemy/BasicEnemy.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 0b21afa49dff7144b9be39b80f486c31 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjektUnity/Assets/Enemy 2/BasicEnemy/BasicEnemyMover.cs b/ProjektUnity/Assets/Enemy 2/BasicEnemy/BasicEnemyMover.cs new file mode 100644 index 0000000..48f5790 --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/BasicEnemy/BasicEnemyMover.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class BasicEnemyMover : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/ProjektUnity/Assets/Enemy 2/BasicEnemy/BasicEnemyMover.cs.meta b/ProjektUnity/Assets/Enemy 2/BasicEnemy/BasicEnemyMover.cs.meta new file mode 100644 index 0000000..b586a97 --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/BasicEnemy/BasicEnemyMover.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6561a2f840bd8224295dc78863baccb8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces.meta b/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces.meta new file mode 100644 index 0000000..d3b55ef --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 910dbf35b889c0246a15e580e0c7e435 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyBaseState.cs b/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyBaseState.cs new file mode 100644 index 0000000..e92a031 --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyBaseState.cs @@ -0,0 +1,9 @@ +using UnityEngine; + +public abstract class BasicenemyBaseState +{ + + + + +} diff --git a/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyBaseState.cs.meta b/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyBaseState.cs.meta new file mode 100644 index 0000000..21a0ea2 --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyBaseState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1f4c4008ca80ef14f896f45f81438010 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyMovingState.cs b/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyMovingState.cs new file mode 100644 index 0000000..8c9d43a --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyMovingState.cs @@ -0,0 +1,23 @@ +using System.Collections; +using System.Collections.Generic; +using Unity.VisualScripting; +using UnityEngine; + +public class BasicEnemyMovingState: IState +{ + public void OnEnter(BasicEnemyStateController sc) + { + + } + + public void UpdateState(BasicEnemyStateController sc) + { + + } + + public void OnExit(BasicEnemyStateController sc) + { + + } + +} diff --git a/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyMovingState.cs.meta b/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyMovingState.cs.meta new file mode 100644 index 0000000..741206a --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyMovingState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 58629341ddd353743ae4cc1cd1832d73 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyPatrolState.cs b/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyPatrolState.cs new file mode 100644 index 0000000..9f94f0a --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyPatrolState.cs @@ -0,0 +1,24 @@ +using System.Collections; +using System.Collections.Generic; +using Unity.VisualScripting; +using UnityEngine; + +public class BasicEnemyPatrolState : IState +{ + + public void OnEnter(BasicEnemyStateController sc) + { + + } + + public void UpdateState(BasicEnemyStateController sc) + { + + } + + public void OnExit(BasicEnemyStateController sc) + { + + } + +} diff --git a/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyPatrolState.cs.meta b/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyPatrolState.cs.meta new file mode 100644 index 0000000..f6b5545 --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyPatrolState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4968fa0b37ab5344595f0618dc33c8db +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyShootingState.cs b/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyShootingState.cs new file mode 100644 index 0000000..efea03a --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyShootingState.cs @@ -0,0 +1,24 @@ +using System.Collections; +using System.Collections.Generic; +using Unity.VisualScripting; +using UnityEngine; + +public class BasicEnemyShootingState : IState +{ + + public void OnEnter(BasicEnemyStateController sc) + { + + } + + public void UpdateState(BasicEnemyStateController sc) + { + + } + + public void OnExit(BasicEnemyStateController sc) + { + + } + +} diff --git a/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyShootingState.cs.meta b/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyShootingState.cs.meta new file mode 100644 index 0000000..62dfd72 --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyShootingState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 53a5e863180374d4c941d8d393df2be2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyStateController.cs b/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyStateController.cs new file mode 100644 index 0000000..0e0c55f --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyStateController.cs @@ -0,0 +1,42 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class BasicEnemyStateController : MonoBehaviour +{ + IState currentState; + BasicenemyBaseState currentStatee; + public BasicEnemyPatrolState patrolState = new BasicEnemyPatrolState(); + public BasicEnemyMovingState movingState = new BasicEnemyMovingState(); + public BasicEnemyShootingState ShootingState = new BasicEnemyShootingState(); + + private void Start() + { + ChangeState(patrolState); + } + + void Update() + { + if(currentState != null) + { + currentState.UpdateState(this); + } + } + + public void ChangeState(IState newState) + { + if(currentState != null) + { + currentState.OnExit(this); + } + currentState = newState; + currentState.OnEnter(this); + } +} + +public interface IState +{ + public void OnEnter(BasicEnemyStateController controller); + public void UpdateState(BasicEnemyStateController controller); + public void OnExit(BasicEnemyStateController controller); +} diff --git a/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyStateController.cs.meta b/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyStateController.cs.meta new file mode 100644 index 0000000..fa33251 --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/BasicEnemy/Interfaces/BasicEnemyStateController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 89c349a0b8dd3744ca4a6a956c37a102 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjektUnity/Assets/Enemy 2/CornerEnemy.meta b/ProjektUnity/Assets/Enemy 2/CornerEnemy.meta new file mode 100644 index 0000000..c32cda7 --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/CornerEnemy.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 22a5702fae01e48498253edbe660c009 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjektUnity/Assets/Enemy 2/CornerEnemy/Bullet.prefab b/ProjektUnity/Assets/Enemy 2/CornerEnemy/Bullet.prefab new file mode 100644 index 0000000..a85763e --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/CornerEnemy/Bullet.prefab @@ -0,0 +1,131 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &5968115980010623989 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2913999036722315340} + - component: {fileID: 1818678054169691364} + - component: {fileID: 4860762186380713840} + - component: {fileID: 4846165707667960322} + m_Layer: 0 + m_Name: Bullet + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &2913999036722315340 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5968115980010623989} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 2.11, y: 0, z: 0} + m_LocalScale: {x: 0.7, y: 1.5, z: 0.7} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!212 &1818678054169691364 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5968115980010623989} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 0 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 10913, guid: 0000000000000000f000000000000000, type: 0} + m_Color: {r: 0, g: 1, b: 0.9187336, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 0.2, y: 0.2} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!114 &4860762186380713840 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5968115980010623989} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 22c0ca694b1a3e84fa2124fa4e1bc078, type: 3} + m_Name: + m_EditorClassIdentifier: + player: {fileID: 0} + rb: {fileID: 0} + force: 5 + rotation: -90 +--- !u!50 &4846165707667960322 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5968115980010623989} + m_BodyType: 0 + m_Simulated: 1 + m_UseFullKinematicContacts: 0 + m_UseAutoMass: 0 + m_Mass: 1 + m_LinearDrag: 0 + m_AngularDrag: 0.05 + m_GravityScale: 0 + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_Interpolate: 1 + m_SleepingMode: 1 + m_CollisionDetection: 1 + m_Constraints: 0 diff --git a/ProjektUnity/Assets/Enemy 2/CornerEnemy/Bullet.prefab.meta b/ProjektUnity/Assets/Enemy 2/CornerEnemy/Bullet.prefab.meta new file mode 100644 index 0000000..4da063d --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/CornerEnemy/Bullet.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 29242ccfd2d49664695ec236149d46c0 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjektUnity/Assets/Enemy 2/CornerEnemy/CE.prefab b/ProjektUnity/Assets/Enemy 2/CornerEnemy/CE.prefab new file mode 100644 index 0000000..dd6cbf4 --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/CornerEnemy/CE.prefab @@ -0,0 +1,154 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &3387530004440916541 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 882353549050517113} + - component: {fileID: 8730294487243150790} + - component: {fileID: 4149420046778740505} + - component: {fileID: 8094646476916395580} + m_Layer: 0 + m_Name: CE + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &882353549050517113 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3387530004440916541} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 3.95, y: 3.87, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 5819585485157445600} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!212 &8730294487243150790 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3387530004440916541} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 0 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 3625043607559282579, guid: 19fb86013d8c24d6cb8410c0aadf30fa, type: 3} + m_Color: {r: 1, g: 0, b: 0, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 1, y: 0.5} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!114 &4149420046778740505 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3387530004440916541} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 29f4f9763f9d32b42a66f763a69e97d8, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &8094646476916395580 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3387530004440916541} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c7134d437a038a1458826bf4de570aa7, type: 3} + m_Name: + m_EditorClassIdentifier: + playerData: {fileID: 11400000, guid: 1eb106af6b01cff45878a6564b04fa81, type: 2} + moveDistance: 7.5 + moveSpeed: 250 + moveDuration: 2 + bullet: {fileID: 5968115980010623989, guid: 29242ccfd2d49664695ec236149d46c0, type: 3} + bulletPos: {fileID: 5819585485157445600} + timeBetweenShots: 1 + leaveShootsPhaseTime: 0 + shootAmount: 3 + cEData: {fileID: 11400000, guid: d3e10099688917b488b09c4c6f3b52ae, type: 2} +--- !u!1 &5360936932408424590 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5819585485157445600} + m_Layer: 0 + m_Name: BulletPosition + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &5819585485157445600 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5360936932408424590} + 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: 882353549050517113} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/ProjektUnity/Assets/Enemy 2/CornerEnemy/CE.prefab.meta b/ProjektUnity/Assets/Enemy 2/CornerEnemy/CE.prefab.meta new file mode 100644 index 0000000..b04c6aa --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/CornerEnemy/CE.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: e2b3e57d1c69c284299d86daa82cbdcc +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjektUnity/Assets/Enemy 2/CornerEnemy/CEVariables.cs b/ProjektUnity/Assets/Enemy 2/CornerEnemy/CEVariables.cs new file mode 100644 index 0000000..d8867d5 --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/CornerEnemy/CEVariables.cs @@ -0,0 +1,37 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class CEVariables : MonoBehaviour +{ + [Header("Data")] + public Player playerData; + + [Header("Settings MovePhase")] + public float moveDistance; + public float moveSpeed; + public float moveDuration; + + [Header("ShootPhase")] + public GameObject bullet; + public Transform bulletPos; + public float timeBetweenShots; + public float leaveShootsPhaseTime; + public float shootAmount; + + [Header("Internal References")] + public CEData cEData; + + void Awake() + { + moveDistance = cEData.moveDistance; + moveSpeed = cEData.moveSpeed; + moveDuration = cEData.moveDuration; + } + + public void CreateBullet() + { + Instantiate(bullet, bulletPos.position, Quaternion.identity); + } + +} diff --git a/ProjektUnity/Assets/Enemy 2/CornerEnemy/CEVariables.cs.meta b/ProjektUnity/Assets/Enemy 2/CornerEnemy/CEVariables.cs.meta new file mode 100644 index 0000000..5ff7f09 --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/CornerEnemy/CEVariables.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c7134d437a038a1458826bf4de570aa7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjektUnity/Assets/Enemy 2/CornerEnemy/Data.meta b/ProjektUnity/Assets/Enemy 2/CornerEnemy/Data.meta new file mode 100644 index 0000000..fc26415 --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/CornerEnemy/Data.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9ede1673960af3e4582a4b2ba5f17687 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjektUnity/Assets/Enemy 2/CornerEnemy/Data/CEData.asset b/ProjektUnity/Assets/Enemy 2/CornerEnemy/Data/CEData.asset new file mode 100644 index 0000000..ae55091 --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/CornerEnemy/Data/CEData.asset @@ -0,0 +1,17 @@ +%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: ce656df099041f6428dde90080e911ad, type: 3} + m_Name: CEData + m_EditorClassIdentifier: + moveDistance: 7.5 + moveSpeed: 250 + moveDuration: 2 diff --git a/ProjektUnity/Assets/Enemy 2/CornerEnemy/Data/CEData.asset.meta b/ProjektUnity/Assets/Enemy 2/CornerEnemy/Data/CEData.asset.meta new file mode 100644 index 0000000..e74668e --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/CornerEnemy/Data/CEData.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d3e10099688917b488b09c4c6f3b52ae +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjektUnity/Assets/Enemy 2/CornerEnemy/Data/CEData.cs b/ProjektUnity/Assets/Enemy 2/CornerEnemy/Data/CEData.cs new file mode 100644 index 0000000..a10abce --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/CornerEnemy/Data/CEData.cs @@ -0,0 +1,14 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +[CreateAssetMenu] +public class CEData : ScriptableObject +{ + [Header("Settings")] + + public float moveDistance; + public float moveSpeed; + public float moveDuration; + +} diff --git a/ProjektUnity/Assets/Enemy 2/CornerEnemy/Data/CEData.cs.meta b/ProjektUnity/Assets/Enemy 2/CornerEnemy/Data/CEData.cs.meta new file mode 100644 index 0000000..a843933 --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/CornerEnemy/Data/CEData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ce656df099041f6428dde90080e911ad +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjektUnity/Assets/Enemy 2/CornerEnemy/EnemyBulletScript.cs b/ProjektUnity/Assets/Enemy 2/CornerEnemy/EnemyBulletScript.cs new file mode 100644 index 0000000..cd32711 --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/CornerEnemy/EnemyBulletScript.cs @@ -0,0 +1,32 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class EnemyBulletScript : MonoBehaviour +{ + public GameObject player; + public Rigidbody2D rb; + public float force; + public float rotation; + + public GameObject[] bullets; + + void Start() + { + + rb = GetComponent(); + player = GameObject.FindGameObjectWithTag("Player"); + + Vector3 direction = player.transform.position - transform.position; + rb.velocity = new Vector2(direction.x, direction.y).normalized * force; + + float rot = Mathf.Atan2(-direction.y, -direction.x) * Mathf.Rad2Deg; + transform.rotation = Quaternion.Euler(0,0, rot + rotation); + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/ProjektUnity/Assets/Enemy 2/CornerEnemy/EnemyBulletScript.cs.meta b/ProjektUnity/Assets/Enemy 2/CornerEnemy/EnemyBulletScript.cs.meta new file mode 100644 index 0000000..e3ca147 --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/CornerEnemy/EnemyBulletScript.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 22c0ca694b1a3e84fa2124fa4e1bc078 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine.meta b/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine.meta new file mode 100644 index 0000000..b60d767 --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ca264db2c83738e43bf3ce0c1cb45219 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEBaseState.cs b/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEBaseState.cs new file mode 100644 index 0000000..3fbe667 --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEBaseState.cs @@ -0,0 +1,11 @@ + +using UnityEngine; + +public abstract class CEBaseState +{ + + public abstract void EnterState(CEStateManager CornerEnemy); + + public abstract void UpdateState(CEStateManager CornerEnemy); + +} diff --git a/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEBaseState.cs.meta b/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEBaseState.cs.meta new file mode 100644 index 0000000..9b3622c --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEBaseState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 91d97a9871ad39e4fba6de98d983afd1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEMoveState.cs b/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEMoveState.cs new file mode 100644 index 0000000..f187acd --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEMoveState.cs @@ -0,0 +1,58 @@ +using Unity.VisualScripting; +using UnityEngine; + +public class CEMoveState : CEBaseState +{ + CEVariables cEVariables; + public Vector2 targetPosition; + public Vector2 currentTargetVector; + public int randomNumber; + public Vector2 currentVelocity; + public float timeUntilSwitch; + + public override void EnterState(CEStateManager CornerEnemy) //passiert nur das erste mal wo er aufgerufen wird + { + cEVariables = CornerEnemy.GetComponent(); + currentTargetVector = new Vector2(Random.Range(0,2)*2-1, Random.Range(0,2)*2-1); + RandomNeighborVector(); + timeUntilSwitch = cEVariables.moveDuration; + } + + public override void UpdateState(CEStateManager CornerEnemy) //passiert jeden frame + { + CalculateTargetPosition(); + timeUntilSwitch -= Time.smoothDeltaTime; + if(timeUntilSwitch >= 0) + { + MoveToPosition(CornerEnemy); + } + else + { + CornerEnemy.SwitchState(CornerEnemy.ShootState); + Debug.Log("switch to shoot"); + } + } + + void CalculateTargetPosition() + { + targetPosition = cEVariables.playerData.playerPosition + currentTargetVector * cEVariables.moveDistance; + } + + void RandomNeighborVector() + { + if(Random.Range(0,2) == 0) + { + currentTargetVector.x = currentTargetVector.x - (currentTargetVector.x * 2); + } + else + { + currentTargetVector.y = currentTargetVector.y - (currentTargetVector.y * 2); + } + } + + void MoveToPosition(CEStateManager CornerEnemy) + { + CornerEnemy.transform.position = Vector2.SmoothDamp(CornerEnemy.transform.position, targetPosition, ref currentVelocity, cEVariables.moveSpeed * Time.deltaTime); + } +} + \ No newline at end of file diff --git a/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEMoveState.cs.meta b/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEMoveState.cs.meta new file mode 100644 index 0000000..1bc23c7 --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEMoveState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1c6a537fb83a4324aad655724f2f358d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEPatrolState.cs b/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEPatrolState.cs new file mode 100644 index 0000000..adc899c --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEPatrolState.cs @@ -0,0 +1,18 @@ +using UnityEngine; + +public class CEPatrolState : CEBaseState +{ + CEVariables cEVariables; + + public override void EnterState(CEStateManager CornerEnemy) + { + cEVariables = CornerEnemy.GetComponent(); + } + + public override void UpdateState(CEStateManager CornerEnemy) + { + + CornerEnemy.SwitchState(CornerEnemy.MoveState); + + } +} diff --git a/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEPatrolState.cs.meta b/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEPatrolState.cs.meta new file mode 100644 index 0000000..52a3ad7 --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEPatrolState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 15346aeec83ab4a419994afa358cef2e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEShootState.cs b/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEShootState.cs new file mode 100644 index 0000000..1aba480 --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEShootState.cs @@ -0,0 +1,41 @@ +using Unity.Properties; +using UnityEditor.U2D.Aseprite; +using UnityEngine; +using UnityEngine.U2D; + +public class CEShootState : CEBaseState +{ + CEVariables cEVariables; + public float timer; + public float timesShoot; + + public override void EnterState(CEStateManager CornerEnemy) + { + cEVariables = CornerEnemy.GetComponent(); + timer = 0; + timesShoot = 0; + } + + public override void UpdateState(CEStateManager CornerEnemy) + { + timer += Time.deltaTime; + if(timer > cEVariables.timeBetweenShots) + { + timer = 0; + Shoot(); + timesShoot++; + } + + if(timesShoot > cEVariables.shootAmount) + { + CornerEnemy.SwitchState(CornerEnemy.MoveState); + } + } + + + + public void Shoot() + { + cEVariables.CreateBullet(); + } +} diff --git a/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEShootState.cs.meta b/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEShootState.cs.meta new file mode 100644 index 0000000..331aa71 --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEShootState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 197736bf882dc2d42a124a72702b66f9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEStateManager.cs b/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEStateManager.cs new file mode 100644 index 0000000..09a6896 --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEStateManager.cs @@ -0,0 +1,30 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class CEStateManager : MonoBehaviour +{ + CEBaseState currentState; + public CEPatrolState PatrolState = new CEPatrolState(); + public CEMoveState MoveState = new CEMoveState(); + public CEShootState ShootState = new CEShootState(); + + void Start() + { + currentState = PatrolState; + + currentState.EnterState(this); + } + + // Update is called once per frame + void Update() + { + currentState.UpdateState(this); + } + + public void SwitchState(CEBaseState state) + { + currentState = state; + state.EnterState(this); + } +} diff --git a/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEStateManager.cs.meta b/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEStateManager.cs.meta new file mode 100644 index 0000000..7220143 --- /dev/null +++ b/ProjektUnity/Assets/Enemy 2/CornerEnemy/StateMachine/CEStateManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 29f4f9763f9d32b42a66f763a69e97d8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjektUnity/Assets/Scenes/TestScenes/Test_MarvinSchneider.unity b/ProjektUnity/Assets/Scenes/TestScenes/Test_MarvinSchneider.unity index 5fd6d1a..b64de23 100644 --- a/ProjektUnity/Assets/Scenes/TestScenes/Test_MarvinSchneider.unity +++ b/ProjektUnity/Assets/Scenes/TestScenes/Test_MarvinSchneider.unity @@ -123,6 +123,71 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1001 &286557122 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 241451934901582234, guid: 0b21afa49dff7144b9be39b80f486c31, type: 3} + propertyPath: m_LocalPosition.x + value: 7.76957 + objectReference: {fileID: 0} + - target: {fileID: 241451934901582234, guid: 0b21afa49dff7144b9be39b80f486c31, type: 3} + propertyPath: m_LocalPosition.y + value: -2.860758 + objectReference: {fileID: 0} + - target: {fileID: 241451934901582234, guid: 0b21afa49dff7144b9be39b80f486c31, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 241451934901582234, guid: 0b21afa49dff7144b9be39b80f486c31, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 241451934901582234, guid: 0b21afa49dff7144b9be39b80f486c31, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 241451934901582234, guid: 0b21afa49dff7144b9be39b80f486c31, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 241451934901582234, guid: 0b21afa49dff7144b9be39b80f486c31, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 241451934901582234, guid: 0b21afa49dff7144b9be39b80f486c31, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 241451934901582234, guid: 0b21afa49dff7144b9be39b80f486c31, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 241451934901582234, guid: 0b21afa49dff7144b9be39b80f486c31, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5948914820988570729, guid: 0b21afa49dff7144b9be39b80f486c31, type: 3} + propertyPath: m_Name + value: BasicEnemy + objectReference: {fileID: 0} + - target: {fileID: 7103501296239490851, guid: 0b21afa49dff7144b9be39b80f486c31, type: 3} + propertyPath: sc + value: + objectReference: {fileID: 2005503033} + - target: {fileID: 7103501296239490851, guid: 0b21afa49dff7144b9be39b80f486c31, type: 3} + propertyPath: playerData + value: + objectReference: {fileID: 11400000, guid: 7c64b53d21912624bb32264372f5f097, type: 2} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 0b21afa49dff7144b9be39b80f486c31, type: 3} --- !u!4 &444734234 stripped Transform: m_CorrespondingSourceObject: {fileID: 893546842153150297, guid: 3252080e9352bb84eb35d950674a2ef9, type: 3} @@ -376,6 +441,17 @@ Transform: - {fileID: 444734234} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &2005503033 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 3882792213140454294, guid: 0b21afa49dff7144b9be39b80f486c31, type: 3} + m_PrefabInstance: {fileID: 286557122} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 89c349a0b8dd3744ca4a6a956c37a102, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &2082218125 GameObject: m_ObjectHideFlags: 3 @@ -602,6 +678,10 @@ PrefabInstance: propertyPath: m_Name value: Player objectReference: {fileID: 0} + - target: {fileID: 788356621976524134, guid: f25706fcb77adb246a6a86fbe829a8f3, type: 3} + propertyPath: player + value: + objectReference: {fileID: 11400000, guid: 7c64b53d21912624bb32264372f5f097, type: 2} - target: {fileID: 7799985602798067093, guid: f25706fcb77adb246a6a86fbe829a8f3, type: 3} propertyPath: m_LocalPosition.x value: 0 @@ -654,3 +734,4 @@ SceneRoots: - {fileID: 1055048549} - {fileID: 878561087} - {fileID: 1432196631} + - {fileID: 286557122} diff --git a/ProjektUnity/Assets/Scripts/Player/PlayerMover.cs b/ProjektUnity/Assets/Scripts/Player/PlayerMover.cs index 2f27247..79c4649 100644 --- a/ProjektUnity/Assets/Scripts/Player/PlayerMover.cs +++ b/ProjektUnity/Assets/Scripts/Player/PlayerMover.cs @@ -16,6 +16,8 @@ public class PlayerMover : MonoBehaviour public PlayerStats playerStats; public float speed = 2f; + public Player player; + // Start is called before the first frame update void Start() { @@ -28,6 +30,8 @@ public class PlayerMover : MonoBehaviour void Update() { Move(); + + player.playerPosition = transform.position; } public void Move(){ diff --git a/ProjektUnity/Assets/Scripts/ScriptableObjects/Player/Player.cs b/ProjektUnity/Assets/Scripts/ScriptableObjects/Player/Player.cs index bcee610..10007a4 100644 --- a/ProjektUnity/Assets/Scripts/ScriptableObjects/Player/Player.cs +++ b/ProjektUnity/Assets/Scripts/ScriptableObjects/Player/Player.cs @@ -10,6 +10,8 @@ public class Player : ScriptableObject [SerializeField] private float currentSpeed = 5f; + public Vector2 playerPosition; + public float getCurrentHealth(){ return currentHealth; }