// Update is called once per frame void Update() { if (!registered && (collisionCount > maxCollisionCount || Time.time > birthTime + lifeTime)) { explosion.CreateExplosion(transform.position); Destroy(gameObject); } }
// Update is called once per frame void Update() { if (temp_ballstobeChanged - ballsToBeChanged >= 2) { col_recurse = false; } float mag = GetComponent <Rigidbody>().velocity.magnitude; if (mag < speedLimit && mag > 0f) { GetComponent <Rigidbody>().velocity = speedLimit / mag * GetComponent <Rigidbody>().velocity; } if (hitCount > 3) { explosion.CreateExplosion(transform.position); Destroy(gameObject); } }
void CheckColor() { if (insertionQueue.Count == 0 && checkColorTable.Count > 0 && Time.time > checkColorRegisterTime + checkColorDelay) { foreach (KeyValuePair <GameObject, CheckColorTableEntry> kvpair in checkColorTable) { if (kvpair.Value.covered == false) { int idx = balls.IndexOf(kvpair.Key); if (idx < 0) { Debug.LogWarning("Ball not in Chain " + kvpair.Key.name + "ID: " + kvpair.Key.GetInstanceID()); // continue seems to avoid the bug // value.cover not work well continue; } int prevCount = 0; int nextCount = 0; int counterMagicCount = 0; if (!brokenChainNodeSet.Contains(kvpair.Key)) { foreach (GameObject ball in balls.GetRange(idx + 1, balls.Count - (idx + 1))) { if (ball.tag == kvpair.Key.tag || ball.tag == "CounterMagic") { nextCount++; if (checkColorTable.ContainsKey(kvpair.Key)) { kvpair.Value.covered = true; } if (brokenChainNodeSet.Contains(ball)) { break; } } else { break; } } } ArrayList reverseBalls = new ArrayList(balls.GetRange(0, idx)); reverseBalls.Reverse(); foreach (GameObject ball in reverseBalls) { if ((ball.tag == kvpair.Key.tag || ball.tag == "CounterMagic") && (!brokenChainNodeSet.Contains(ball))) { prevCount++; if (checkColorTable.ContainsKey(kvpair.Key)) { Debug.Log(kvpair.Key.name + " ID: " + kvpair.Key.GetInstanceID() + " is covered in combo"); kvpair.Value.covered = true; } if (ball.tag == "CounterMagic") { counterMagicCount++; } } else { break; } } if (prevCount + nextCount + 1 > 2) { GameObject head, tail; head = (GameObject)balls[idx - prevCount]; tail = (GameObject)balls[idx + nextCount]; combo++; health.GetDamage(prevCount + nextCount + 1 - counterMagicCount, counterMagicCount, combo); soundManager.PlayComboAudio(); if (brokenChainNodeSet.Contains(head)) { Debug.LogError("Chain with same color crosses gap"); } if (brokenChainNodeSet.Contains(tail)) { brokenChainNodeSet.Remove(tail); } if (idx - prevCount > 0) { GameObject headHead = (GameObject)balls[idx - prevCount - 1]; if (!brokenChainNodeSet.Contains(headHead)) { brokenChainNodeSet.Add(headHead); brokenChainNodeDirty = true; } } foreach (GameObject ball in balls.GetRange(idx - prevCount, prevCount + nextCount + 1)) { explosion.CreateExplosion(ball.transform.position); Destroy(ball); } balls.RemoveRange(idx - prevCount, prevCount + nextCount + 1); } } } checkColorTable.Clear(); } }