// Use this for initialization public void Start() { buttonPressed = false; //Makes sure no button has been pressed hasRunned = false; //Makes sure no statIncreases has been runned //Shows the currentScore _myScore.ChangeScore(); _addStr = 10; _addAgi = 10; _addDef = 10; }
//DestroyMatchesAt is a helper function. It is used to destroy the tile in the given column and tile. //It instantiates particle effects with the color of the destroyed tile. //It calls ChangeScore from ScoreManager everytime a tile is destroyed. //If the given column and rows tile has isMatched bool true it does all that and returns true. //If it is false it returns false and does nothing. private bool DestroyMatchesAt(int column, int row) { if (allTiles[column, row].GetComponent <TileBehavior>().isMatched) { matchManager.currentMatches.Remove(allTiles[column, row]); string colorString = allTiles[column, row].tag; switch (colorString) { case "PurpleTile": destroyEffect.GetComponentInChildren <ParticleSystem>().startColor = Color.magenta; break; case "RedTile": destroyEffect.GetComponentInChildren <ParticleSystem>().startColor = Color.red; break; case "BlueTile": destroyEffect.GetComponentInChildren <ParticleSystem>().startColor = Color.blue; break; case "YellowTile": destroyEffect.GetComponentInChildren <ParticleSystem>().startColor = Color.yellow; break; case "GreenTile": destroyEffect.GetComponentInChildren <ParticleSystem>().startColor = Color.green; break; default: break; } GameObject particle = Instantiate(destroyEffect, allTiles[column, row].transform.position, Quaternion.identity); Destroy(particle, .5f); Destroy(allTiles[column, row]); allTiles[column, row] = null; scoreManager.ChangeScore(); bombCounter++; return(true); } return(false); }