optimized level, updated shooting system, and fixed enemy death still causing damage bug
This commit is contained in:
@ -46,6 +46,11 @@ public class SkinlessMonsterComponent : MonoBehaviour
|
||||
private InGameManager manager;
|
||||
private bool prePauseStoppedState = false;
|
||||
|
||||
[SerializeField]
|
||||
private BoxCollider leftHandDamage;
|
||||
[SerializeField]
|
||||
private BoxCollider rightHandDamage;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
//Find active player rn.
|
||||
@ -310,7 +315,11 @@ public class SkinlessMonsterComponent : MonoBehaviour
|
||||
if(isAlive&&player.IsAlive)
|
||||
SetLiveTargeting();
|
||||
timeSinceTarget += Time.deltaTime;
|
||||
|
||||
if (this.isAlive)
|
||||
{
|
||||
leftHandDamage.enabled = false;
|
||||
rightHandDamage.enabled = false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
@ -28,6 +28,7 @@ public class InGameMenuManager : MonoBehaviour
|
||||
}
|
||||
void SettingsUnClicked()
|
||||
{
|
||||
|
||||
menuAnimator.SetBool("SettingsOpen", false);
|
||||
}
|
||||
public void UpdateSensitivity()
|
||||
|
54
Assets/Scripts/Game/Optimizer.cs
Normal file
54
Assets/Scripts/Game/Optimizer.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Attach this behavior to a master room collider. Enables everything in this room OnTriggerEnter of [tag]
|
||||
/// disables everything in this room OnTriggerExit of [tag]
|
||||
/// </summary>
|
||||
public class Optimizer : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
public string Tag;
|
||||
[SerializeField]
|
||||
private GameObject[] references;
|
||||
[SerializeField]
|
||||
private bool beginDisabled = true;
|
||||
private void Start()
|
||||
{
|
||||
if (beginDisabled)
|
||||
{
|
||||
Disable();
|
||||
}
|
||||
}
|
||||
public void Enable()
|
||||
{
|
||||
foreach (GameObject go in references)
|
||||
{
|
||||
go.SetActive(true);
|
||||
}
|
||||
}
|
||||
public void Disable()
|
||||
{
|
||||
foreach (GameObject go in references)
|
||||
{
|
||||
go.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.CompareTag(Tag))
|
||||
{
|
||||
Enable();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
if (other.CompareTag(Tag))
|
||||
{
|
||||
Disable();
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Game/Optimizer.cs.meta
Normal file
11
Assets/Scripts/Game/Optimizer.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce10ec9aaa603bb4da9dfadd6e590584
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -25,9 +25,11 @@ public class PistolComponent : MonoBehaviour
|
||||
private float firePower = 20f;
|
||||
[SerializeField]
|
||||
private float maxProjectileDuration = 5f;
|
||||
[SerializeField]
|
||||
private float maxTargetObjDistance = 15f;
|
||||
|
||||
|
||||
|
||||
private bool hasCloseTarget = false;
|
||||
|
||||
//private Dictionary<int,float> projectiles = new Dictionary<int, float>();
|
||||
|
||||
@ -59,16 +61,41 @@ public class PistolComponent : MonoBehaviour
|
||||
}
|
||||
private void FixedUpdate()
|
||||
{
|
||||
|
||||
if (this.IsEnabled)
|
||||
{
|
||||
Ray ray = new Ray(transform.position, transform.up);
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(ray, out hit, 50))
|
||||
{
|
||||
targetObject.gameObject.transform.position = hit.point;
|
||||
float drop = CalculateDrop(this.bulletSpawnPoint.position, hit.point, this.transform.up * this.firePower);
|
||||
//print(drop);
|
||||
|
||||
float hitDist = Vector3.Distance(hit.point, transform.position);
|
||||
if (hitDist < maxTargetObjDistance)
|
||||
{
|
||||
targetObject.gameObject.transform.position = hit.point;
|
||||
|
||||
targetObject.gameObject.GetComponent<MeshRenderer>().materials[0].SetColor("_EmissiveColor", new Color(255, 0,0));
|
||||
//Track if we have a close target
|
||||
hasCloseTarget = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetObject.gameObject.transform.position = transform.position + (ray.direction * maxTargetObjDistance);
|
||||
|
||||
targetObject.gameObject.GetComponent<MeshRenderer>().materials[0].SetColor("_EmissiveColor", new Color(255, 255,255));
|
||||
//Track if we have a close target
|
||||
hasCloseTarget = false;
|
||||
}
|
||||
//float drop = CalculateDrop(this.bulletSpawnPoint.position, hit.point, this.transform.up * this.firePower);
|
||||
//print(drop);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
targetObject.gameObject.transform.position = transform.position + (ray.direction * maxTargetObjDistance);
|
||||
|
||||
targetObject.gameObject.GetComponent<MeshRenderer>().materials[0].SetColor("_EmissiveColor", new Color(255,255,255));
|
||||
hasCloseTarget = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,6 +104,10 @@ public class PistolComponent : MonoBehaviour
|
||||
|
||||
}
|
||||
public void Fire()
|
||||
{
|
||||
Fire(!hasCloseTarget);
|
||||
}
|
||||
public void Fire(bool offsetWithTargetBall)
|
||||
{
|
||||
|
||||
GameObject projectile = Instantiate(projectilePrefab, this.bulletSpawnPoint);
|
||||
@ -84,7 +115,29 @@ public class PistolComponent : MonoBehaviour
|
||||
projectile.transform.localEulerAngles = Vector3.zero;
|
||||
projectile.transform.localScale = Vector3.one;
|
||||
Rigidbody pRigid = projectile.GetComponent<Rigidbody>();
|
||||
pRigid.AddForce(pRigid.transform.up*this.firePower, ForceMode.Impulse);
|
||||
|
||||
/*Modified targeting system
|
||||
1. Since aim direction is vector from camera to ball (where player thinks its gonna go), raycast forward there, till hit. If no hit,
|
||||
then set target distance to ~50.
|
||||
2. Modify launch vector apply modified force
|
||||
*/
|
||||
Vector3 launchVector = pRigid.transform.up * this.firePower;
|
||||
|
||||
if(offsetWithTargetBall)
|
||||
{
|
||||
Vector3 ballCamVector = targetObject.transform.position - this.GetComponentInParent<PlayerMovementController>().cam.transform.position;
|
||||
Ray r = new Ray();
|
||||
r.origin = targetObject.transform.position;
|
||||
r.direction = ballCamVector.normalized;
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(r,out hit))
|
||||
{
|
||||
launchVector = (hit.point - pRigid.transform.position).normalized;
|
||||
launchVector *= this.firePower;
|
||||
}
|
||||
}
|
||||
|
||||
pRigid.AddForce(launchVector, ForceMode.Impulse);
|
||||
projectile.transform.parent = null;
|
||||
|
||||
|
||||
|
@ -39,6 +39,8 @@ public class LevelZeroSpecial : MonoBehaviour
|
||||
WaypointMarker marker2Ref;
|
||||
[SerializeField]
|
||||
WaypointMarker marker3Ref;
|
||||
[SerializeField]
|
||||
private Optimizer finalRoomOptimizer;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
@ -102,6 +104,7 @@ public class LevelZeroSpecial : MonoBehaviour
|
||||
|
||||
transitioningOut = true;
|
||||
gate.Play("Open");
|
||||
finalRoomOptimizer.Enable();
|
||||
|
||||
}
|
||||
if (transitioningOut)
|
||||
|
@ -12,6 +12,8 @@ public class CameraController : MonoBehaviour
|
||||
private float mouseY;
|
||||
[SerializeField]
|
||||
private Camera cam;
|
||||
|
||||
|
||||
[SerializeField]
|
||||
private Transform target;
|
||||
|
||||
|
@ -30,7 +30,7 @@ public class PlayerMovementController : MonoBehaviour
|
||||
[SerializeField]
|
||||
private float animatedRotationSpeed = 5f;
|
||||
[SerializeField]
|
||||
private Camera cam;
|
||||
public Camera cam;
|
||||
|
||||
[HideInInspector]
|
||||
public bool AllowRotation = false;
|
||||
|
Reference in New Issue
Block a user