Add runner mechanics and travel asset library
This commit is contained in:
+17
-10
@@ -3,6 +3,7 @@
|
||||
// 발판으로서 필요한 동작을 담은 스크립트
|
||||
public class Platform : MonoBehaviour {
|
||||
public GameObject[] obstacles; // 장애물 오브젝트들
|
||||
public int emptyPatternWeight = 2; // 장애물이 없는 패턴이 선택될 가중치
|
||||
private bool stepped = false; // 플레이어 캐릭터가 밟았었는가
|
||||
|
||||
// 컴포넌트가 활성화될때 마다 매번 실행되는 메서드
|
||||
@@ -11,16 +12,22 @@ public class Platform : MonoBehaviour {
|
||||
|
||||
stepped = false;
|
||||
|
||||
for( int i = 0; i < obstacles.Length; i++)
|
||||
for(int i = 0; i < obstacles.Length; i++)
|
||||
{
|
||||
if(Random.Range(0,3) == 0)
|
||||
{
|
||||
obstacles[i].SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
obstacles[i].SetActive(false);
|
||||
}
|
||||
obstacles[i].SetActive(false);
|
||||
}
|
||||
|
||||
if(obstacles.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 낮은 장애물과 높은 장애물이 동시에 켜져 불가능한 배치가 되지 않도록 하나만 선택한다.
|
||||
int patternIndex = Random.Range(0, obstacles.Length + emptyPatternWeight);
|
||||
|
||||
if(patternIndex < obstacles.Length)
|
||||
{
|
||||
obstacles[patternIndex].SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,4 +39,4 @@ public class Platform : MonoBehaviour {
|
||||
GameManager.instance.AddScore(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user