private IEnumerator _setPop(float duration, float offset, MoleHole[] moles, bool stagger, bool reverse) { yield return new WaitForSeconds(offset); if(!isRunning) { yield break; } if(reverse) { for(int i=moles.Length-1; i>=0;i--) { if(!moles[i].Raise(duration)) { // raising failed, take it off the total count waveTotal--; } if(stagger) { yield return new WaitForSeconds(duration / 10); if(!isRunning) { yield break; } } } } else { foreach(MoleHole mole in moles) { if(!mole.Raise(duration)) { // raising failed, take it off the total count waveTotal--; } if(stagger) { yield return new WaitForSeconds(duration / 10); if(!isRunning) { yield break; } } } } }
private void SetPop(float duration, float offset, MoleHole mole) { SetPop(duration, offset, new MoleHole[] { mole }, false); }
private void SetPop(float duration, float offset, MoleHole[] moles, bool stagger = false, bool reverse = false) { waveTotal += moles.Length; StartCoroutine(_setPop(duration, offset, moles, stagger, reverse)); }
private void InitMoles() { moles = moleHolder.GetComponentsInChildren<MoleHole>(); System.Array.Sort(moles, (x, y) => x.name.CompareTo(y.name)); // create some convience arrays for making patterns rowBottom = new MoleHole[] { moles[0], moles[1], moles[2] }; rowMid = new MoleHole[] { moles[5], moles[6], moles[7] }; rowTop = new MoleHole[] { moles[10], moles[11], moles[12] }; columnLeft = new MoleHole[] { moles[0], moles[5], moles[10] }; columnMid = new MoleHole[] { moles[1], moles[6], moles[11] }; columnRight = new MoleHole[] { moles[2], moles[7], moles[12] }; /// diagonals start at bottom, without number is "big", two numbers /// are smaller ones /// L L1 L2 /// . . * . . . . * . /// . * . . * . /// . * . . . * * . . /// * . . * . . /// * . . . * . . . . diagonalL = new MoleHole[] { moles[0], moles[3], moles[6], moles[9], moles[12] }; diagonalL1 = new MoleHole[] { moles[1], moles[4], moles[7] }; diagonalL2 = new MoleHole[] { moles[5], moles[8], moles[11] }; diagonalR = new MoleHole[] { moles[2], moles[4], moles[6], moles[8], moles[10] }; diagonalR1 = new MoleHole[] { moles[1], moles[3], moles[5] }; diagonalR2 = new MoleHole[] { moles[7], moles[9], moles[11] }; squareInner = new MoleHole[] { moles[3], moles[4], moles[8], moles[9] }; squareOuter = new MoleHole[] { moles[0], moles[2], moles[10], moles[12] }; }