treeSpawnCounter
This commit is contained in:
@@ -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:
|
||||||
|
|||||||
@@ -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)
|
||||||
|
{
|
||||||
|
child.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
if (isStarting)
|
if (TreeSpawner.treeCount == 0)
|
||||||
{
|
{
|
||||||
transform.GetChild(0).gameObject.SetActive(true);
|
transform.GetChild(0).gameObject.SetActive(true);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
foreach (Transform child in transform)
|
|
||||||
child.gameObject.SetActive(false);
|
|
||||||
|
|
||||||
int randomIndex = Random.Range(1, transform.childCount);
|
int randomIndex = Random.Range(1, transform.childCount);
|
||||||
|
|
||||||
transform.GetChild(randomIndex).gameObject.SetActive(true);
|
transform.GetChild(randomIndex).gameObject.SetActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user