void ClearPieceAt(List <GamePiece> gamePieces, List <GamePiece> bombedPieces) { foreach (var piece in gamePieces) { if (piece != null) { ClearPieceAt(piece.xIndex, piece.yIndex); int bonus = 0; if (gamePieces.Count >= 4) { bonus = 20; } piece.ScorePoints(m_scoreMultiplier, bonus); if (m_particleManager != null) { if (bombedPieces.Contains(piece)) { m_particleManager.BombFXAt(piece.xIndex, piece.yIndex); } else { m_particleManager.ClearPieceFXAt(piece.xIndex, piece.yIndex); } } } } }
// clear a list of GamePieces (plus a potential sublist of GamePieces destroyed by bombs) void ClearPieceAt(List <GamePiece> gamePieces, List <GamePiece> bombedPieces) { foreach (GamePiece piece in gamePieces) { if (piece != null) { // clear the GamePiece ClearPieceAt(piece.xIndex, piece.yIndex); // add a score bonus if we clear four or more pieces int bonus = 0; if (gamePieces.Count >= 4) { bonus = 20; } piece.ScorePoints(m_scoreMultiplier, bonus); // play particle effects for pieces... if (m_particleManager != null) { // ... cleared by bombs if (bombedPieces.Contains(piece)) { m_particleManager.BombFXAt(piece.xIndex, piece.yIndex); } // ... cleared normally else { m_particleManager.ClearPieceFXAt(piece.xIndex, piece.yIndex); } } } } }
//clear list of gamepieces (plus potential sublist of gamepieces destroyed by bombs) void ClearPiecesAt(List <GamePiece> gamePieces, List <GamePiece> bombedPieces) { //add score bonus if 4 or more pieces cleared int bonus = 0; if (gamePieces.Count >= 4) { bonus = 20; } foreach (GamePiece piece in gamePieces) { if (piece != null) { //clear the gamepiece ClearPieceAt(piece.xIndex, piece.yIndex); MarkAdjacentExplosions(piece.xIndex, piece.yIndex); if (GameManager.Instance != null) { //add bonus points GameManager.Instance.ScorePoints(piece, m_scoreMultiplier, bonus); //add time bonus if in timed mode TimeBonus timeBonus = piece.GetComponent <TimeBonus>(); if (timeBonus != null) { GameManager.Instance.AddTime(timeBonus.bonusValue); Debug.Log("adding time bonus from " + piece.name + " of " + timeBonus.bonusValue); } //update collection goals GameManager.Instance.UpdateCollectionGoals(piece); } //play particle effects for pieces destroyed if (m_particleManager != null) { if (bombedPieces.Contains(piece)) { m_particleManager.BombFXAt(piece.xIndex, piece.yIndex); } else { m_particleManager.ClearPieceFXAt(piece.xIndex, piece.yIndex); } } } } }
void ClearPieceAt(List <GamePiece> gamePieces, List <GamePiece> bombedPieces) { foreach (GamePiece piece in gamePieces) { if (piece != null) { ClearPieceAt(piece.xIndex, piece.yIndex); //Destroy gamepiece int bonus = 0; if (gamePieces.Count >= 4) { bonus = 20; //per gamepiece. } if (GameManager.Instance != null) { GameManager.Instance.ScorePoints(piece, m_scoreMultiplier, bonus); TimeBonus timeBonus = piece.GetComponent <TimeBonus>(); if (timeBonus != null) { GameManager.Instance.AddTime(timeBonus.bonusValue); //Debug.Log("BOARD Adding time bonus from " + piece.name + " of " + timeBonus.bonusValue); } GameManager.Instance.UpdateCollectionGoals(piece); //everytime we clear piece we check collection goals. } //piece.ScorePoints(m_scoreMultiplier, bonus); //piece to be destroyed, add score but if we destroy immidiately doesn't wait current frame to finish. if (m_particleManager != null) { if (bombedPieces.Contains(piece)) { m_particleManager.BombFXAt(piece.xIndex, piece.yIndex); } else { m_particleManager.ClearPieceFXAt(piece.xIndex, piece.yIndex); } } } } }
private void ClearPieceAt(List <GamePiece> gamePieces, List <GamePiece> bombedPieces) { foreach (GamePiece piece in gamePieces) { if (piece != null) { ClearPieceAt(piece.xIndex, piece.yIndex); int bonus = 0; if (gamePieces.Count >= 4) { bonus = 20; } if (GameManager.Instance != null) { GameManager.Instance.ScorePoints(piece, scoreMultiplier, bonus); TimeBonus timeBonus = piece.GetComponent <TimeBonus>(); if (timeBonus != null) { GameManager.Instance.AddTime(timeBonus.bonusValue); // Debug.Log("Board: adding time bonus from" + // piece.name + " of " + timeBonus.bonusValue); } GameManager.Instance.UpdateCollectionGoals(piece); } if (particleManager != null) { if (bombedPieces.Contains(piece)) { particleManager.BombFXAt(piece.xIndex, piece.yIndex); } else { particleManager.ClearPieceFXAt(piece.xIndex, piece.yIndex); } } } } }
void ClearPieceAt(List <GamePiece> gamePieces, List <GamePiece> bombedPieces) { foreach (GamePiece piece in gamePieces) { if (piece != null) { ClearPieceAt(piece.XIndex, piece.YIndex); int bonus = 0; if (gamePieces.Count >= 4) { bonus = 20; } if (GameManager.Instance != null) { GameManager.Instance.ScorePoints(piece, _scoreMultiplier, bonus); TimeBonus timeBonus = piece.GetComponent <TimeBonus>(); if (timeBonus != null) { GameManager.Instance.AddTime(timeBonus.BonusValue); } GameManager.Instance.UpdateCollectionGoals(piece); } if (_particlManager != null) { if (bombedPieces.Contains(piece)) { _particlManager.BombFXAt(piece.XIndex, piece.YIndex); } else { _particlManager.ClearPieceFXAt(piece.XIndex, piece.YIndex); } } } } }
// Overload to pass a list of game piece objects to the clear method private void ClearPieceAt(List <GamePiece> gamePieces, List <GamePiece> bombedPieces) { foreach (GamePiece piece in gamePieces) { if (piece != null) { ClearPieceAt(piece.xIndex, piece.yIndex); piece.ScorePoints(mScoreMultiplier); if (mParticleManager != null) { if (bombedPieces.Contains(piece)) { mParticleManager.BombFXAt(piece.xIndex, piece.yIndex); } else { mParticleManager.ClearPieceFXAt(piece.xIndex, piece.yIndex); } } } } }
// Clears the gamePieces and plays the proper clear or bomb FX. // Scores the pieces points void ClearPieceAt(List <GamePiece> gamePieces, List <GamePiece> bombedPieces) { foreach (GamePiece piece in gamePieces) { if (piece != null) { ClearPieceAt(piece.xIndex, piece.yIndex); int bonus = 0; if (gamePieces.Count >= 4) { bonus = 20; } piece.ScorePoints(m_scoreMultiplier, bonus); if (m_particleManager != null) { // play bombFX if (bombedPieces.Contains(piece)) { // get bomb component from gameObject // check that bomb component is not null // add bombType to paramaters m_particleManager.BombFXAt(piece.xIndex, piece.yIndex); } else { // play clearFX m_particleManager.ClearPieceFXAt(piece.xIndex, piece.yIndex); } } } } }