public void DecreaseLife() { if (canBeHit) { hitAudioSource.Play(); lives--; PlayerStatusData playerData = PlayerStatusService.LoadPlayerStatus(); //Game Over if (lives <= 0) { SetDummyDeadPlayer(); gameOverManager.TakeScreenShot(); //Stop the score count scoreCounterManager.enabled = false; //Save player stats playerData.SetLifeBuff(0); int finalScore = scoreCounterManager.FinishAndGetFinalScore(); playerData.IncreaseScore(finalScore); PlayerStatusService.SavePlayerStatus(playerData); gameOverManager.SetGameOver(finalScore); DisablePlayer(); UpdateLifeText(); } else { //buffs means extra lives, so we reduce one from total amount of lives the player has playerData.SetLifeBuff(lives - 1); PlayerStatusService.SavePlayerStatus(playerData); UpdateLifeText(); //Make player invulnerable for few seconds SetPlayerInvulnerable(); } } }
bool GetPrizeObject(int prizeNum, bool bestPrize) { bool hasPrize = false; PlayerStatusData playerData = PlayerStatusService.LoadPlayerStatus(); switch (prizeNum) { case 1: //Life Buff GetLifePrize(bestPrize, playerData, prizeNum); hasPrize = true; break; case 2: //Extra Credits XXX resultPanelPrizeImg.sprite = spritesForResult[prizeNum]; if (bestPrize) { resultMsgTxt.text = string.Format("+300 {0}", creditsItem); playerData.IncreaseScore(300); } else { resultMsgTxt.text = string.Format("+50 {0}", creditsItem); playerData.IncreaseScore(50); } hasPrize = true; break; case 3: //Dash Upgrade if (bestPrize && playerData.CanUpgradeDash()) { playerData.IncreaseDashUpgrade(); resultMsgTxt.text = dashUpgradeItem; resultPanelPrizeImg.sprite = spritesForResult[prizeNum]; hasPrize = true; } else { resultMsgTxt.text = twoPointsDashWarningJackPot; } break; case 4: //New Skin if (bestPrize) { resultMsgTxt.text = skinItem; resultPanelPrizeImg.sprite = skinPrize; playerData.GetOwnedShipsIDs().Add(skinPrizeId); hasPrize = true; } else { resultMsgTxt.text = twoPointsSkinsWarningJackPot; } break; } PlayerStatusService.SavePlayerStatus(playerData); return(hasPrize); }