MOD: Zweite variante an Gegnern

This commit is contained in:
Marvin Schneider 2024-09-05 21:10:50 +02:00
parent 1eeafca3f2
commit 5a92744ee1
47 changed files with 1344 additions and 0 deletions

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 82bf254122ef80449b51a95c33815d86
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9ee5721d58b55084a940198d9fd3cffc
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 11a55b423f5f68e4a8bcb85bf693a99b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 0b21afa49dff7144b9be39b80f486c31
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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()
{
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6561a2f840bd8224295dc78863baccb8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 910dbf35b889c0246a15e580e0c7e435
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
using UnityEngine;
public abstract class BasicenemyBaseState
{
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1f4c4008ca80ef14f896f45f81438010
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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)
{
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 58629341ddd353743ae4cc1cd1832d73
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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)
{
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4968fa0b37ab5344595f0618dc33c8db
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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)
{
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 53a5e863180374d4c941d8d393df2be2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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);
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 89c349a0b8dd3744ca4a6a956c37a102
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 22a5702fae01e48498253edbe660c009
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 29242ccfd2d49664695ec236149d46c0
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e2b3e57d1c69c284299d86daa82cbdcc
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c7134d437a038a1458826bf4de570aa7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9ede1673960af3e4582a4b2ba5f17687
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d3e10099688917b488b09c4c6f3b52ae
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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;
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ce656df099041f6428dde90080e911ad
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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<Rigidbody2D>();
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()
{
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 22c0ca694b1a3e84fa2124fa4e1bc078
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ca264db2c83738e43bf3ce0c1cb45219
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,11 @@
using UnityEngine;
public abstract class CEBaseState
{
public abstract void EnterState(CEStateManager CornerEnemy);
public abstract void UpdateState(CEStateManager CornerEnemy);
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 91d97a9871ad39e4fba6de98d983afd1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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<CEVariables>();
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);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1c6a537fb83a4324aad655724f2f358d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,18 @@
using UnityEngine;
public class CEPatrolState : CEBaseState
{
CEVariables cEVariables;
public override void EnterState(CEStateManager CornerEnemy)
{
cEVariables = CornerEnemy.GetComponent<CEVariables>();
}
public override void UpdateState(CEStateManager CornerEnemy)
{
CornerEnemy.SwitchState(CornerEnemy.MoveState);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 15346aeec83ab4a419994afa358cef2e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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<CEVariables>();
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();
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 197736bf882dc2d42a124a72702b66f9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 29f4f9763f9d32b42a66f763a69e97d8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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}

View File

@ -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(){

View File

@ -10,6 +10,8 @@ public class Player : ScriptableObject
[SerializeField]
private float currentSpeed = 5f;
public Vector2 playerPosition;
public float getCurrentHealth(){
return currentHealth;
}