tnt graphics, bug fixes, folder organization
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class Flashlight : Tool
|
||||
{
|
||||
[Header("Flashlight Parameters")]
|
||||
public Light lightSrc;
|
||||
|
||||
public override void Use()
|
||||
{
|
||||
lightSrc.enabled = !lightSrc.enabled;
|
||||
}
|
||||
|
||||
public override void UseAlt()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: edd0364a446d1fd489dd8bbb53de613a
|
||||
@@ -0,0 +1,27 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class Shovel : Tool
|
||||
{
|
||||
[Header("Shovel Parameters")]
|
||||
public Animator shovelAnimator;
|
||||
|
||||
public override void Use()
|
||||
{
|
||||
shovelAnimator.SetTrigger("Dig");
|
||||
}
|
||||
|
||||
public override void UseAlt()
|
||||
{
|
||||
// no tool
|
||||
}
|
||||
|
||||
// this only works if this script is sitting on the object with the collider!!
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
Diggable diggable = other.GetComponent<Diggable>();
|
||||
if (diggable != null)
|
||||
{
|
||||
diggable.Dig();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 21ea1f4973209f34aa1bfb2f1dda5454
|
||||
@@ -0,0 +1,86 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
using static UnityEngine.GraphicsBuffer;
|
||||
|
||||
public class ThrowableHand : Tool
|
||||
{
|
||||
[Header("Throwable Hand Parameters")]
|
||||
public float range;
|
||||
public float forceModifier;
|
||||
public float loft;
|
||||
public GameObject testBomb;
|
||||
|
||||
// Mathematical plane used to catch the raycast from camera to get direction for
|
||||
// looking at the mouse
|
||||
private Plane handGroundPlane;
|
||||
private DecalProjector targetProjection;
|
||||
private float throwForce;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (GameManager.Instance.GetPlayerController() != null)
|
||||
{
|
||||
SetGroundPlane();
|
||||
DrawTargetProjection();
|
||||
}
|
||||
}
|
||||
|
||||
private void SetGroundPlane()
|
||||
{
|
||||
if (handGroundPlane == null)
|
||||
{
|
||||
handGroundPlane = new Plane(Vector3.up, -GameManager.Instance.GetPlayerController().DougBody.transform.position.y);
|
||||
}
|
||||
|
||||
handGroundPlane.distance = -GameManager.Instance.GetPlayerController().DougBody.transform.position.y;
|
||||
handGroundPlane.normal = Vector3.up;
|
||||
}
|
||||
|
||||
private void DrawTargetProjection()
|
||||
{
|
||||
if (targetProjection == null)
|
||||
{
|
||||
targetProjection = GetComponentInChildren<DecalProjector>();
|
||||
}
|
||||
|
||||
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
|
||||
if (handGroundPlane.Raycast(ray, out var distance))
|
||||
{
|
||||
Vector3 hitPoint = ray.GetPoint(distance);
|
||||
|
||||
float distanceFromPoint = Vector3.Distance(hitPoint, transform.position);
|
||||
if (distanceFromPoint > range)
|
||||
{
|
||||
Vector3 directionTowardMouse = (hitPoint - transform.position).normalized;
|
||||
targetProjection.transform.position = new Vector3(transform.position.x, hitPoint.y, transform.position.z);
|
||||
targetProjection.transform.position += directionTowardMouse * range;
|
||||
|
||||
throwForce = range;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetProjection.gameObject.SetActive(true);
|
||||
targetProjection.transform.position = hitPoint;
|
||||
throwForce = distanceFromPoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Use()
|
||||
{
|
||||
GameObject newBomb = Instantiate(testBomb);
|
||||
newBomb.transform.position = transform.position;
|
||||
|
||||
Vector3 direction = transform.forward * throwForce * forceModifier;
|
||||
direction += GameManager.Instance.GetPlayerController().GetVelocity();
|
||||
direction.y = loft;
|
||||
|
||||
newBomb.GetComponent<Rigidbody>().AddForce(direction, ForceMode.Impulse);
|
||||
}
|
||||
|
||||
public override void UseAlt()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fe5aedf75d904534296ad0d07fe55622
|
||||
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class Tool : MonoBehaviour
|
||||
{
|
||||
|
||||
[Header("Base Tool Parameters")]
|
||||
public float useTimeSec;
|
||||
public float altUseTimeSec;
|
||||
public bool inUse;
|
||||
|
||||
// primary (left click)
|
||||
public abstract void Use();
|
||||
|
||||
// secondary (right click)
|
||||
public abstract void UseAlt();
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 72d72769aaaeff0479ea6b811b94d1df
|
||||
Reference in New Issue
Block a user