void Awake() { // Initialize self. BoxCol = GetComponent <Collider> (); rb = GetComponent <Rigidbody> (); rend = GetComponentInChildren <MeshRenderer> (true); InvokeRepeating("CheckBounds", 0, 0.5f); normalBlockTypeListLength = System.Enum.GetValues(typeof(mainBlockType)).Length; if (isBossPart == false && isBonusBlock == false) { BlockChecker.Instance.BlocksInstanced.Add(gameObject); } // Static: Don't change type, update once. if (BlockChangeType == blockChangeType.Static) { UpdateBlockType(); return; } // Random once: Change type once randomly, update self. if (BlockChangeType == blockChangeType.RandomOnce) { BlockType = (mainBlockType)(Random.Range(0, 4)); UpdateBlockType(); return; } Invoke("AllowParticleCollisionBossNow", 2); UpdateBlockType(); }
// Scroll block type sequentially. void SequentialScroll() { // Increment block type index if still going through the list. if (BlockType < (mainBlockType)normalBlockTypeListLength) { BlockType += 1; } // Reset block type index when end of list is reached. if (BlockType >= (mainBlockType)normalBlockTypeListLength) { BlockType = 0; } }
void SetNewBlockType() { if (isBossPart == false && isBonusBlock == false) { if (GameController.Instance.Wave < 5) { int BlockId = Random.Range(0, GameController.Instance.Wave); BlockType = (mainBlockType)BlockId; } else { int BlockId = Random.Range(0, 4); BlockType = (mainBlockType)BlockId; } } }
// Change block type in list randomly. void RandomScroll() { BlockType = (mainBlockType)Random.Range(0, normalBlockTypeListLength); }