void CheckShootingControls() { if (Input.GetMouseButtonDown(0) || InputWrapper.Pressed(Control.Shoot)) { var color = shootQueue.GetNextPiece(); if (color != PieceColor.Undefined) { PieceFactory.CreateShootingPiece( color, shootQueuePiece.trans.position); Globals.cursor.PlayShootAnim(); snd.PlaySound(SjSounds.playerShoot01); UpdateNextPiece(); shootQueueHUD.UpdateHUD(ref shootQueue); } } }
public bool ScanForMatches() { // don't let any matches be counted if the game is over if (!Globals.player.IsActive) { return(false); } PieceColor prevColor1 = PieceColor.Undefined; PieceColor prevColor2 = PieceColor.Undefined; // the number of pieces (if any) that need to be cleared int clearCount = 0; // the starting index of pieces (if any) that needs to be cleared int clearFrom = 0; bool piecesAreShifting = false; for (int i = 0; i < CurrentSize; i++) { // skip any shifting pieces if (pieces[i].state == PieceState.Shifting) { piecesAreShifting = true; continue; } // skip any pieces that are not locked in position if (pieces[i].state != PieceState.InGrid) { continue; } PieceColor color = pieces[i].color; if (prevColor1 != PieceColor.Undefined && prevColor2 != PieceColor.Undefined) { bool matchFound = false; // if the piece we are shooting is wild if (color == PieceColor.Wild) { if (prevColor1 == prevColor2 || prevColor1 == PieceColor.Wild || prevColor2 == PieceColor.Wild) { matchFound = true; } } else { if ((prevColor1 == PieceColor.Wild || prevColor1 == color) && (prevColor2 == PieceColor.Wild || prevColor2 == color)) { matchFound = true; } } // check if we have a match if (matchFound) { int extra = 0; // check for a 4th match if (i < CurrentSize - 1 && pieces[i + 1].color == color) { extra++; // now check for a 5th match if (i < CurrentSize - 2 && pieces[i + 2].color == color) { extra++; } } clearCount = 3 + extra; clearFrom = i - 2; break; } } prevColor2 = prevColor1; prevColor1 = color; } if (clearCount > 0) { currentChain++; consecPiecesCleared += clearCount; ClearMatches(clearCount, clearFrom); // create wild pieces when enough pieces are cleared if (consecPiecesCleared >= pieceVars.wildStringCount) { PieceFactory.CreateWildPiece(); } // add time for consecutive chains Globals.gameTimer.AddSeconds((currentChain - 1) * bonusSecPerChain); } else if (!piecesAreShifting) { currentChain = 0; consecPiecesCleared = 0; } return(clearCount > 0); }
public override void Deactivate() { base.Deactivate(); PieceFactory.SetPieceColor(ref shootQueuePiece, PieceColor.Undefined); }