private void OnClick() { if (state == STATE_SELECTED) { Debug.Log("type: " + type + ", this phone is already in use"); return; } else if (state == STATE_UNSELECTED) { gameRecord.SetPhoneInUse(phoneRecord); ChangeBtnState(STATE_SELECTED); UnselectedOthers(); SoundManager.instance.playSingle(selectEfx); Debug.Log("type: " + type + ", you select this phone"); } else if (state == STATE_NOTHAVE) { if (HasEnoughMoney()) { gameRecord.userRecord.coins -= price; money.text = gameRecord.userRecord.coins.ToString(); ChangeBtnState(STATE_UNSELECTED); phoneRecord = new GameRecord.PhoneRecord(type, false); gameRecord.userRecord.AddPhone(phoneRecord); Register(); SoundManager.instance.playSingle(buyEfx); Debug.Log("type: " + type + ", congratulation, you bought a new phone successfully"); } else { Debug.Log("type: " + type + ", sorry, but you don't have enough money to buy this phone"); } } gameRecord.Save(); }
void Awake() { Screen.SetResolution(Screen.width, -1, true); if (instance == null) { instance = this; } else if (instance != this) { Destroy(this); } user = GameRecord.getInstance().userRecord; phoneInUse = GameRecord.getInstance().phoneInUse; scoresRecord = GameRecord.getInstance().scoresRecord; ui = new UI(); eliTotalNumList = new int[5]; timeLeft = totalTime = 30 + (phoneInUse.elementRecords[Element.TYPE_BATTERY].level - 1) * 5.0f; costPerError = (20 - phoneInUse.elementRecords[Element.TYPE_GPU].level * 2); scorePerEli = (10 + (phoneInUse.elementRecords[Element.TYPE_CPU].level - 1) * 2); SoundManager.instance.PlayBGM(SoundManager.instance.game); }
private void InitState() { phoneRecord = gameRecord.userRecord.GetPhoneByType(type); if (phoneRecord == null) { state = STATE_NOTHAVE; } else { Register(); if (gameRecord.phoneInUse.type == type) { state = STATE_SELECTED; } else { state = STATE_UNSELECTED; } } ChangeBtnState(state); Debug.Log("type: " + type + ", state: " + state); }