I was wondering what i could add to my code to have the score calculate really fast on click and touch, if a player does not want to sit and wait for it to finish calculating. Here is my current code
private mainRoot pMainRoot = null;
private int pScore = 0;
private int pFinalScore = 0;
private UILabel pPointsLable = null;
private UILabel pScoreLable = null;
private UILabel pBonusLable = null;
private UILabel pMultiplierLable = null;
private int pPoints = 0;
private int pCoins = 0;
private int pCombos = 0;
private int vCombos = 20;
private bool pTallyActive = false;
private int pTallyStage=0;
private int pTallyCycle = 0;
private int pTallyDelayCycle = 0;
//
private void Start () {
findObjects();
}
//
private void findObjects(){
pMainRoot = GameObject.Find ("mainRoot").GetComponent<mainRoot> ();
pPointsLable = GameObject.Find ("Label_points").GetComponent<UILabel> ();
pScoreLable = GameObject.Find ("Label_score").GetComponent<UILabel> ();
pBonusLable = GameObject.Find ("Label_bonus").GetComponent<UILabel> ();
pMultiplierLable = GameObject.Find ("Label_multiplier").GetComponent<UILabel> ();
}
//
public void takeScore(int vPoints, int vCoins, int vCombos){
traceOut ("takeScore");
pPoints = vPoints;
pCoins = vCoins;
pCombos = vCombos;
//for testing
//pPoints = 100;
//pCoins = 15;
//pCombos = 30;
}
//sent by intro animation event
public void introAnimationOver(){
pTallyActive = true;
nextTallyStage();
traceOut ("introAnimationOver");
}
//
private void Update () {
if (pTallyActive){
tallyScore();
}
}
//
private void tallyScore(){
pTallyDelayCycle++;
if (pTallyDelayCycle<2){
return;
}
pTallyDelayCycle = 0;
switch(pTallyStage){
case 1:
tallyPoints();
break;
case 2:
tallyCombos();
break;
case 3:
tallyCoins();
break;
case 4:
tallyFinalScore();
break;
}
}
//
private void playCoinSound(){
pMainRoot.pSoundManager.playBtnSound(2);
}
//
private void nextTallyStage(){
pTallyStage++;
pTallyCycle=0;;
}
//
private void tallyPoints(){
if (pTallyCycle<pPoints){
pTallyCycle++;
pPointsLable.text = "POINTS " + pTallyCycle;
//playCoinSound();
}else{
nextTallyStage();
}
}
//
//
private void tallyCombos(){
if (pTallyCycle<pCombos){
pTallyCycle++;
pMultiplierLable.text = "MULTIPLIER X" + pTallyCycle;
//playCoinSound();
}else{
nextTallyStage();
}
}
//
private void tallyCoins(){
if (pTallyCycle<pCoins){
pTallyCycle++;
pBonusLable.text = "BONUS ITEM X " + pTallyCycle;
//playCoinSound();
}else{
calculateFinalScore();
nextTallyStage();
}
}
//
private void calculateFinalScore(){
pFinalScore = pPoints + pCombos * 20 + pCoins * 50;
}
//
private void tallyFinalScore(){
if (pTallyCycle<pFinalScore){
pTallyCycle++;
}else{
pTallyActive = false;
}
string score = addCommasToScore(pTallyCycle);
//playCoinSound();
pScoreLable.text = "SCORE " + score;
}
//
private string addCommasToScore(int vScore){
string score = vScore.ToString( "n0" );
return (score);
}
//
private void traceOut (String txt) {
print ("scoreScreen: " + txt);
}
}