The fucking 3rd time i had to upload this project to git
This commit is contained in:
28
Assets/Scripts/Level/DependAppear.cs
Normal file
28
Assets/Scripts/Level/DependAppear.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class DependAppear : MonoBehaviour
|
||||
{
|
||||
public GameObject[] dependents;
|
||||
public GameObject[] targets;
|
||||
private bool allCollected;
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
foreach (var obj in targets) obj.SetActive(false);
|
||||
allCollected = false;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
if (!allCollected)
|
||||
{
|
||||
allCollected = dependents.Select(x => !x.activeSelf).Aggregate((x, y) => x && y);
|
||||
if (allCollected)
|
||||
foreach (var obj in targets)
|
||||
obj.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Level/DependAppear.cs.meta
Normal file
11
Assets/Scripts/Level/DependAppear.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0bbb0992303414c6e99433ff5c723b15
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
206
Assets/Scripts/Level/MovingPlatform.cs
Normal file
206
Assets/Scripts/Level/MovingPlatform.cs
Normal file
@ -0,0 +1,206 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public class MovingPlatform : MonoBehaviour
|
||||
{
|
||||
public float translationSpeedX = 1.0f; // Speed of translation along X-axis
|
||||
public float translationSpeedY = 1.0f; // Speed of translation along Y-axis
|
||||
public float translationSpeedZ = 1.0f; // Speed of translation along Z-axis
|
||||
|
||||
public float rotationSpeedX = 1.0f; // Speed of rotation around X-axis
|
||||
public float rotationSpeedY = 1.0f; // Speed of rotation around Y-axis
|
||||
public float rotationSpeedZ = 1.0f; // Speed of rotation around Z-axis
|
||||
|
||||
public float translationAmplitudeX = 1.0f; // Amplitude of translation along X-axis
|
||||
public float translationAmplitudeY = 1.0f; // Amplitude of translation along Y-axis
|
||||
public float translationAmplitudeZ = 1.0f; // Amplitude of translation along Z-axis
|
||||
|
||||
public float rotationAmplitudeX = 30.0f; // Amplitude of rotation around X-axis
|
||||
public float rotationAmplitudeY = 30.0f; // Amplitude of rotation around Y-axis
|
||||
public float rotationAmplitudeZ = 30.0f; // Amplitude of rotation around Z-axis
|
||||
|
||||
public bool translationX; // Enable translation along X-axis
|
||||
public bool translationY; // Enable translation along Y-axis
|
||||
public bool translationZ; // Enable translation along Z-axis
|
||||
|
||||
public bool rotationX; // Enable rotation around X-axis
|
||||
public bool rotationY; // Enable rotation around Y-axis
|
||||
public bool rotationZ; // Enable rotation around Z-axis
|
||||
|
||||
public bool constantrotX; // Enable nonsine translation along X-axis
|
||||
public bool constantrotY; // Enable nonsine translation along Y-axis
|
||||
public bool constantrotZ; // Enable nonsine translation along Z-axis
|
||||
|
||||
|
||||
private Vector3 _initialPosition; // Initial position of the object
|
||||
private Quaternion _initialRotation; // Initial rotation of the object
|
||||
private Transform _transform; // Cached transform
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_transform = transform;
|
||||
// Store the initial position and rotation of the object
|
||||
_initialPosition = _transform.position;
|
||||
_initialRotation = _transform.rotation;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
// Calculate the new position and rotation using sine curves
|
||||
|
||||
// Translation
|
||||
var translationOffsetX = translationX ? Mathf.Sin(Time.time * translationSpeedX) * translationAmplitudeX : 0.0f;
|
||||
var translationOffsetY = translationY ? Mathf.Sin(Time.time * translationSpeedY) * translationAmplitudeY : 0.0f;
|
||||
var translationOffsetZ = translationZ ? Mathf.Sin(Time.time * translationSpeedZ) * translationAmplitudeZ : 0.0f;
|
||||
|
||||
// Rotation
|
||||
float rotationOffsetX;
|
||||
float rotationOffsetY;
|
||||
float rotationOffsetZ;
|
||||
|
||||
if (constantrotX == false)
|
||||
rotationOffsetX = rotationX ? Mathf.Sin(Time.time * rotationSpeedX) * rotationAmplitudeX : 0.0f;
|
||||
else
|
||||
rotationOffsetX = rotationX ? Time.time * rotationSpeedX * rotationAmplitudeX : 0.0f;
|
||||
|
||||
if (constantrotY == false)
|
||||
rotationOffsetY = rotationY ? Mathf.Sin(Time.time * rotationSpeedY) * rotationAmplitudeY : 0.0f;
|
||||
else
|
||||
rotationOffsetY = rotationY ? Time.time * rotationSpeedY * rotationAmplitudeY : 0.0f;
|
||||
|
||||
if (constantrotZ == false)
|
||||
rotationOffsetZ = rotationZ ? Mathf.Sin(Time.time * rotationSpeedZ) * rotationAmplitudeZ : 0.0f;
|
||||
else
|
||||
rotationOffsetZ = rotationZ ? Time.time * rotationSpeedZ * rotationAmplitudeZ : 0.0f;
|
||||
|
||||
// Calculate the rotation around the center of the object
|
||||
// Calculate the rotation around the center of the object
|
||||
Vector3 centerOffset = _transform.InverseTransformPoint(_transform.position); // Get the offset from the center of the object
|
||||
Quaternion quatrotationX = Quaternion.Euler(rotationOffsetX, 0, 0);
|
||||
Quaternion quatrotationY = Quaternion.Euler(0, rotationOffsetY, 0);
|
||||
Quaternion quatrotationZ = Quaternion.Euler(0, 0, rotationOffsetZ);
|
||||
Quaternion rotation = quatrotationX * quatrotationY * quatrotationZ; // Calculate the rotation
|
||||
|
||||
_transform.rotation = rotation * Quaternion.LookRotation(centerOffset); // Apply rotation around the center
|
||||
|
||||
|
||||
// Update the position and rotation of the object
|
||||
_transform.position = _initialPosition +
|
||||
new Vector3(translationOffsetX, translationOffsetY, translationOffsetZ); // Update translation
|
||||
_transform.rotation = _initialRotation * quatrotationX * quatrotationY * quatrotationZ; // Update rotation
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
// Custom editor for MovingPlatform script
|
||||
[CustomEditor(typeof(MovingPlatform))]
|
||||
public class MovingPlatformEditor : Editor
|
||||
{
|
||||
private bool _showRotationSettings = true;
|
||||
private bool _showTranslationSettings = true;
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
// Draw the default inspector
|
||||
|
||||
// Get the MovingPlatform script
|
||||
var movingPlatform = (MovingPlatform)target;
|
||||
|
||||
// Display custom fields for translation and rotation settings
|
||||
// add foldout for translation settings
|
||||
_showTranslationSettings = EditorGUILayout.Foldout(_showTranslationSettings, "Translation Settings", true,
|
||||
EditorStyles.foldoutHeader);
|
||||
|
||||
// Display translation X settings
|
||||
if (_showTranslationSettings)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
// Display translation X settings
|
||||
movingPlatform.translationX = EditorGUILayout.Toggle("Translation X", movingPlatform.translationX);
|
||||
if (movingPlatform.translationX)
|
||||
{
|
||||
movingPlatform.translationSpeedX =
|
||||
EditorGUILayout.FloatField("Translation Speed X", movingPlatform.translationSpeedX);
|
||||
movingPlatform.translationAmplitudeX =
|
||||
EditorGUILayout.FloatField("Translation Amplitude X", movingPlatform.translationAmplitudeX);
|
||||
}
|
||||
|
||||
// Display translation Y settings
|
||||
movingPlatform.translationY = EditorGUILayout.Toggle("Translation Y", movingPlatform.translationY);
|
||||
if (movingPlatform.translationY)
|
||||
{
|
||||
movingPlatform.translationSpeedY =
|
||||
EditorGUILayout.FloatField("Translation Speed Y", movingPlatform.translationSpeedY);
|
||||
movingPlatform.translationAmplitudeY =
|
||||
EditorGUILayout.FloatField("Translation Amplitude Y", movingPlatform.translationAmplitudeY);
|
||||
}
|
||||
|
||||
// Display translation Z settings
|
||||
movingPlatform.translationZ = EditorGUILayout.Toggle("Translation Z", movingPlatform.translationZ);
|
||||
if (movingPlatform.translationZ)
|
||||
{
|
||||
movingPlatform.translationSpeedZ =
|
||||
EditorGUILayout.FloatField("Translation Speed Z", movingPlatform.translationSpeedZ);
|
||||
movingPlatform.translationAmplitudeZ =
|
||||
EditorGUILayout.FloatField("Translation Amplitude Z", movingPlatform.translationAmplitudeZ);
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
|
||||
// add foldout for rotation settings
|
||||
_showRotationSettings = EditorGUILayout.Foldout(_showRotationSettings, "Rotation Settings", true,
|
||||
EditorStyles.foldoutHeader);
|
||||
if (_showRotationSettings)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
|
||||
movingPlatform.rotationX = EditorGUILayout.Toggle("Rotation X", movingPlatform.rotationX);
|
||||
if (movingPlatform.rotationX)
|
||||
{
|
||||
movingPlatform.rotationSpeedX =
|
||||
EditorGUILayout.FloatField("Rotation Speed X", movingPlatform.rotationSpeedX);
|
||||
movingPlatform.constantrotX =
|
||||
EditorGUILayout.Toggle("Constant Rotation X", movingPlatform.constantrotX);
|
||||
|
||||
if (!movingPlatform.constantrotX)
|
||||
movingPlatform.rotationAmplitudeX =
|
||||
EditorGUILayout.Slider("Rotation Amplitude X", movingPlatform.rotationAmplitudeX, 0.0f, 360.0f);
|
||||
}
|
||||
|
||||
movingPlatform.rotationY = EditorGUILayout.Toggle("Rotation Y", movingPlatform.rotationY);
|
||||
if (movingPlatform.rotationY)
|
||||
{
|
||||
movingPlatform.rotationSpeedY =
|
||||
EditorGUILayout.FloatField("Rotation Speed Y", movingPlatform.rotationSpeedY);
|
||||
movingPlatform.constantrotY =
|
||||
EditorGUILayout.Toggle("Constant Rotation Y", movingPlatform.constantrotY);
|
||||
|
||||
if (!movingPlatform.constantrotY)
|
||||
movingPlatform.rotationAmplitudeY =
|
||||
EditorGUILayout.Slider("Rotation Amplitude Y", movingPlatform.rotationAmplitudeY, 0.0f, 360.0f);
|
||||
}
|
||||
|
||||
movingPlatform.rotationZ = EditorGUILayout.Toggle("Rotation Z", movingPlatform.rotationZ);
|
||||
if (movingPlatform.rotationZ)
|
||||
{
|
||||
movingPlatform.rotationSpeedZ =
|
||||
EditorGUILayout.FloatField("Rotation Speed Z", movingPlatform.rotationSpeedZ);
|
||||
movingPlatform.constantrotZ =
|
||||
EditorGUILayout.Toggle("Constant Rotation Z", movingPlatform.constantrotZ);
|
||||
|
||||
if (!movingPlatform.constantrotZ)
|
||||
movingPlatform.rotationAmplitudeZ =
|
||||
EditorGUILayout.Slider("Rotation Amplitude Z", movingPlatform.rotationAmplitudeZ, 0.0f, 360.0f);
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
11
Assets/Scripts/Level/MovingPlatform.cs.meta
Normal file
11
Assets/Scripts/Level/MovingPlatform.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e2fb7d8a4ff9ac43b4d860f982dab82
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Level/TraversalProperties.cs
Normal file
8
Assets/Scripts/Level/TraversalProperties.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class TraversalProperties : MonoBehaviour
|
||||
{
|
||||
[SerializeField] public bool canGrappleOnto;
|
||||
|
||||
[SerializeField] public bool lethalToEnter;
|
||||
}
|
11
Assets/Scripts/Level/TraversalProperties.cs.meta
Normal file
11
Assets/Scripts/Level/TraversalProperties.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b7990ac7d1b27486c887ffb3550956cd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
12
Assets/Scripts/Level/TriggerLevelChange.cs
Normal file
12
Assets/Scripts/Level/TriggerLevelChange.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class TriggerLevelChange : MonoBehaviour
|
||||
{
|
||||
public string levelToLoad;
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.tag == "Player") SceneManager.LoadScene(levelToLoad);
|
||||
}
|
||||
}
|
11
Assets/Scripts/Level/TriggerLevelChange.cs.meta
Normal file
11
Assets/Scripts/Level/TriggerLevelChange.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a881360b82b9241deba8e1d70e7acf87
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user