Commit 8356dad4 authored by Max's avatar Max
Browse files

Added enemy health scripts, enemies take damage/die if a stone falls on them

parent 217a2f90
......@@ -15,7 +15,7 @@ MonoBehaviour:
isIdle: 0
alertDistance: 10
backToIdleDistance: 15
speed: 3
speed: 1
whatIsGround:
serializedVersion: 2
m_Bits: 256
......@@ -186,7 +186,7 @@ MonoBehaviour:
isIdle: 1
alertDistance: 10
backToIdleDistance: 15
speed: 1
speed: 0.5
whatIsGround:
serializedVersion: 2
m_Bits: 256
......
......@@ -12,6 +12,7 @@ GameObject:
- component: {fileID: 382294967272604786}
- component: {fileID: 382294967272604789}
- component: {fileID: 7926794471850828057}
- component: {fileID: -111158171268748557}
m_Layer: 0
m_Name: Crawler
m_TagString: Untagged
......@@ -126,3 +127,19 @@ BoxCollider2D:
serializedVersion: 2
m_Size: {x: 1, y: 1}
m_EdgeRadius: 0
--- !u!114 &-111158171268748557
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 382294967272604784}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 881bc08784fef3a4eb8ed70cbdc48ea5, type: 3}
m_Name:
m_EditorClassIdentifier:
deathParticlePrefab: {fileID: 3659447474157512490, guid: 855f44ca275592447969fa22a87ae0ba,
type: 3}
healthPoints: 1
stoneLayer: 8
......@@ -12,6 +12,7 @@ GameObject:
- component: {fileID: 8955553666151367596}
- component: {fileID: 8955553666151367597}
- component: {fileID: 8955553666151367587}
- component: {fileID: -3949400525136398494}
m_Layer: 13
m_Name: Giant Mushroom
m_TagString: Untagged
......@@ -126,3 +127,19 @@ Animator:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0
--- !u!114 &-3949400525136398494
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8955553666151367599}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 881bc08784fef3a4eb8ed70cbdc48ea5, type: 3}
m_Name:
m_EditorClassIdentifier:
deathParticlePrefab: {fileID: 3659447474157512490, guid: 855f44ca275592447969fa22a87ae0ba,
type: 3}
healthPoints: 1
stoneLayer: 8
......@@ -12,6 +12,7 @@ GameObject:
- component: {fileID: 258479075904060254}
- component: {fileID: 258479075904060253}
- component: {fileID: 2498483169841620389}
- component: {fileID: 7109203871868091221}
m_Layer: 31
m_Name: Shroombie
m_TagString: Untagged
......@@ -126,3 +127,19 @@ BoxCollider2D:
serializedVersion: 2
m_Size: {x: 1, y: 1}
m_EdgeRadius: 0
--- !u!114 &7109203871868091221
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 258479075904060248}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 881bc08784fef3a4eb8ed70cbdc48ea5, type: 3}
m_Name:
m_EditorClassIdentifier:
deathParticlePrefab: {fileID: 3659447474157512490, guid: 855f44ca275592447969fa22a87ae0ba,
type: 3}
healthPoints: 1
stoneLayer: 8
......@@ -151,7 +151,7 @@ Transform:
- {fileID: 671354061}
- {fileID: 1652412121}
m_Father: {fileID: 0}
m_RootOrder: 1
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &225743466
GameObject:
......@@ -565,7 +565,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!95 &382514593
Animator:
......@@ -586,6 +586,85 @@ Animator:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0
--- !u!1001 &413952538
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 2410282298153064044, guid: 504d671a4858dbe4cb1f3c567bb881b4,
type: 3}
propertyPath: m_Name
value: TestStone
objectReference: {fileID: 0}
- target: {fileID: 1088708388262890221, guid: 504d671a4858dbe4cb1f3c567bb881b4,
type: 3}
propertyPath: m_LocalPosition.x
value: 17
objectReference: {fileID: 0}
- target: {fileID: 1088708388262890221, guid: 504d671a4858dbe4cb1f3c567bb881b4,
type: 3}
propertyPath: m_LocalPosition.y
value: -3.5
objectReference: {fileID: 0}
- target: {fileID: 1088708388262890221, guid: 504d671a4858dbe4cb1f3c567bb881b4,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1088708388262890221, guid: 504d671a4858dbe4cb1f3c567bb881b4,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1088708388262890221, guid: 504d671a4858dbe4cb1f3c567bb881b4,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1088708388262890221, guid: 504d671a4858dbe4cb1f3c567bb881b4,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1088708388262890221, guid: 504d671a4858dbe4cb1f3c567bb881b4,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1088708388262890221, guid: 504d671a4858dbe4cb1f3c567bb881b4,
type: 3}
propertyPath: m_RootOrder
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1088708388262890221, guid: 504d671a4858dbe4cb1f3c567bb881b4,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1088708388262890221, guid: 504d671a4858dbe4cb1f3c567bb881b4,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1088708388262890221, guid: 504d671a4858dbe4cb1f3c567bb881b4,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1088708388262890221, guid: 504d671a4858dbe4cb1f3c567bb881b4,
type: 3}
propertyPath: m_LocalScale.x
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1088708388262890221, guid: 504d671a4858dbe4cb1f3c567bb881b4,
type: 3}
propertyPath: m_LocalScale.y
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 504d671a4858dbe4cb1f3c567bb881b4, type: 3}
--- !u!1 &445195221
GameObject:
m_ObjectHideFlags: 0
......@@ -1625,6 +1704,16 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 3724751736021467387, guid: a1e0107a2375e1140a669c1da0647f9a,
type: 3}
propertyPath: m_LocalPosition.x
value: -0.05
objectReference: {fileID: 0}
- target: {fileID: 3724751736021467387, guid: a1e0107a2375e1140a669c1da0647f9a,
type: 3}
propertyPath: m_LocalPosition.y
value: 2.15
objectReference: {fileID: 0}
- target: {fileID: 264577551908436831, guid: a1e0107a2375e1140a669c1da0647f9a,
type: 3}
propertyPath: m_Name
......@@ -2594,7 +2683,7 @@ Transform:
- {fileID: 1761456133}
- {fileID: 754269808}
m_Father: {fileID: 0}
m_RootOrder: 2
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &1761456133 stripped
Transform:
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyHealth : MonoBehaviour
{
//Partikel, die beim Tod erscheinen
public GameObject deathParticlePrefab;
//Leben der Gegner
public int healthPoints;
public int stoneLayer;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if(healthPoints <= 0)
{
Instantiate(deathParticlePrefab, transform.position, Quaternion.identity);
Destroy(gameObject);
}
}
private void OnCollisionEnter2D(Collision2D other)
{
//wenn Stein von oben auf den Gegner fällt, dann Schaden machen
if (other.gameObject.layer == stoneLayer && other.gameObject.transform.position.y - transform.position.y > 1)
{
healthPoints--;
}
}
}
fileFormatVersion: 2
guid: 881bc08784fef3a4eb8ed70cbdc48ea5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment