Zombie 1
This commit is contained in:
44
Assets/Scripts/EnemyManager.cs
Normal file
44
Assets/Scripts/EnemyManager.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
public class EnemyManager : MonoBehaviour
|
||||
{
|
||||
public float health = 100;
|
||||
private NavMeshAgent navMeshAgent;
|
||||
private PlayerManager player;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
player = FindObjectOfType<PlayerManager>();
|
||||
navMeshAgent = GetComponent<NavMeshAgent>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
navMeshAgent.SetDestination(player.transform.position);
|
||||
if (health <= 0)
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public void Damage()
|
||||
{
|
||||
WeaponManager weaponManager = player.weaponList[player.selectedWeapon].GetComponent<WeaponManager>();
|
||||
if (weaponManager != null) {
|
||||
health -= weaponManager.damage;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnParticleCollision(GameObject other)
|
||||
{
|
||||
if (other.transform.tag == "Bullets")
|
||||
{
|
||||
Damage();
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/EnemyManager.cs.meta
Normal file
11
Assets/Scripts/EnemyManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 90b7fc8866f905646bc8b17282c9c521
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -56,6 +56,7 @@ public class PlayerManager : MonoBehaviour
|
||||
|
||||
void Rotate()
|
||||
{
|
||||
rigidBody.freezeRotation = false;
|
||||
transform.Rotate(new Vector3(0, rotateSpeed * Input.GetAxis("Mouse X") * mouseSensitive * Time.deltaTime, 0));
|
||||
if (
|
||||
((playerCamera.transform.localEulerAngles.x >= 270 && playerCamera.transform.localEulerAngles.x <= 360) &&
|
||||
@@ -83,6 +84,7 @@ public class PlayerManager : MonoBehaviour
|
||||
{
|
||||
playerCamera.transform.Rotate(new Vector3(rotateSpeed * -Input.GetAxis("Mouse Y") * mouseSensitive * Time.deltaTime, 0, 0));
|
||||
}
|
||||
rigidBody.freezeRotation = true;
|
||||
}
|
||||
|
||||
void RunSwitch()
|
||||
|
@@ -32,7 +32,6 @@ public class WeaponManager : MonoBehaviour
|
||||
{
|
||||
if (particleShoot != null)
|
||||
{
|
||||
Debug.Log(transform.position);
|
||||
GameObject shoot = Instantiate(particleShoot, spawnShoot.transform.position, spawnShoot.transform.rotation);
|
||||
Destroy(shoot, 0.3f);
|
||||
}
|
||||
|
Reference in New Issue
Block a user