This commit is contained in:
Kotrba Filip
2020-02-01 08:52:46 +01:00
parent 7316eb6477
commit a787aa09a3
24 changed files with 1434 additions and 17 deletions

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

View File

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

View File

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

View File

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