Add project files.

This commit is contained in:
caleb Sandford DeQuincey
2025-10-27 17:05:16 +00:00
parent 93cec4de9e
commit 36f31d54d1
7970 changed files with 2179811 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 693a5171faa224c46a992c9c1ccee87d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
using UnityEngine;
using RPG.Combat;
public class CombatTarget : MonoBehaviour
{
// This class is intentionally left empty.
// It serves as a marker to identify combat targets in the game.
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: b8654c3b7c55a404fbedd3d1b66415f2

View File

@@ -0,0 +1,22 @@
using UnityEngine;
using RPG.Movement;
namespace RPG.Combat
{
public class Fighter : MonoBehaviour
{
Transform target;
private void Update()
{
if(target != null)
{
GetComponent<Mover>().MoveTo(target.position);
target = null;
}
}
public void Attack(CombatTarget combatTarget)
{
target = combatTarget.transform;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 0dac85c6432a11746b07d2f6a021e2e4

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 04f126232ba345441abb1a3fe3ca806d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,75 @@
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.InputSystem;
using RPG.Movement;
using RPG.Combat;
using System;
namespace RPG.Control
{
public class PlayerController : MonoBehaviour
{
private PlayerControls playerControls;
private InputAction moveAction;
private InputAction interactAction;
private Camera mainCamera;
private void Awake()
{
playerControls = new PlayerControls();
moveAction = playerControls.Player.Move;
interactAction = playerControls.Player.Action;
mainCamera = Camera.main;
}
private void OnEnable()
{
moveAction.Enable();
interactAction.Enable();
}
private void OnDisable()
{
moveAction.Disable();
interactAction.Disable();
}
private void Update()
{
if (InteractWithCombat()) return;
if (InteractWithMovement()) return;
}
private bool InteractWithCombat()
{
RaycastHit[] hits = Physics.RaycastAll(GetMouseRay());
foreach (RaycastHit hit in hits)
{
CombatTarget target = hit.transform.GetComponent<CombatTarget>();
if (target == null) continue;
if (interactAction.WasPressedThisFrame())
{
//MoveToCursor();
GetComponent<Fighter>().Attack(target);
}
return true;
}
return false;
}
private bool InteractWithMovement()
{
RaycastHit hit;
bool hasHit = Physics.Raycast(GetMouseRay(), out hit);
if (hasHit)
{
if (moveAction.IsPressed())
GetComponent<Mover>().MoveTo(hit.point);
return true;
}
return false;
}
private Ray GetMouseRay()
{
return mainCamera.ScreenPointToRay(Mouse.current.position.ReadValue());
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: a8218d52e9da57343b0e14cd0a1af897

8
Assets/Scripts/Core.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2d6fe9a4109216047b65d5a73e659d70
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,14 @@
using UnityEngine;
namespace RPG.Core
{
public class FollowCamera : MonoBehaviour
{
[SerializeField] Transform target;
void LateUpdate()
{
transform.position = target.position;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: bc35952d43d5ef444a4da8f0fdf4d488

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 20e5e08225415394989e0b790f460a71
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,42 @@
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.InputSystem;
namespace RPG.Movement
{
public class Mover : MonoBehaviour
{
[SerializeField] private Transform target;
// Cache components for performance
private NavMeshAgent navMeshAgent;
private Animator animator;
private void Awake()
{
// Get component references once
navMeshAgent = GetComponent<NavMeshAgent>();
animator = GetComponent<Animator>();
}
void Update()
{
UpdateAnimator();
}
public void MoveTo(Vector3 destination)
{
navMeshAgent.destination = destination;
}
private void UpdateAnimator()
{
// This is your original code, which is correct!
// It just uses the cached variables now.
Vector3 velocity = navMeshAgent.velocity;
Vector3 localVelocity = transform.InverseTransformDirection(velocity);
float speed = localVelocity.z;
animator.SetFloat("forwardSpeed", speed);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 99048001b4ebc1543911415b71049d4a