treeSpawnCounter

This commit is contained in:
cemt1363
2026-06-06 18:19:52 +02:00
parent 4827de6748
commit 2c3933d77f
4 changed files with 20 additions and 18 deletions
@@ -127,7 +127,7 @@ BoxCollider2D:
m_UsedByEffector: 1 m_UsedByEffector: 1
m_CompositeOperation: 0 m_CompositeOperation: 0
m_CompositeOrder: 0 m_CompositeOrder: 0
m_Offset: {x: 0, y: -0.61813337} m_Offset: {x: 0, y: -0.299548}
m_SpriteTilingProperty: m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0} border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5} pivot: {x: 0.5, y: 0.5}
@@ -137,7 +137,7 @@ BoxCollider2D:
drawMode: 0 drawMode: 0
adaptiveTiling: 0 adaptiveTiling: 0
m_AutoTiling: 0 m_AutoTiling: 0
m_Size: {x: 6.08, y: 1.5346009} m_Size: {x: 6.08, y: 0.8974301}
m_EdgeRadius: 0 m_EdgeRadius: 0
--- !u!251 &1230605949537068183 --- !u!251 &1230605949537068183
PlatformEffector2D: PlatformEffector2D:
@@ -127,7 +127,7 @@ BoxCollider2D:
m_UsedByEffector: 1 m_UsedByEffector: 1
m_CompositeOperation: 0 m_CompositeOperation: 0
m_CompositeOrder: 0 m_CompositeOrder: 0
m_Offset: {x: 0, y: -0.61813337} m_Offset: {x: 0, y: -0.25666255}
m_SpriteTilingProperty: m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0} border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5} pivot: {x: 0.5, y: 0.5}
@@ -137,7 +137,7 @@ BoxCollider2D:
drawMode: 0 drawMode: 0
adaptiveTiling: 0 adaptiveTiling: 0
m_AutoTiling: 0 m_AutoTiling: 0
m_Size: {x: 6.08, y: 1.5346009} m_Size: {x: 6.08, y: 0.8116592}
m_EdgeRadius: 0 m_EdgeRadius: 0
--- !u!251 &1230605949537068183 --- !u!251 &1230605949537068183
PlatformEffector2D: PlatformEffector2D:
+11 -14
View File
@@ -2,24 +2,21 @@ using UnityEngine;
public class PatternSelecter : MonoBehaviour public class PatternSelecter : MonoBehaviour
{ {
bool isStarting = true;
void Start() void Start()
{ {
foreach (Transform child in transform)
if (isStarting)
{ {
transform.GetChild(0).gameObject.SetActive(true); child.gameObject.SetActive(false);
} else
{
foreach (Transform child in transform)
child.gameObject.SetActive(false);
int randomIndex = Random.Range(1, transform.childCount);
transform.GetChild(randomIndex).gameObject.SetActive(true);
} }
if (TreeSpawner.treeCount == 0)
{
transform.GetChild(0).gameObject.SetActive(true);
}
else
{
int randomIndex = Random.Range(1, transform.childCount);
transform.GetChild(randomIndex).gameObject.SetActive(true);
}
} }
} }
+5
View File
@@ -7,6 +7,9 @@ public class TreeSpawner : MonoBehaviour
private bool hasSpawned = false; private bool hasSpawned = false;
public static int treeCount;
void Update() void Update()
{ {
if (hasSpawned == false) if (hasSpawned == false)
@@ -18,7 +21,9 @@ public class TreeSpawner : MonoBehaviour
float treeHeight = GetComponent<SpriteRenderer>().bounds.size.y; float treeHeight = GetComponent<SpriteRenderer>().bounds.size.y;
Vector3 spawnPos = transform.position + Vector3.down * treeHeight + new Vector3(0, 0.2f, 0); Vector3 spawnPos = transform.position + Vector3.down * treeHeight + new Vector3(0, 0.2f, 0);
treeCount++;
Instantiate(treePrefab, spawnPos, Quaternion.identity); Instantiate(treePrefab, spawnPos, Quaternion.identity);
} }
} }