Merge branch 'main' of https://github.com/orsolya-st/gamejam_050626
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
@@ -39,7 +40,7 @@ public class DamageHandler : MonoBehaviour
|
||||
if (lastYVelocity >= 0 && currentVelocity < 0)
|
||||
{
|
||||
falling = true;
|
||||
Debug.Log("Started falling");
|
||||
// Debug.Log("Started falling");
|
||||
fallTime = 0f;
|
||||
}
|
||||
else if(lastYVelocity < 0 && currentVelocity < 0)
|
||||
@@ -51,7 +52,7 @@ public class DamageHandler : MonoBehaviour
|
||||
fallTime += Time.deltaTime;
|
||||
} else if(currentVelocity >= 0)
|
||||
{
|
||||
Debug.Log("Not falling");
|
||||
// Debug.Log("Not falling");
|
||||
falling = false;
|
||||
}
|
||||
lastYVelocity = currentVelocity;
|
||||
@@ -59,10 +60,7 @@ public class DamageHandler : MonoBehaviour
|
||||
|
||||
private void OnCollisionEnter2D(Collision2D other)
|
||||
{
|
||||
|
||||
if (other.collider.CompareTag("Minidrop")){
|
||||
UpdateHealth(0.2f);
|
||||
}
|
||||
// Debug.LogWarning("collide");
|
||||
//on collision check fall damage
|
||||
float fallSpeed = lastYVelocity;
|
||||
if (fallSpeed < -threshold)
|
||||
@@ -71,7 +69,16 @@ public class DamageHandler : MonoBehaviour
|
||||
UpdateHealth(health - fallDamage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (other.CompareTag("Minidrop")){
|
||||
UpdateHealth(health + 0.2f);
|
||||
Destroy(other.gameObject);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void UpdateHealth(float health)
|
||||
{
|
||||
|
||||
@@ -2,24 +2,21 @@ using UnityEngine;
|
||||
|
||||
public class PatternSelecter : MonoBehaviour
|
||||
{
|
||||
|
||||
|
||||
bool isStarting = true;
|
||||
void Start()
|
||||
{
|
||||
|
||||
if (isStarting)
|
||||
foreach (Transform child in transform)
|
||||
{
|
||||
transform.GetChild(0).gameObject.SetActive(true);
|
||||
} else
|
||||
{
|
||||
foreach (Transform child in transform)
|
||||
child.gameObject.SetActive(false);
|
||||
|
||||
int randomIndex = Random.Range(1, transform.childCount);
|
||||
|
||||
transform.GetChild(randomIndex).gameObject.SetActive(true);
|
||||
child.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
if (TreeSpawner.treeCount == 0)
|
||||
{
|
||||
transform.GetChild(0).gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
int randomIndex = Random.Range(1, transform.childCount);
|
||||
transform.GetChild(randomIndex).gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,9 @@ public class TreeSpawner : MonoBehaviour
|
||||
|
||||
private bool hasSpawned = false;
|
||||
|
||||
public static int treeCount;
|
||||
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (hasSpawned == false)
|
||||
@@ -18,7 +21,9 @@ public class TreeSpawner : MonoBehaviour
|
||||
float treeHeight = GetComponent<SpriteRenderer>().bounds.size.y;
|
||||
Vector3 spawnPos = transform.position + Vector3.down * treeHeight + new Vector3(0, 0.2f, 0);
|
||||
|
||||
treeCount++;
|
||||
Instantiate(treePrefab, spawnPos, Quaternion.identity);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user