//function aim to check if current fill level is ready for state change void CheckColorStateChange() { //print("curLevel: " + curPaintLevel + " " + myPaintState); //call change state function to change the state to clean when curPaintLevel is 0 if (curPaintLevel == 0 && myPaintState != ColorState.Clean) { //print("get cleaned canRecoverTIle: " + canTileRecover); isStateChangedTF = true; ChangePaintState(ColorState.Clean); curColorState = ColorState.Clean; curRecoverTimer = 0.0f; CheckTileRecover(); isOwned = false; //set spill effect to false TowerSpillEffect.SetActive(false); } //call change state function to change the state to the target color when curPaintLevel is full if (curPaintLevel == fullPaintLevel && myPaintState == ColorState.Clean) { isStateChangedTF = true; ChangePaintState(curColorState); //add exp to player when it is colored to another state if (curColorState == ColorState.Blue) { ExpController expSc = bluePlayer.GetComponent <ExpController>(); if (expSc != null) { expSc.AddExp(100); } mMetricsManager.setTowersPainted(0, 1); //set blue spill color TurnOnTowerSpill(blueSpillColor); } else { ExpController expSc = redPlayer.GetComponent <ExpController>(); if (expSc != null) { expSc.AddExp(100); } mMetricsManager.setTowersPainted(1, 1); TurnOnTowerSpill(redSpillColor); } CheckTileRecover(); //print("*isstatechangedTF: " + isStateChangedTF); } }