first commit

This commit is contained in:
2026-06-04 20:14:47 +03:00
commit a70f7fe2b9
143 changed files with 19543 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
using UnityEngine;
public class Enemy : MonoBehaviour
{
public string enemyType = "Goblin";
public int health = 100;
public bool IsDead { get; private set; }
public void TakeDamage(int amount)
{
if (IsDead || amount <= 0)
{
return;
}
health -= amount;
if (health <= 0)
{
Die();
}
else if (NotificationUI.Instance != null)
{
NotificationUI.Instance.Show($"{enemyType}: {health} HP");
}
}
public void Die()
{
if (IsDead)
{
return;
}
IsDead = true;
if (QuestManager.Instance != null)
{
QuestManager.Instance.OnEnemyKilled(enemyType);
}
if (NotificationUI.Instance != null)
{
NotificationUI.Instance.Show($"{enemyType} уничтожен");
}
Destroy(gameObject);
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 117ef3366a8028ade8393946ba5eb300
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+56
View File
@@ -0,0 +1,56 @@
using UnityEngine;
public class PlayerCombat : MonoBehaviour
{
public float attackRange = 3f;
public int damage = 100;
public KeyCode keyboardAttack = KeyCode.F;
private void Update()
{
bool uiBlocksCombat =
DialogueUI.Instance != null && DialogueUI.Instance.IsOpen ||
QuestLogUI.Instance != null && QuestLogUI.Instance.IsOpen;
if (uiBlocksCombat)
{
return;
}
if (Input.GetKeyDown(keyboardAttack) || Input.GetMouseButtonDown(0))
{
AttackNearestEnemy();
}
}
private void AttackNearestEnemy()
{
Enemy nearest = null;
float nearestDistance = attackRange;
Enemy[] enemies = FindObjectsOfType<Enemy>();
foreach (Enemy enemy in enemies)
{
if (enemy == null || enemy.IsDead)
{
continue;
}
float distance = Vector3.Distance(transform.position, enemy.transform.position);
if (distance <= nearestDistance)
{
nearestDistance = distance;
nearest = enemy;
}
}
if (nearest != null)
{
nearest.TakeDamage(damage);
}
else if (NotificationUI.Instance != null)
{
NotificationUI.Instance.Show("Нет врага в радиусе атаки");
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2dd80ac98d16da650a5885eadfb31917
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+62
View File
@@ -0,0 +1,62 @@
using UnityEngine;
public class ResourceNode : MonoBehaviour
{
public ItemData itemData;
public int amount = 1;
public float interactionRange = 2.4f;
public KeyCode interactionKey = KeyCode.E;
private Transform player;
private bool collected;
private void Start()
{
GameObject playerObject = GameObject.FindGameObjectWithTag("Player");
if (playerObject != null)
{
player = playerObject.transform;
}
}
private void Update()
{
if (collected || itemData == null)
{
return;
}
if (player == null)
{
GameObject playerObject = GameObject.FindGameObjectWithTag("Player");
player = playerObject != null ? playerObject.transform : null;
}
if (player == null || Vector3.Distance(player.position, transform.position) > interactionRange)
{
return;
}
if (Input.GetKeyDown(interactionKey))
{
Collect();
}
}
private void Collect()
{
collected = true;
if (Inventory.Instance != null)
{
Inventory.Instance.AddItem(itemData, amount);
}
if (NotificationUI.Instance != null)
{
NotificationUI.Instance.Show($"Собрано:\n{itemData.itemName} x{amount}");
}
Destroy(gameObject);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 006e7c9e149f954dfa7124eb98d94f64
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,135 @@
using UnityEngine;
[RequireComponent(typeof(CharacterController))]
public class SimplePlayerController : MonoBehaviour
{
[Header("Movement")]
public float moveSpeed = 5.5f;
public float sprintSpeed = 7.5f;
public float jumpHeight = 1.4f;
public float gravity = -22f;
public float rotationSmoothTime = 0.08f;
[Header("Camera")]
public Transform cameraPivot;
public Camera playerCamera;
public float cameraDistance = 5.5f;
public float mouseSensitivity = 2.2f;
public float minPitch = -25f;
public float maxPitch = 65f;
private CharacterController controller;
private float verticalVelocity;
private float yaw;
private float pitch = 20f;
private float rotationVelocity;
private void Awake()
{
controller = GetComponent<CharacterController>();
if (cameraPivot == null)
{
GameObject pivot = new GameObject("Camera Pivot");
pivot.transform.SetParent(transform);
pivot.transform.localPosition = new Vector3(0f, 1.45f, 0f);
cameraPivot = pivot.transform;
}
if (playerCamera == null)
{
playerCamera = Camera.main;
}
if (playerCamera != null)
{
playerCamera.transform.SetParent(null);
}
yaw = transform.eulerAngles.y;
}
private void Start()
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
private void Update()
{
bool uiBlocksMovement =
DialogueUI.Instance != null && DialogueUI.Instance.IsOpen ||
QuestLogUI.Instance != null && QuestLogUI.Instance.IsOpen;
if (uiBlocksMovement)
{
ApplyCamera();
return;
}
HandleLook();
HandleMovement();
ApplyCamera();
}
private void HandleLook()
{
yaw += Input.GetAxis("Mouse X") * mouseSensitivity;
pitch -= Input.GetAxis("Mouse Y") * mouseSensitivity;
pitch = Mathf.Clamp(pitch, minPitch, maxPitch);
}
private void HandleMovement()
{
bool grounded = controller.isGrounded;
if (grounded && verticalVelocity < 0f)
{
verticalVelocity = -2f;
}
Vector2 input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
input = Vector2.ClampMagnitude(input, 1f);
Vector3 cameraForward = Quaternion.Euler(0f, yaw, 0f) * Vector3.forward;
Vector3 cameraRight = Quaternion.Euler(0f, yaw, 0f) * Vector3.right;
Vector3 move = cameraForward * input.y + cameraRight * input.x;
if (move.sqrMagnitude > 0.001f)
{
float targetAngle = Mathf.Atan2(move.x, move.z) * Mathf.Rad2Deg;
float smoothAngle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref rotationVelocity, rotationSmoothTime);
transform.rotation = Quaternion.Euler(0f, smoothAngle, 0f);
}
if (Input.GetButtonDown("Jump") && grounded)
{
verticalVelocity = Mathf.Sqrt(jumpHeight * -2f * gravity);
}
verticalVelocity += gravity * Time.deltaTime;
float speed = Input.GetKey(KeyCode.LeftShift) ? sprintSpeed : moveSpeed;
Vector3 velocity = move * speed + Vector3.up * verticalVelocity;
controller.Move(velocity * Time.deltaTime);
}
private void ApplyCamera()
{
if (playerCamera == null || cameraPivot == null)
{
return;
}
Quaternion rotation = Quaternion.Euler(pitch, yaw, 0f);
Vector3 pivot = cameraPivot.position;
Vector3 desiredPosition = pivot - rotation * Vector3.forward * cameraDistance;
if (Physics.Linecast(pivot, desiredPosition, out RaycastHit hit, ~0, QueryTriggerInteraction.Ignore)
&& !hit.transform.IsChildOf(transform))
{
desiredPosition = hit.point + hit.normal * 0.25f;
}
playerCamera.transform.position = desiredPosition;
playerCamera.transform.rotation = rotation;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1b485d09b14fd5b80b37a052d8ab0f7c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: