This commit is contained in:
Malak
2026-06-06 17:31:47 +02:00
30 changed files with 1667 additions and 2920 deletions
+14 -15
View File
@@ -1,6 +1,5 @@
using System;
using System.Collections;
using UnityEngine;
using Object = System.Object;
using UnityEngine.SceneManagement;
public class DamageHandler : MonoBehaviour
@@ -26,11 +25,11 @@ public class DamageHandler : MonoBehaviour
private void Start()
{
threshold = 10f;
multiplier = 0.1f;
threshold = 10f;
multiplier = 0.1f;
maxHealth = 1f;
minSize = 0.8f;
maxHealth = 1f;
minSize = 0.8f;
health = maxHealth;
}
@@ -60,32 +59,32 @@ public class DamageHandler : MonoBehaviour
private void OnCollisionEnter2D(Collision2D other)
{
if (other.collider.CompareTag("Minidrop")){
UpdateHealth(0.2f);
}
//on collision check fall damage
float fallSpeed = lastYVelocity;
if (fallSpeed < -threshold)
{
float fallDamage = (-fallSpeed - threshold) * multiplier;
// Debug.Log($"Fell with velocity:{fallSpeed}. Fall damage{fallDamage}");
UpdateHealth(health - fallDamage);
// Debug.Log($"New health:{health - fallDamage}");
}
else
{
// Debug.Log($"Fell with velocity:{fallSpeed}. No fall damage");
}
}
public void UpdateHealth(float health)
{
{
this.health = health;
if (health > maxHealth) this.health = maxHealth;
Transform transform = GetComponent<Transform>();
float healthScaling = minSize + (1 - minSize) * (this.health / maxHealth);
//adjust size based on health
transform.localScale = new Vector3(healthScaling,healthScaling,healthScaling);
// Debug.Log("UpdatedScale and health");
if(this.health <= 0f)
{
// Debug.Log("Die");
Die();
}
}
+21 -9
View File
@@ -8,7 +8,7 @@ public class DropletMovement : MonoBehaviour
private Collider2D characterCollider;
// helper variables
private bool isGrounded = true;
private bool isGrounded = false;
private float facingDirection = 1f;
private bool isDropping = false;
private float fallTimer;
@@ -40,7 +40,7 @@ public class DropletMovement : MonoBehaviour
{
//dashing
if (isDashing)
if (isDashing || isGrounded == false)
{
return;
}
@@ -91,20 +91,17 @@ public class DropletMovement : MonoBehaviour
private void FixedUpdate()
{
if (isDashing || isDropping)
{
{
return;
} // was here before
}
//wind
float windForce = 0f;
if (WindManager.Instance != null)
{
windForce = WindManager.Instance.CurrentWindForce;
}
rb.linearVelocity = new Vector2(movement.x * moveSpeed + windForce, rb.linearVelocity.y);
//used to be rb.linearVelocity = new Vector2(movement.x * moveSpeed, rb.linearVelocity.y);
}
private void OnTriggerEnter2D(Collider2D other)
@@ -151,8 +148,23 @@ public class DropletMovement : MonoBehaviour
}
private void OnCollisionEnter2D(Collision2D col)
{
if (col.collider.CompareTag("Platform") && rb.linearVelocity.y == 0)
{
isGrounded = true;
}
else
{
isGrounded = false;
}
}
private void OnCollisionExit2D(Collision2D collision)
{
isGrounded = true;
if (collision.collider.CompareTag("Platform"))
{
isGrounded = false;
}
}
+14
View File
@@ -0,0 +1,14 @@
using UnityEngine;
public class MiniDroplet : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
float size = Random.Range(0.3f, 0.7f);
Vector2 targetSize = new Vector2(size, size);
transform.localScale = targetSize;
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 9e4bdf7e79782084cae014769845a30a
+15 -4
View File
@@ -2,13 +2,24 @@ using UnityEngine;
public class PatternSelecter : MonoBehaviour
{
bool isStarting = true;
void Start()
{
foreach (Transform child in transform)
child.gameObject.SetActive(false);
if (isStarting)
{
transform.GetChild(0).gameObject.SetActive(true);
} else
{
foreach (Transform child in transform)
child.gameObject.SetActive(false);
int randomIndex = Random.Range(0, transform.childCount);
int randomIndex = Random.Range(1, transform.childCount);
transform.GetChild(randomIndex).gameObject.SetActive(true);
}
transform.GetChild(randomIndex).gameObject.SetActive(true);
}
}
-8
View File
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: c75792f2507b4ad4193b0d02e0f844bb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,33 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &6150638783375540612
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1039062502636170370}
m_Layer: 0
m_Name: Pattern1
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!4 &1039062502636170370
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6150638783375540612}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0.88164, y: 2.6479797, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: e2110c62d836c984ab0db69c7897a126
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,33 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &8832551750935600745
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 33410884287286606}
m_Layer: 0
m_Name: Pattern2
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &33410884287286606
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8832551750935600745}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0.88164, y: 2.6479797, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 5e99c7748f96ea543ad4882124711a08
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,33 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1071583743141859860
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 38291094147875370}
m_Layer: 0
m_Name: Pattern3
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &38291094147875370
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1071583743141859860}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0.88164, y: 2.6479797, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 8920e77dfed2f1f42a365a095b2a2193
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,33 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &7347798228780826248
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3713290930691113175}
m_Layer: 0
m_Name: Pattern4
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3713290930691113175
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7347798228780826248}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0.88164, y: 2.6479797, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 70f689dc535d5614b8692fd200a930a8
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,33 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &7044465100937614328
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8036000506115012035}
m_Layer: 0
m_Name: Pattern5
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &8036000506115012035
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7044465100937614328}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0.88164, y: 2.6479797, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: bee5caaa7a9115f4db4eed38b176d3f6
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: