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,85 @@
using UnityEngine;
public class HighStrikerController : MonoBehaviour
{
public PlanetData[] planets;
public ToyRocketController rocket;
public StrikerLeverController newtonLever;
public StrikerLeverController lengthLever;
public int currentPlanet = 0;
public float maxDistanceY = 0f;
public Transform startRocketPosition;
public Transform endRocketPosition;
void Start()
{
SetupStriker();
}
void Update()
{
}
private void SetupStriker()
{
// Rocket initial setup
rocket.SetRocketMass(Random.Range(10f, 100f));
// Planets initial setup
maxDistanceY = Random.Range(20000f, 40000f);
foreach (PlanetData planet in planets)
{
float planetY = planet.planetFlightPoint.transform.localPosition.y;
float planetDist = Remap(planetY, startRocketPosition.localPosition.y, endRocketPosition.localPosition.y, 0f, maxDistanceY);
planet.SetupPlanet(planetDist);
}
SetupLevers();
}
private void SetupLevers()
{
PlanetData planet = planets[currentPlanet];
if (Random.Range(0, 100) < 50f) // If Newton Lever
{
lengthLever.isBlocked = true;
newtonLever.isBlocked = false;
lengthLever.springValue = (2 * (rocket.rocketMass / 1000f) * 9.81f * planet.planetDistanceM) / Random.Range(lengthLever.maxSpringValue * 0.25f, lengthLever.maxSpringValue * 0.9f);
} else // If Length Lever
{
lengthLever.isBlocked = false;
newtonLever.isBlocked = true;
newtonLever.springValue = (2 * (rocket.rocketMass / 1000f) * 9.81f * planet.planetDistanceM) / Random.Range(lengthLever.maxSpringValue * 0.25f, lengthLever.maxSpringValue * 0.9f);
}
}
public void FlyRocket()
{
float k = newtonLever.springValue;
float x = lengthLever.springValue / 100f;
float m = rocket.rocketMass / 1000f;
float height = (k * x * x) / (2f * m * 9.81f);
Vector3 flyTo = rocket.transform.localPosition;
Debug.Log(height);
flyTo.y = Remap(height, 0f, maxDistanceY / 100f, startRocketPosition.transform.localPosition.y, endRocketPosition.transform.localPosition.y);
rocket.transform.localPosition = flyTo;
}
private float Remap(float v, float inMin, float inMax, float outMin, float outMax)
{
return (v - inMin) / (inMax - inMin) * (outMax - outMin) + outMin;
}
}

View File

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

View File

@@ -0,0 +1,15 @@
using UnityEngine;
using TMPro;
public class PlanetData : MonoBehaviour
{
public Transform planetFlightPoint;
public TextMeshPro planetDistanceText;
public float planetDistanceM;
public void SetupPlanet(float distance)
{
planetDistanceM = distance;
planetDistanceText.text = $"{planetDistanceM:F0} CM".Replace(",", ".");
}
}

View File

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

View File

@@ -0,0 +1,10 @@
using UnityEngine;
public class RocketButtonController : MonoBehaviour
{
public HighStrikerController HighStrikerController;
public void Use()
{
HighStrikerController.FlyRocket();
}
}

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,63 @@
using TMPro;
using UnityEngine;
public class StrikerLeverController : MonoBehaviour
{
public float endAngle = 8f;
public float currentAngle;
public Transform leverObject;
public Transform[] springsObjects;
public float springMaxScaleZ = 3.3f;
public bool isLength = false;
public TextMeshPro valueText;
public float springValue = 0f;
public float maxSpringValue = 1000f;
public bool isBlocked = false;
private void Awake()
{
currentAngle = endAngle;
}
void Update()
{
if (isLength)
valueText.text = $"{springValue:F2} CM".Replace(",", ".");
else
valueText.text = $"{springValue:F2} N/m".Replace(",", ".");
if (isBlocked) SetAlpha(0.2f);
}
public void RotateLever(float angle)
{
if (isBlocked) return;
currentAngle += angle;
if (currentAngle < endAngle) currentAngle = endAngle;
if (currentAngle > 180f - endAngle) currentAngle = 180f - endAngle;
foreach (Transform t in springsObjects) {
Vector3 newScale = t.localScale;
newScale.z = Remap(currentAngle, endAngle, 180f - endAngle, 0f, springMaxScaleZ);
t.localScale = newScale;
}
springValue = Remap(currentAngle, endAngle, 180f - endAngle, 0, maxSpringValue);
leverObject.localRotation = Quaternion.Euler(0f, 0f, currentAngle);
}
private float Remap(float v, float inMin, float inMax, float outMin, float outMax)
{
return (v - inMin) / (inMax - inMin) * (outMax - outMin) + outMin;
}
private void SetAlpha(float alpha)
{
leverObject.GetChild(0).GetComponent<Renderer>().material.color = new UnityEngine.Color(1, 1, 1, alpha);
}
}

View File

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

View File

@@ -0,0 +1,25 @@
using System;
using TMPro;
using UnityEngine;
public class ToyRocketController : MonoBehaviour
{
public TextMeshPro rocketMassText;
public float rocketMass;
void Start()
{
}
void Update()
{
}
public void SetRocketMass(float newMass)
{
rocketMass = newMass;
rocketMassText.text = $"{rocketMass:F2} GR".Replace(",", ".");
}
}

View File

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