Initial commit

This commit is contained in:
2026-03-17 13:40:09 +02:00
commit 91fb7fdad5
1055 changed files with 388166 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
using UnityEngine;
namespace IdyllicFantasyNature
{
public class BushLeafTrigger : MonoBehaviour
{
[Tooltip("particle system that will be triggered")]
[SerializeField] private ParticleSystem _leafParticleSystem;
[Tooltip("the tag of the player gameobject with the collider")]
[SerializeField] private string _playerTag;
/// <summary>
/// When the player leaves the trigger, the particle system is placed at the last player position and starts playing
/// </summary>
/// <param name="other"></param>
private void OnTriggerExit(Collider other)
{
if (other.CompareTag(_playerTag))
{
_leafParticleSystem.gameObject.transform.position = new Vector3(other.GetComponent<Transform>().position.x, _leafParticleSystem.gameObject.transform.position.y, other.GetComponent<Transform>().position.z);
_leafParticleSystem.Play();
}
}
}
}

View File

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

View File

@@ -0,0 +1,80 @@
using UnityEngine;
namespace IdyllicFantasyNature
{
public class ButterflySpawn : MonoBehaviour
{
[Tooltip("child with the mesh renderer to make the butterfly invisible when the animation is not running")]
[SerializeField] private GameObject _butterflyChild;
// the spawn area script to get the data from the set range and cooldown
private ButterflySpawnArea _area;
// the cooldown to respawn the butterfly
private float _cooldown = 0;
// indicates if the animation is playing to stop the cooldown for the respawn
private bool _isPlaying = false;
// animator of the butterfly
private Animator _animator;
// Start is called before the first frame update
void Start()
{
_animator = GetComponent<Animator>();
_area = GetComponentInParent<ButterflySpawnArea>();
// sets the animator off to not play the animation before the cooldown reaches 0
_animator.enabled = false;
// get the set cooldown
_cooldown = Random.Range(_area.MinCooldown, _area.MaxCooldown);
// makes the butterfly invisible until the animation starts playing
_butterflyChild.SetActive(false);
}
// Update is called once per frame
void Update()
{
ActivateButterfly();
}
/// <summary>
/// activates the butterfly when the cooldown reaches 0 and the animation isn't already playing
/// </summary>
private void ActivateButterfly()
{
if (!_isPlaying)
{
if (_cooldown <= 0)
{
// activates the animator to play the animation
_animator.enabled = true;
// resets the cooldown for the respawn
_cooldown = Random.Range(_area.MinCooldown, _area.MaxCooldown);
// makes the butterfly visible
_butterflyChild.SetActive(true);
// determines a random position for the butterfly in the spawn area
transform.position = new Vector3(Random.Range(_area.Collider.bounds.min.x, _area.Collider.bounds.max.x), Random.Range(_area.Collider.bounds.min.y, _area.Collider.bounds.max.y), Random.Range(_area.Collider.bounds.min.z, _area.Collider.bounds.max.z));
_isPlaying = true;
}
else
{
_cooldown -= Time.deltaTime;
}
}
}
/// <summary>
/// animation event will be used at the end of the butterfly animation
/// Resets the stats to enable the cooldown for the respawn
/// </summary>
public void AnimationEnded()
{
_isPlaying = false;
_animator.enabled = false;
_butterflyChild.SetActive(false);
}
}
}

View File

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

View File

@@ -0,0 +1,19 @@
using UnityEngine;
namespace IdyllicFantasyNature
{
public class ButterflySpawnArea : MonoBehaviour
{
public Collider Collider { get; set; }
[Tooltip("the minimum cooldown for the butterfly to respawn")]
[Min(0)] public float MinCooldown;
[Tooltip("the maximum cooldown for the butterfly to respawn")]
[Min(1)] public float MaxCooldown;
private void Start()
{
Collider = GetComponent<Collider>();
}
}
}

View File

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

View File

@@ -0,0 +1,47 @@
using UnityEngine;
namespace IdyllicFantasyNature
{
public class CameraMovement : MonoBehaviour
{
[Range(1f, 10f)]
[Tooltip("speed of the camera movement")]
[SerializeField] private float _mouseSensity = 1;
// mouse rotation
private float _xRotation;
private float _yRotation;
[Tooltip("the parent of this object")]
[SerializeField] private Transform _controller;
// Start is called before the first frame update
private void Start()
{
// locks cursor and makes it invisible
Cursor.lockState = Cursor.lockState;
Cursor.visible = false;
}
// Update is called once per frame
void Update()
{
// get input of the mouse
float mouseX = Input.GetAxis("Mouse X") * _mouseSensity;
float mouseY = Input.GetAxis("Mouse Y") * _mouseSensity;
_yRotation += mouseX;
_xRotation -= mouseY;
// limits camera rotation
_xRotation = Mathf.Clamp(_xRotation, -90f, 90f);
// rotates camera on the y- and x-axis
transform.rotation = Quaternion.Euler(_xRotation, _yRotation, 0);
// rotates the controller on the y-axis so that it is on the same rotation as the camera
_controller.rotation = Quaternion.Euler(0, _yRotation, 0);
}
}
}

View File

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

View File

@@ -0,0 +1,16 @@
using UnityEngine;
namespace IdyllicFantasyNature
{
public class ExitGame : MonoBehaviour
{
void Update()
{
// If you press the ESC key in the game, the application will be closed
if (Input.GetKey(KeyCode.Escape))
{
Application.Quit();
}
}
}
}

View File

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

View File

@@ -0,0 +1,61 @@
using UnityEngine;
namespace IdyllicFantasyNature
{
public class PlayerMovement : MonoBehaviour
{
[Range(1f, 20f)]
[SerializeField] private float _movementSpeed;
[Tooltip("run multiplier of the movement speed")]
[Range(1f, 20f)]
[SerializeField] private float _runMultiplier;
[SerializeField] private float _gravity = -9.81f;
[Range(1f, 20f)]
[SerializeField] private float _jumpHeight;
private CharacterController characterController;
Vector3 _controllerVelocity;
// Start is called before the first frame update
void Start()
{
characterController = GetComponent<CharacterController>();
}
// Update is called once per frame
void Update()
{
// stops the y velocity when player is on the ground and the velocity has reached 0
if (characterController.isGrounded && _controllerVelocity.y < 0)
{
_controllerVelocity.y = 0;
}
// get the movement input
float moveX = Input.GetAxis("Horizontal");
float moveZ = Input.GetAxis("Vertical");
// moves the controller in the desired direction on the x- and z-axis
Vector3 movement = transform.right * moveX + transform.forward * moveZ;
characterController.Move(movement * _movementSpeed * Time.deltaTime);
// gravity affects the controller on the y-axis
_controllerVelocity.y += _gravity * Time.deltaTime;
// moves the controller on the y-axis
characterController.Move(_controllerVelocity * Time.deltaTime);
// the controller is able to jump when on the ground
if (Input.GetButton("Jump") && characterController.isGrounded)
{
_controllerVelocity.y = Mathf.Sqrt(_jumpHeight * -2f * _gravity);
}
// the controller is able to run
if (Input.GetKey(KeyCode.LeftShift))
{
characterController.Move(movement * Time.deltaTime * _runMultiplier);
}
}
}
}

View File

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

View File

@@ -0,0 +1,65 @@
using UnityEngine;
namespace IdyllicFantasyNature
{
[ExecuteInEditMode]
public class VegetationBendControl : MonoBehaviour
{
[SerializeField] private bool _enableBendFeature = false;
[Tooltip("The origin where the impact on the object starts")]
[SerializeField] private Transform _bendOrigin;
[Range(0.3f, 1)]
[Tooltip("object starts to bend when the player is at a certain distance")]
[SerializeField] private float _startBendRange;
[Range(0, 1)]
[SerializeField] private float _bendStrength;
[Tooltip("material of the vegetation objects")]
[SerializeField] private Material[] _material;
// current world space position of the bending object
private Vector3 _currentBendPosition;
private void Update()
{
if (_enableBendFeature)
{
moveOnVegetation();
}
}
private void OnValidate()
{
BendSettings();
}
/// <summary>
/// the material gets the object position to know when to bend
/// only updates when player moves
/// </summary>
void moveOnVegetation()
{
if (_currentBendPosition != _bendOrigin.position)
{
for (int i = 0; i < _material.Length; i++)
{
_material[i].SetVector("_Player_Position", _bendOrigin.position);
}
_currentBendPosition = _bendOrigin.position;
}
}
/// <summary>
/// the material gets the bend settings
/// </summary>
void BendSettings()
{
for (int i = 0; i < _material.Length; i++)
{
_material[i].SetFloat("_Bend_Strength", _bendStrength);
_material[i].SetFloat("_Start_Bend_Range", _startBendRange);
}
}
}
}

View File

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

View File

@@ -0,0 +1,36 @@
using UnityEngine;
namespace IdyllicFantasyNature
{
public class WindControl : MonoBehaviour
{
[Range(0, 1)]
[SerializeField] private float _windStrength;
[Range(0, 1)]
[SerializeField] private float _windSpeed;
[Range(0, 1)]
[SerializeField] private float _windVariation;
[Range(0, 1)]
[Tooltip("how detailed the wind moves the object")]
[SerializeField] private float _waveScale;
[SerializeField] private Vector2 _windDirection;
[Tooltip("material of the vegetation objects")]
[SerializeField] private Material[] _material;
/// <summary>
/// the material gets the wind settings
/// method only runs in the editor mode
/// </summary>
private void OnValidate()
{
for (int i = 0; i < _material.Length; i++)
{
_material[i].SetFloat("_Wind_Speed", _windSpeed);
_material[i].SetFloat("_Wind_Variation", _windVariation);
_material[i].SetFloat("_Wind_Strength", _windStrength);
_material[i].SetFloat("_Wave_Scale", _waveScale);
_material[i].SetVector("_Wind_Direction", _windDirection);
}
}
}
}

View File

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