public IEnumerator CreateLevel() { while (GameBlockStart == null) { yield return(new WaitForSeconds(1)); } game_speed *= 0.5f; Path.Clear(); healt = 3; CheckPoint = new Vector3(0, 0, 0); this.gameObject.transform.position = CheckPoint; this.gameObject.GetComponent <Animator>().enabled = true; Transform l_end_pos; GameBlockStart.GetGameObject().transform.position = new Vector3(0, 0, 0); GameBlockStart.GetGameObject().SetActive(true); l_end_pos = GameBlockStart.GetEndPos(); Path.AddRange(GameBlockStart.GetPath()); int random; foreach (IGameBlock t in GameBlockList) { t.SpeedUp(game_speed); random = Random.Range(0, 8); if (random == 3) { t.GetGameObject().transform.position = l_end_pos.position; t.StartAnimation(); t.GetGameObject().SetActive(true); l_end_pos = t.GetEndPos(); Path.AddRange(t.GetPath()); } else { t.StopAnimation(); t.GetGameObject().SetActive(false); } } GameBlockEnd.GetGameObject().transform.position = l_end_pos.position; GameBlockEnd.GetGameObject().SetActive(true); Path.AddRange(GameBlockEnd.GetPath()); GameStart = true; Target = Path[0]; }
private void InitBlocks() { GameBlockStart = (Instantiate(BlockStartPrefab, new Vector3(0, 0, 0), Quaternion.identity)).GetComponent <IGameBlock>(); GameBlockStart.GetGameObject().SetActive(false); GameBlockEnd = (Instantiate(BlockEndPrefab, new Vector3(0, 0, 0), Quaternion.identity)).GetComponent <IGameBlock>(); GameBlockEnd.GetGameObject().SetActive(false); for (int i = 0; i < 10; i++) { GameBlockList.Add((Instantiate(Block1Prefab, new Vector3(0, 0, 0), Quaternion.identity)).GetComponent <IGameBlock>()); GameBlockList.Add((Instantiate(Block2Prefab, new Vector3(0, 0, 0), Quaternion.identity)).GetComponent <IGameBlock>()); GameBlockList.Add((Instantiate(Block3Prefab, new Vector3(0, 0, 0), Quaternion.identity)).GetComponent <IGameBlock>()); } foreach (IGameBlock t in GameBlockList) { t.GetGameObject().SetActive(false); } }