commit 500
This commit is contained in:
@@ -132,4 +132,21 @@ public class BlockManager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnTriggerEnter(Collider collider)
|
||||
{
|
||||
if (blockType == BlockType.Barricade) {
|
||||
Debug.Log(collider.transform.tag);
|
||||
if (collider.transform.CompareTag("Enemy"))
|
||||
{
|
||||
EnemyManager enemyManager = collider.transform.GetComponent<EnemyManager>();
|
||||
if (enemyManager != null)
|
||||
{
|
||||
enemyManager.Damage(100);
|
||||
health = 0;
|
||||
Destroy(this.gameObject, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -47,7 +47,7 @@ public class EnemyManager : MonoBehaviour
|
||||
|
||||
void FixedUpdate()
|
||||
{
|
||||
if (navMeshAgent.pathStatus == NavMeshPathStatus.PathComplete)
|
||||
if (navMeshAgent != null && navMeshAgent.pathStatus == NavMeshPathStatus.PathComplete)
|
||||
{
|
||||
if (actualHealth > 0 && barricadeManager == null)
|
||||
{
|
||||
@@ -64,11 +64,17 @@ public class EnemyManager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public void Damage()
|
||||
public void Damage(float damageLoc = 0)
|
||||
{
|
||||
WeaponManager weaponManager = player.weaponList[player.selectedWeapon].GetComponent<WeaponManager>();
|
||||
if (weaponManager != null) {
|
||||
actualHealth -= weaponManager.damage;
|
||||
if (damageLoc == 0) {
|
||||
WeaponManager weaponManager = player.weaponList[player.selectedWeapon].GetComponent<WeaponManager>();
|
||||
if (weaponManager != null) {
|
||||
actualHealth -= weaponManager.damage;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
actualHealth -= damageLoc;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +159,7 @@ public class EnemyManager : MonoBehaviour
|
||||
void Attack()
|
||||
{
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(transform.position + new Vector3(0,0.5f,0),transform.forward,out hit,2) && attackTime <= Time.time)
|
||||
if (Physics.Raycast(transform.position + new Vector3(0,0.5f,0),transform.forward,out hit,1.5f) && attackTime <= Time.time)
|
||||
{
|
||||
if (hit.transform.CompareTag("Player"))
|
||||
{
|
||||
@@ -182,10 +188,14 @@ public class EnemyManager : MonoBehaviour
|
||||
|
||||
void OnTriggerEnter(Collider collider)
|
||||
{
|
||||
Debug.Log(collider.transform.tag);
|
||||
if (collider.transform.CompareTag("Meele"))
|
||||
{
|
||||
Damage();
|
||||
|
||||
WeaponManager weaponManager = collider.transform.GetComponent<WeaponManager>();
|
||||
if (weaponManager != null && weaponManager.hit) {
|
||||
Damage();
|
||||
weaponManager.hit = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -21,8 +21,12 @@ public class GuiManager : MonoBehaviour
|
||||
|
||||
}
|
||||
|
||||
public void InteractVerifier(bool set)
|
||||
public void InteractVerifier(bool set, Sprite image = null)
|
||||
{
|
||||
InteractIcon.SetActive(set);
|
||||
if (image != null)
|
||||
{
|
||||
InteractIcon.GetComponent<Image>().sprite = image;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
43
Assets/Scripts/NightDayParticles.cs
Normal file
43
Assets/Scripts/NightDayParticles.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class NightDayParticles : MonoBehaviour
|
||||
{
|
||||
public GameObject parentParticle;
|
||||
public bool activeInDay = false;
|
||||
public bool activeInNight = false;
|
||||
public DayManager dayManager;
|
||||
bool night = false;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
float sunRotationX = dayManager.transform.localEulerAngles.x;
|
||||
sunRotationX = (sunRotationX > 180) ? sunRotationX - 360 : sunRotationX;
|
||||
|
||||
if (sunRotationX < 0 && !night)
|
||||
{
|
||||
night = true;
|
||||
}
|
||||
else if (sunRotationX > 0 && night)
|
||||
{
|
||||
night = false;
|
||||
}
|
||||
|
||||
if ((activeInDay && !night) || (activeInNight && night))
|
||||
{
|
||||
parentParticle.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
parentParticle.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/NightDayParticles.cs.meta
Normal file
11
Assets/Scripts/NightDayParticles.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0314a14d6c40f643bdaaf2fb3e0228d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -21,6 +21,9 @@ public class PlayerManager : MonoBehaviour
|
||||
public int ammo = 50;
|
||||
public List<GameObject> weaponList = new List<GameObject>();
|
||||
private GameObject createWeapon;
|
||||
public GameObject spikes;
|
||||
public Sprite spikesImage;
|
||||
public Sprite handImage;
|
||||
public GuiManager guiManager;
|
||||
public int selectedWeapon = 0;
|
||||
private float selectRate = 1;
|
||||
@@ -47,7 +50,6 @@ public class PlayerManager : MonoBehaviour
|
||||
Move();
|
||||
RunSwitch();
|
||||
SelectWeapon();
|
||||
BuildBlock();
|
||||
Interact();
|
||||
|
||||
if (actualHealth <= 0)
|
||||
@@ -178,36 +180,30 @@ public class PlayerManager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
void BuildBlock ()
|
||||
{
|
||||
if (Input.GetAxisRaw("Fire1") > 0 && buildTime < Time.time && weaponList.Count > 0)
|
||||
{
|
||||
Ray ray = playerCamera.ScreenPointToRay(Input.mousePosition);
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(ray, out hit, Mathf.Infinity, LayerMask.GetMask("BuildPlace")))
|
||||
{
|
||||
BlockManager blockManager = weaponList[selectedWeapon].GetComponent<BlockManager>();
|
||||
if (blockManager != null) {
|
||||
Instantiate(weaponList[selectedWeapon], hit.point, transform.rotation);
|
||||
buildTime = buildRate + Time.time;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Interact()
|
||||
{
|
||||
Ray ray = playerCamera.ScreenPointToRay(Input.mousePosition);
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(ray, out hit, 2))
|
||||
{
|
||||
if (hit.transform.CompareTag("BarricadeField") || hit.transform.CompareTag("Interact"))
|
||||
if (hit.transform.CompareTag("BarricadeField") || hit.transform.CompareTag("Interact") || hit.transform.gameObject.layer == LayerMask.NameToLayer("BuildPlace"))
|
||||
{
|
||||
guiManager.InteractVerifier(true);
|
||||
BlockManager blockManager = hit.transform.GetComponent<BlockManager>();
|
||||
if (blockManager == null || blockManager.blockType != BlockManager.BlockType.Barricade) {
|
||||
guiManager.InteractVerifier(true, handImage);
|
||||
if (hit.transform.gameObject.layer == LayerMask.NameToLayer("BuildPlace"))
|
||||
{
|
||||
guiManager.InteractVerifier(true, spikesImage);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
guiManager.InteractVerifier(false, handImage);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
guiManager.InteractVerifier(false);
|
||||
guiManager.InteractVerifier(false, handImage);
|
||||
}
|
||||
if (Input.GetAxisRaw("Build") > 0 && buildTime < Time.time && barricadeMaterials > 0 && hit.transform.tag == "BarricadeField")
|
||||
{
|
||||
@@ -226,7 +222,15 @@ public class PlayerManager : MonoBehaviour
|
||||
{
|
||||
BlockManager blockManager = hit.transform.GetComponent<BlockManager>();
|
||||
blockManager.Action();
|
||||
|
||||
}
|
||||
else if (hit.transform.gameObject.layer == LayerMask.NameToLayer("BuildPlace") && Input.GetKeyDown(KeyCode.E) && buildTime < Time.time)
|
||||
{
|
||||
BlockManager blockManager = spikes.GetComponent<BlockManager>();
|
||||
if (blockManager != null)
|
||||
{
|
||||
Instantiate<GameObject>(spikes, hit.point, transform.rotation);
|
||||
buildTime = buildRate + Time.time;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@@ -47,19 +47,15 @@ public class WeaponManager : MonoBehaviour
|
||||
}
|
||||
else if (weaponType == WeaponType.Meele)
|
||||
{
|
||||
hit = true;
|
||||
animator.ResetTrigger("Hit");
|
||||
animator.SetTrigger("Hit");
|
||||
fireTime = fireRate + Time.time;
|
||||
}
|
||||
}
|
||||
}
|
||||
void Hit_Enemy_Start()
|
||||
{
|
||||
hit = true;
|
||||
}
|
||||
|
||||
void Hit_Enemy_End()
|
||||
{
|
||||
hit = false;
|
||||
if (fireTime <= Time.time)
|
||||
{
|
||||
hit = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user