EnemyScript erstellt für das UI Element KillCounter

This commit is contained in:
pbg2h23akl 2024-06-27 08:55:02 +02:00
parent 6242c69919
commit 36d4d1c9b6
12 changed files with 395 additions and 3 deletions

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

View File

@ -0,0 +1,114 @@
fileFormatVersion: 2
guid: 1bfe96be0343cfb4cafcedd7c2ab75c3
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -303,6 +303,81 @@ MeshFilter:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 322531732} m_GameObject: {fileID: 322531732}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &747170971
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 747170972}
- component: {fileID: 747170974}
- component: {fileID: 747170973}
m_Layer: 5
m_Name: KillCounterImage
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &747170972
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 747170971}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.51208, y: 0.51208, z: 0.51208}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1178726364}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 474.6, y: 117.7}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &747170973
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 747170971}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 1bfe96be0343cfb4cafcedd7c2ab75c3, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &747170974
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 747170971}
m_CullTransparentMesh: 1
--- !u!1 &834183076 --- !u!1 &834183076
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -690,9 +765,10 @@ GameObject:
- component: {fileID: 1062964500} - component: {fileID: 1062964500}
- component: {fileID: 1062964499} - component: {fileID: 1062964499}
- component: {fileID: 1062964498} - component: {fileID: 1062964498}
- component: {fileID: 1062964502}
m_Layer: 0 m_Layer: 0
m_Name: Sphere m_Name: Enemy
m_TagString: Untagged m_TagString: Enemy
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
@ -783,6 +859,19 @@ Transform:
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1062964502
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1062964497}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 853ef1d1386dff846a0bcc37b58022ef, type: 3}
m_Name:
m_EditorClassIdentifier:
dataEnemy: {fileID: 11400000, guid: 725a3f209282b5e43aae5cd12fce2234, type: 2}
--- !u!4 &1091931327 stripped --- !u!4 &1091931327 stripped
Transform: Transform:
m_CorrespondingSourceObject: {fileID: 6798321073873421098, guid: 4d3459d3c81134641b756c0c5205d59e, type: 3} m_CorrespondingSourceObject: {fileID: 6798321073873421098, guid: 4d3459d3c81134641b756c0c5205d59e, type: 3}
@ -924,7 +1013,9 @@ RectTransform:
m_LocalScale: {x: 0, y: 0, z: 0} m_LocalScale: {x: 0, y: 0, z: 0}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 747170972}
- {fileID: 63850010} - {fileID: 63850010}
- {fileID: 1552423893}
m_Father: {fileID: 1261709731} m_Father: {fileID: 1261709731}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
@ -1281,6 +1372,85 @@ Transform:
- {fileID: 1261709731} - {fileID: 1261709731}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 85.23, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 85.23, z: 0}
--- !u!1 &1552423892
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1552423893}
- component: {fileID: 1552423895}
- component: {fileID: 1552423894}
m_Layer: 5
m_Name: AnzahlKills
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1552423893
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1552423892}
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: 1178726364}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 571.9, y: 86.9}
m_SizeDelta: {x: 134.5, y: 109.16}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1552423894
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1552423892}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 46
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 6
m_MaxSize: 60
m_Alignment: 0
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: 0
--- !u!222 &1552423895
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1552423892}
m_CullTransparentMesh: 1
--- !u!1 &1651397764 --- !u!1 &1651397764
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -20,6 +20,10 @@ public class BulletScript : MonoBehaviour
private Ray ray; private Ray ray;
private RaycastHit hit; private RaycastHit hit;
public void damageEnemy(float damageAmount){
}
private void die(float lifetime){ private void die(float lifetime){
if(time > lifetime){ if(time > lifetime){
GameObject.Destroy(this.gameObject); GameObject.Destroy(this.gameObject);
@ -31,7 +35,7 @@ public class BulletScript : MonoBehaviour
} }
} }
private void OnCollisionEnter(Collision collision){ private void OnCollisionEnter(Collision collision){
Debug.Log(collision.gameObject.name); Debug.Log(collision.gameObject.name + " UND HIER IST DER TAG: " + collision.gameObject.tag);
ContactPoint contact = collision.GetContact(0); ContactPoint contact = collision.GetContact(0);
Instantiate(particalClash,transform.position,Quaternion.LookRotation(contact.normal)); Instantiate(particalClash,transform.position,Quaternion.LookRotation(contact.normal));
GameObject.Destroy(this.gameObject); GameObject.Destroy(this.gameObject);

View File

@ -0,0 +1,12 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "EnemyScriptableObject", order = 2)]
public class DataEnemy : ScriptableObject
{
public float health;
public float damage;
}

View File

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

View File

@ -0,0 +1,37 @@
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
public class Enemy : MonoBehaviour
{
private bool alive = true;
public DataEnemy dataEnemy;
public void checkAlive(bool alive){
if(!alive){
GameObject.Destroy(this.gameObject);
}
}
public void takeDamage(float bulletDamage){
dataEnemy.health = dataEnemy.health - bulletDamage;
if(dataEnemy.health <= 0){
alive = false;
}
}
private void OnCollisionEnter(Collision collision){
DataBullet bulletData = collision.gameObject.GetComponent<DataBullet>();
takeDamage(bulletData.damage);
checkAlive(alive);
}
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

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

View File

@ -0,0 +1,16 @@
%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: 9a476e53f7c21af43b8fb3b00b60c337, type: 3}
m_Name: EnemyScriptableObject
m_EditorClassIdentifier:
health: 20
damage: 2

View File

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

View File

@ -5,6 +5,7 @@ TagManager:
serializedVersion: 2 serializedVersion: 2
tags: tags:
- PlayerView - PlayerView
- Enemy
layers: layers:
- Default - Default
- TransparentFX - TransparentFX