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_CompositeOperation: 0
m_CompositeOrder: 0
m_Offset: {x: 0, y: -0.61813337}
m_Offset: {x: 0, y: -0.299548}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
@@ -137,7 +137,7 @@ BoxCollider2D:
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
m_Size: {x: 6.08, y: 1.5346009}
m_Size: {x: 6.08, y: 0.8974301}
m_EdgeRadius: 0
--- !u!251 &1230605949537068183
PlatformEffector2D:
@@ -127,7 +127,7 @@ BoxCollider2D:
m_UsedByEffector: 1
m_CompositeOperation: 0
m_CompositeOrder: 0
m_Offset: {x: 0, y: -0.61813337}
m_Offset: {x: 0, y: -0.25666255}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
@@ -137,7 +137,7 @@ BoxCollider2D:
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
m_Size: {x: 6.08, y: 1.5346009}
m_Size: {x: 6.08, y: 0.8116592}
m_EdgeRadius: 0
--- !u!251 &1230605949537068183
PlatformEffector2D:
+7 -10
View File
@@ -2,24 +2,21 @@ using UnityEngine;
public class PatternSelecter : MonoBehaviour
{
bool isStarting = true;
void Start()
{
foreach (Transform child in transform)
{
child.gameObject.SetActive(false);
}
if (isStarting)
if (TreeSpawner.treeCount == 0)
{
transform.GetChild(0).gameObject.SetActive(true);
} else
}
else
{
foreach (Transform child in transform)
child.gameObject.SetActive(false);
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;
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);
}
}