EnemyScript erstellt für das UI Element KillCounter
This commit is contained in:
@@ -20,6 +20,10 @@ public class BulletScript : MonoBehaviour
|
||||
private Ray ray;
|
||||
private RaycastHit hit;
|
||||
|
||||
public void damageEnemy(float damageAmount){
|
||||
|
||||
}
|
||||
|
||||
private void die(float lifetime){
|
||||
if(time > lifetime){
|
||||
GameObject.Destroy(this.gameObject);
|
||||
@@ -31,7 +35,7 @@ public class BulletScript : MonoBehaviour
|
||||
}
|
||||
}
|
||||
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);
|
||||
Instantiate(particalClash,transform.position,Quaternion.LookRotation(contact.normal));
|
||||
GameObject.Destroy(this.gameObject);
|
||||
|
12
Plunderblock/Assets/Scripts/ScriptsKevin/DataEnemy.cs
Normal file
12
Plunderblock/Assets/Scripts/ScriptsKevin/DataEnemy.cs
Normal 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;
|
||||
|
||||
}
|
11
Plunderblock/Assets/Scripts/ScriptsKevin/DataEnemy.cs.meta
Normal file
11
Plunderblock/Assets/Scripts/ScriptsKevin/DataEnemy.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9a476e53f7c21af43b8fb3b00b60c337
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
37
Plunderblock/Assets/Scripts/ScriptsKevin/Enemy.cs
Normal file
37
Plunderblock/Assets/Scripts/ScriptsKevin/Enemy.cs
Normal 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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
11
Plunderblock/Assets/Scripts/ScriptsKevin/Enemy.cs.meta
Normal file
11
Plunderblock/Assets/Scripts/ScriptsKevin/Enemy.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 853ef1d1386dff846a0bcc37b58022ef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -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
|
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 725a3f209282b5e43aae5cd12fce2234
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user