initial commit

This commit is contained in:
2026-06-04 00:55:54 +03:00
commit 89979b009f
1632 changed files with 880133 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
using System.Linq;
using UnityEngine;
public class CubeSpawner : MonoBehaviour
{
public WaterLevelController waterLevelController;
public GameObject[] cubesPrefabs;
public int minScale = 1;
public int maxScale = 5;
private void Start()
{
for (int i = 0; i < cubesPrefabs.Length; i++)
{
cubesPrefabs[i].transform.localScale = new Vector3(Random.Range(minScale, maxScale), Random.Range(minScale, maxScale), Random.Range(minScale, maxScale));
}
}
public void SpawnNewCube(int cubeId)
{
waterLevelController.currentCubeMass = 0f;
waterLevelController.currentCubeVolume = 0f;
cubeId = cubeId - 1;
while (transform.childCount > 0)
{
DestroyImmediate(transform.GetChild(0).gameObject);
}
GameObject newCube = Instantiate(cubesPrefabs[cubeId]);
newCube.transform.SetParent(transform);
newCube.transform.localPosition = Vector3.zero;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 68b806cec1697c14892810547aec992a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,75 @@
using UnityEngine;
public class DensityCube : MonoBehaviour
{
public float mass;
public float density;
public float cubeVolume;
public Material[] cubeColorMaterials;
public enum CubeMaterial
{
beton,
iron,
aluminum,
copper,
silver,
gold
}
public CubeMaterial cubeMaterial;
private void Start()
{
SetCubeDensity();
SetCubeMass();
}
private void OnValidate()
{
SetCubeDensity();
SetCubeMass();
}
private void SetCubeDensity()
{
switch (cubeMaterial)
{
case CubeMaterial.beton:
density = 2.4f;
GetComponent<Renderer>().material = cubeColorMaterials[0];
break;
case CubeMaterial.iron:
density = 7.85f;
GetComponent<Renderer>().material = cubeColorMaterials[1];
break;
case CubeMaterial.aluminum:
density = 2.7f;
GetComponent<Renderer>().material = cubeColorMaterials[2];
break;
case CubeMaterial.copper:
density = 8.96f;
GetComponent<Renderer>().material = cubeColorMaterials[3];
break;
case CubeMaterial.silver:
density = 10.5f;
GetComponent<Renderer>().material = cubeColorMaterials[4];
break;
case CubeMaterial.gold:
density = 19.3f;
GetComponent<Renderer>().material = cubeColorMaterials[5];
break;
}
}
private void SetCubeMass()
{
float cubeWidth = transform.localScale.x;
float cubeHeight = transform.localScale.y;
float cubeLength = transform.localScale.z;
cubeVolume = cubeWidth * cubeHeight * cubeLength;
mass = cubeVolume * density;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 72dd16f3c11f4e54f877cf7a4087e81b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,40 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class LookInteract : MonoBehaviour
{
public float interactRange = 20f;
public Texture2D normalCursor;
public Texture2D interactCursor;
void Update()
{
if (MenuController.Instance.isPaused) return;
Ray ray = new Ray(Camera.main.transform.position,
Camera.main.transform.forward);
if (Physics.Raycast(ray, out RaycastHit hit, interactRange))
{
if (hit.collider.CompareTag("Button"))
{
Cursor.SetCursor(interactCursor, Vector2.zero, CursorMode.Auto);
if (Input.GetMouseButtonDown(0))
{
hit.collider.SendMessage("OnLookInteract",
SendMessageOptions.DontRequireReceiver);
}
}
else
{
Cursor.SetCursor(normalCursor, new Vector2(16, 16), CursorMode.Auto);
}
}
else
{
Cursor.SetCursor(normalCursor, new Vector2(16, 16), CursorMode.Auto);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 01fd7d793d9255d4aab21e3b299408ab
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,68 @@
using UnityEngine;
public class PickupThrow : MonoBehaviour
{
public Transform holdPoint;
public float pickupRange = 3f;
public float throwForce = 10f;
private Rigidbody heldRb;
private Transform originalParent;
void Update()
{
// ËÊÌ — âçÿòè / â³äïóñòèòè
if (Input.GetMouseButtonDown(0))
{
if (heldRb == null)
TryPickup();
else
Drop(false);
}
// ÏÊÌ — êèíóòè
if (Input.GetMouseButtonDown(1) && heldRb != null)
Drop(true);
}
void TryPickup()
{
if (Physics.Raycast(Camera.main.transform.position,
Camera.main.transform.forward, out RaycastHit hit, pickupRange))
{
if (!hit.collider.CompareTag("Pickable")) return;
heldRb = hit.collider.attachedRigidbody;
if (heldRb == null) return;
originalParent = heldRb.transform.parent;
// Âèìèêàºìî ô³çèêó
heldRb.isKinematic = true;
heldRb.useGravity = false;
// Ïðèêð³ïëþºìî äî ðóêè
heldRb.transform.SetParent(holdPoint);
heldRb.transform.localPosition = Vector3.zero;
heldRb.transform.localRotation = Quaternion.identity;
}
}
void Drop(bool throwIt)
{
// ³äêð³ïëþºìî
heldRb.transform.SetParent(originalParent);
// Âìèêàºìî ô³çèêó
heldRb.isKinematic = false;
heldRb.useGravity = true;
if (throwIt)
{
heldRb.AddForce(Camera.main.transform.forward * throwForce,
ForceMode.VelocityChange);
}
heldRb = null;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5e809941a6cc3be4cbc1ea0e83783b02
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,21 @@
using UnityEngine;
public class ScrollLeverOnHover : MonoBehaviour
{
void Update()
{
float scroll = Input.mouseScrollDelta.y;
if (scroll == 0) return;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out RaycastHit hit))
{
if (hit.collider.gameObject.tag == "LeverParent")
{
StrikerLeverController slc = hit.collider.gameObject.GetComponent<StrikerLeverController>();
if (slc != null) slc.currentAngle += scroll;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e9f1a2816fde2d04782faf4e5a64e2f2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,44 @@
using UnityEngine;
using System.Collections;
public class SpawnCubeButton : MonoBehaviour
{
public int cubeId = 0;
public CubeSpawner cubeSpawner;
private Vector3 _originalScale;
void Start()
{
_originalScale = transform.localScale;
}
void OnLookInteract()
{
cubeSpawner.SpawnNewCube(cubeId);
StartCoroutine(PressAnimation());
}
private IEnumerator PressAnimation()
{
float duration = 0.3f;
float elapsed = 0f;
Vector3 pressedScale = new Vector3(_originalScale.x, _originalScale.y * 0.3f, _originalScale.z);
while (elapsed < duration)
{
elapsed += Time.deltaTime;
transform.localScale = Vector3.Lerp(_originalScale, pressedScale, elapsed / duration);
yield return null;
}
elapsed = 0f;
while (elapsed < duration)
{
elapsed += Time.deltaTime;
transform.localScale = Vector3.Lerp(pressedScale, _originalScale, elapsed / duration);
yield return null;
}
transform.localScale = _originalScale;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2246ba0c8bb0ddb4286c18dafe5f9eda
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,27 @@
using UnityEngine;
using TMPro;
public class WaterLevelController : MonoBehaviour
{
public TextMeshPro waterLevelText;
public TextMeshPro cubeMassText;
private float waterLevel = 100f;
public float currentCubeVolume = 0f;
public float currentCubeMass = 0f;
void Update()
{
waterLevelText.text = "WATER VOLUME " + (waterLevel + currentCubeVolume).ToString().Replace(",", ".") + "L";
cubeMassText.text = "OBJECT MASS " + currentCubeMass.ToString().Replace(",", ".") + "KG";
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag != "DensityCube") return;
DensityCube dc = other.GetComponent<DensityCube>();
currentCubeVolume = dc.cubeVolume;
currentCubeMass = dc.mass;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7bbbbf5b74451c942a48522409cf86b1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: