// Use this for initialization void Awake() { play = GameObject.Find("play").GetComponent <Button>(); store = GameObject.Find("store").GetComponent <Button>(); coin = GameObject.Find("coin"); gameTitle = GameObject.Find("kids-see-ghosts").GetComponent <Image>(); levelSelectCanvas = GameObject.Find("level-select"); levelSelectCanvas.SetActive(false); playOrigin = play.transform.position; storeOrigin = store.transform.position; coinOrigin = coin.transform.position; play.onClick.AddListener(delegate { GameObject.Find("logo").SetActive(false); levelSelectCanvas.SetActive(true); this.gameObject.SetActive(false); }); store.onClick.AddListener(delegate { Application.OpenURL("https://www.kickstarter.com/projects/1538450318/1618577795"); }); score.text = CustomPlayerPrefs.GetInt("Score", 0).ToString(); Screen.orientation = ScreenOrientation.LandscapeLeft; }
private int initPicture() { int createdButtonCount = 0; PictureObject pictureTable = LobbyManager.Instance.DT.Picture; int count = pictureTable.Count; for (int id = 0; id < count; ++id) { if (AlbumId != pictureTable[id].albumId) { continue; } string key = PlayerPrefsKey.GetKey(PlayerPrefsKey.ISLOCKED_PICTURE, id); int value = CustomPlayerPrefs.GetInt(key, PlayerPrefsKey.TRUE_INTEGER); bool isLocked = PlayerPrefsKey.GetIntToBool(value); CGThumbnailButton btn = create(); btn.Set(pictureTable[id].sprite, AlbumType, isLocked); ++createdButtonCount; } return(createdButtonCount); }
void loadPrefs() { if (CustomPlayerPrefs.HasKey("selectedMaskID")) { selectedMaskID = CustomPlayerPrefs.GetInt("selectedMaskID"); Debug.Log("prefered selectedMaskID detected"); } if (CustomPlayerPrefs.HasKey("isMaskFlipped")) { isFlipped = CustomPlayerPrefs.GetBool("isMaskFlipped"); Debug.Log("prefered isMaskFlipped detected"); } if (CustomPlayerPrefs.HasKey("maskScale")) { maskScale = CustomPlayerPrefs.GetFloat("maskScale"); Debug.Log("prefered maskScale detected"); } else { maskScale = 11.2f; } if (CustomPlayerPrefs.HasKey("maskColor_R")) { float red = CustomPlayerPrefs.GetFloat("maskColor_R"); float green = CustomPlayerPrefs.GetFloat("maskColor_G"); float blue = CustomPlayerPrefs.GetFloat("maskColor_B"); maskMat.SetColor("_Color", new Color(red, green, blue, maskMat.GetColor("_Color").a)); } if (CustomPlayerPrefs.HasKey("maskAlpha")) { float alpha = CustomPlayerPrefs.GetFloat("maskAlpha"); maskMat.SetColor("_Color", new Color(maskMat.GetColor("_Color").r, maskMat.GetColor("_Color").g, maskMat.GetColor("_Color").b, alpha)); } }
// private void autoSaveNurture() { Nurture.Calendar calendar = NurtureMode.Calendar; CustomPlayerPrefs.SetInt(PlayerPrefsKey.YEAR, calendar.Year); CustomPlayerPrefs.SetInt(PlayerPrefsKey.MONTH, calendar.Month); Nurture.Character nurtureCharacter = NurtureMode.Character; int condition = (int)nurtureCharacter.Condition; CustomPlayerPrefs.SetInt(PlayerPrefsKey.CONDITION, condition); int actionCount = Manager.Instance.DT.Action.Count; for (int id = 0; id < actionCount; ++id) { string key = PlayerPrefsKey.GetKey(PlayerPrefsKey.ACTION_COUNT, id); CustomPlayerPrefs.SetInt(key, nurtureCharacter.GetActionCount(id)); } CustomPlayerPrefs.SetInt(PlayerPrefsKey.MONEY, nurtureCharacter.Money); CustomPlayerPrefs.SetInt(PlayerPrefsKey.STRESS, nurtureCharacter.Stress); CustomPlayerPrefs.SetInt(PlayerPrefsKey.STAMINA, nurtureCharacter.Stamina); CustomPlayerPrefs.SetInt(PlayerPrefsKey.INTELLECT, nurtureCharacter.Intellect); CustomPlayerPrefs.SetInt(PlayerPrefsKey.GRACE, nurtureCharacter.Grace); CustomPlayerPrefs.SetInt(PlayerPrefsKey.CHARM, nurtureCharacter.Charm); CustomPlayerPrefs.SetInt(PlayerPrefsKey.ATTACK, nurtureCharacter.Attack); CustomPlayerPrefs.SetInt(PlayerPrefsKey.DEFENSE, nurtureCharacter.Defense); CustomPlayerPrefs.SetInt(PlayerPrefsKey.LEADERSHIP, nurtureCharacter.Leadership); CustomPlayerPrefs.SetInt(PlayerPrefsKey.TACTIC, nurtureCharacter.Tactic); CustomPlayerPrefs.SetInt(PlayerPrefsKey.MORALITY, nurtureCharacter.Morality); CustomPlayerPrefs.SetInt(PlayerPrefsKey.GOODNESS, nurtureCharacter.Goodness); CustomPlayerPrefs.SetInt(PlayerPrefsKey.SENSIBILITY, nurtureCharacter.Sensibility); CustomPlayerPrefs.SetInt(PlayerPrefsKey.ARTS, nurtureCharacter.Arts); }
private Story.TargetCharacter loadTargetCharacter() { int targetId = CustomPlayerPrefs.GetInt(PlayerPrefsKey.TARGET, -1); if (-1 == targetId) { Log.Debug("not found target -> startPrologue."); return(null); } int feeling = CustomPlayerPrefs.GetInt(PlayerPrefsKey.FEELING, -1); if (feeling < 0) { Log.Error(string.Format("not found '{0}'", PlayerPrefsKey.FEELING)); return(null); } int lastOpenedScenarioNo = CustomPlayerPrefs.GetInt(PlayerPrefsKey.LAST_OPENED_SCENARIO_NO, -10); if (-10 == lastOpenedScenarioNo) { Log.Error(string.Format("not found '{0}'", PlayerPrefsKey.LAST_OPENED_SCENARIO_NO)); return(null); } Story.TargetCharacter tc = new Story.TargetCharacter(targetId, feeling, lastOpenedScenarioNo); return(tc); }
void Awake() { muteSfx = CustomPlayerPrefs.GetInt("MuteSfx", 0) == 1; muteMusic = CustomPlayerPrefs.GetInt("MuteMusic", 0) == 1; muteSfxImg = GameObject.Find("mute-sfx").GetComponent <Image>(); muteMusicImg = GameObject.Find("mute-music").GetComponent <Image>(); GameObject.Find("mute-sfx").GetComponent <Button>().onClick.AddListener(delegate { muteSfx = !muteSfx; CustomPlayerPrefs.SetInt("MuteSfx", muteSfx ? 1 : 0); GameObject.FindGameObjectWithTag("Player").GetComponent <PlayableCharacter>().muteSfx = muteSfx; PrefsChanged.Invoke(); CustomPlayerPrefs.Save(); }); GameObject.Find("mute-music").GetComponent <Button>().onClick.AddListener(delegate { muteMusic = !muteMusic; CustomPlayerPrefs.SetInt("MuteMusic", muteMusic ? 1 : 0); GameObject.FindGameObjectWithTag("Player").GetComponent <PlayableCharacter>().muteMusic = muteMusic; PrefsChanged.Invoke(); CustomPlayerPrefs.Save(); }); GameObject.Find("resume").GetComponent <Button>().onClick.AddListener(delegate { Time.timeScale = 1.0f; Destroy(this.gameObject); }); GameObject.Find("restart").GetComponent <Button>().onClick.AddListener(delegate { Time.timeScale = 1.0f; Application.LoadLevel(Application.loadedLevel); }); #if UNITY_WEBGL Destroy(GameObject.Find("main-menu")); #else GameObject.Find("main-menu").GetComponent <Button>().onClick.AddListener(delegate { Time.timeScale = 1.0f; Application.LoadLevel("main-menu"); }); #endif }
private void SaveCurrencies(List <Currency> currencies) { for (int i = 0; i < currencies.Count; i++) { CustomPlayerPrefs.SetFloat(currencies[i].Name, currencies[i].Value); } }
new public void Start() { base.Start(); muteSfx = CustomPlayerPrefs.GetInt("MuteSfx", 0) > 0; muteMusic = CustomPlayerPrefs.GetInt("MuteMusic", 0) > 0; music = GameObject.FindGameObjectWithTag("Music").GetComponent <AudioSource>(); audioSource = this.GetComponent <AudioSource>(); followCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>(); UpdateAudio(); #if UNITY_EDITOR max_health = 500; #endif health = max_health; num_coins_start = GameObject.FindGameObjectsWithTag("Coin").Length; if (GameObject.Find("boss") != null) { oldStars = CustomPlayerPrefs.GetInt("LastStars", 0); } #if UNITY_WEBGL || UNITY_EDITOR foreach (GameObject mobile_ui_elem in GameObject.FindGameObjectsWithTag("Mobile UI")) { Destroy(mobile_ui_elem); } #else Screen.orientation = ScreenOrientation.LandscapeLeft; #endif foreach (GameObject mobile_ui_elem in GameObject.FindGameObjectsWithTag("Mobile UI")) { buttons.Add(mobile_ui_elem.name, mobile_ui_elem.GetComponent <MobileButton>()); } pauseButton.onClick.AddListener(delegate { if (GameObject.FindGameObjectWithTag("PauseScreen") == null) { Time.timeScale = 0; Instantiate(pauseScreen, GameObject.Find("UI").transform).GetComponent <PauseScreen>().PrefsChanged += UpdateAudio; } else { Time.timeScale = 1; Destroy(GameObject.FindGameObjectWithTag("PauseScreen")); } }); #if UNITY_WEBGL nextLevel = "webgl-ad"; #endif if (checkpoint != null) { checkpoint.OnRespawn += delegate { GameObject.Find("music").GetComponent <AudioSource>().mute = muteMusic; } } ; }
private IUserStats LoadUserStats() { IUserStats inventory = new UserStats(); inventory.IsFirstSession = CustomPlayerPrefs.GetBool(StringConstants.PlayerPrefsKeys.FirstSession, true); inventory.TutorialStage = CustomPlayerPrefs.GetInt(StringConstants.PlayerPrefsKeys.TutorialStage, 0); return(inventory); }
private IGameOptions LoadGameOptions() { IGameOptions gameOptions = new GameOptions(); gameOptions.IsSoundOn = CustomPlayerPrefs.GetBool(StringConstants.PlayerPrefsKeys.IsSoundOn, true); gameOptions.IsMusicOn = CustomPlayerPrefs.GetBool(StringConstants.PlayerPrefsKeys.IsMusicOn, true); return(gameOptions); }
private List <Currency> LoadCurrencies() { GameConfig gameConfig = ConfigManager.Instance.Get <GameConfig>(); List <Currency> currencies = new List <Currency>(); currencies.Add(new Dollar(CustomPlayerPrefs.GetFloat(StringConstants.PlayerPrefsKeys.Dollar, gameConfig.StartDollars))); currencies.Add(new Respect(CustomPlayerPrefs.GetFloat(StringConstants.PlayerPrefsKeys.Respect, gameConfig.StartRespect))); return(currencies); }
void OnApplicationQuit() { CustomPlayerPrefs.SetBool("isMaskFlipped", isFlipped, true); CustomPlayerPrefs.SetFloat("maskScale", maskScale, true); CustomPlayerPrefs.SetInt("selectedMaskID", selectedMaskID, true); CustomPlayerPrefs.SetFloat("maskAlpha", maskMat.GetColor("_Color").a, true); CustomPlayerPrefs.SetFloat("maskColor_R", maskMat.GetColor("_Color").r, true); CustomPlayerPrefs.SetFloat("maskColor_G", maskMat.GetColor("_Color").g, true); CustomPlayerPrefs.SetFloat("maskColor_B", maskMat.GetColor("_Color").b, true); }
void Start() { if (CustomPlayerPrefs.HasKey("eventsJSON")) { //print(CustomPlayerPrefs.GetString("eventsJSON", CustomPlayerPrefs.DEFAULT_STRING)); //test eventsJSON = CustomPlayerPrefs.GetObjectValue <JSON>("eventsJSON"); string json = JsonUtility.ToJson(eventsJSON); print(json); coroutine = WaitAndSend(); StartCoroutine(coroutine); } }
public override bool Play() { Log.Debug(ToString()); Mode.CmdPictureEvent.Invoke(Id); string key = PlayerPrefsKey.GetKey(PlayerPrefsKey.ISLOCKED_PICTURE, Id); int value = PlayerPrefsKey.GetBoolToInt(false); CustomPlayerPrefs.SetInt(key, value); return(false); // no more child to play }
// Update is called once per frame public void play() { click.Play(); if (CustomPlayerPrefs.LevelPotence() > 1) { SceneManager.LoadScene(CustomPlayerPrefs.LevelPotence() + 1); } else { SceneManager.LoadScene(5); } //done }
public void CreateTargetCharacter(int targetId) { if (false == ExtTarget.isValid(targetId)) { Log.Error(string.Format("invalid target id; {0}", targetId)); return; } CustomPlayerPrefs.SetInt(PlayerPrefsKey.TARGET, targetId); Story.TargetCharacter tc = loadTargetCharacter(); StoryMode.Set(tc); startTargetPrologue(tc); }
public bool IsContinueData() { string invalidName = string.Empty; string playerName = CustomPlayerPrefs.GetString(CONTINUE_KEY, invalidName); if (playerName.Equals(invalidName)) { return(false); } else { return(true); } }
protected override void first() { string prefixKey = null; if (_mode.Character.IsChildHood()) prefixKey = PlayerPrefsKey.ISLOCKED_VACATION_CHILD; else prefixKey = PlayerPrefsKey.ISLOCKED_VACATION_ADULT; string key = PlayerPrefsKey.GetKey(prefixKey, _seasonId); int value = PlayerPrefsKey.GetBoolToInt(false); CustomPlayerPrefs.SetInt(key, value); _mode.Schedule.ActionFirstEvent.Invoke(); }
private void onScenarioEnd() { if (false == _isStartTargetScenario) { return; } _isStartTargetScenario = false; Story.TargetCharacter target = StoryMode.TargetCharacter; target.NextScenarioNo(); CustomPlayerPrefs.SetInt(PlayerPrefsKey.FEELING, target.Feeling); CustomPlayerPrefs.SetInt(PlayerPrefsKey.LAST_OPENED_SCENARIO_NO, target.LastOpenedScenarioNo); }
private void OnTriggerEnter(Collider other) { if (other.name == "Player") { LevelCompleteUI.SetActive(true); CustomPlayerPrefs.LevelUpdate(CustomPlayerPrefs.LevelPotence() + 1); if (CustomPlayerPrefs.LevelPotence() == 4) { CustomPlayerPrefs.LevelUpdate(0); } Time.timeScale = 0f; //SceneManager.LoadScene(sceneToLoad); } }
private IEnumerator WaitAndSend() { CR_running = true; yield return(new WaitForSeconds(cooldownBeforeSend)); string json = JsonUtility.ToJson(eventsJSON); print(json); CustomPlayerPrefs.SetString("eventsJSON", json); try { var httpWebRequest = (HttpWebRequest)WebRequest.Create(serverUrl); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "POST"; using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { streamWriter.Write(json); } var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { if (httpResponse.StatusCode == HttpStatusCode.OK) { eventsJSON.events.Clear(); CR_running = false; CustomPlayerPrefs.DeleteKey("eventsJSON"); } else { coroutine = WaitAndSend(); StartCoroutine(coroutine); } } } catch (Exception ex) { coroutine = WaitAndSend(); StartCoroutine(coroutine); } }
public void FinishLevel() { if (oldStars == 0) { float prop_coin = score / (float)num_coins_start; stars = (prop_coin > .5f) ? (prop_coin > .8f ? 2 : 1) : 0; if (health > 0) { stars++; } } else { stars = oldStars; } if (this.transform.position.y < 0 || health <= 0) { stars = 0; } else { this.audioSource.PlayOneShot(victorySound); CustomPlayerPrefs.SetString("Level", nextLevel); CustomPlayerPrefs.SetInt("Score", score + CustomPlayerPrefs.GetInt("Score", 0)); CustomPlayerPrefs.SetInt("LastStars", stars); Helpers.ChangeUserProgress(saveLevel == null ? Application.loadedLevelName : saveLevel, stars); } if (nextLevel.Contains("boss") && stars > 0 && !Application.loadedLevelName.Contains("boss")) { Application.LoadLevel(nextLevel); } else if (!Application.loadedLevelName.Contains("boss") || stars == 0) { EndScreen end = Instantiate(endScreen, GameObject.Find("UI").transform).GetComponent <EndScreen>(); end.checkpoint = checkpoint; end.nextLevel = nextLevel; Time.timeScale = 0; GameObject.Find("music").GetComponent <AudioSource>().mute = true; } }
private void onNurtureEndingScenarioEnd() { Log.Debug("onNurtureEndingScenarioEnd"); StoryMode.ScenarioEndEvent.Detach(onNurtureEndingScenarioEnd); string key = PlayerPrefsKey.GetKey(PlayerPrefsKey.ISLOCKED_NURTURE_ENDING, _nurtureEndingId); int value = PlayerPrefsKey.GetBoolToInt(false); CustomPlayerPrefs.SetInt(key, value); if (Def.NURTURE_BAD_ENDING_ID == _nurtureEndingId) { Manager.Instance.End(); return; } _nurtureEndingId = -1; EndNurtureEvent.Invoke(); }
/********** Load **********/ private Nurture.Calendar loadCalendar() { int year = CustomPlayerPrefs.GetInt(PlayerPrefsKey.YEAR, -1); if (year < 0) { Log.Error(string.Format("not found '{0}'", PlayerPrefsKey.YEAR)); return(null); } int month = CustomPlayerPrefs.GetInt(PlayerPrefsKey.MONTH, -1); if (month < 0) { Log.Error(string.Format("not found '{0}'", PlayerPrefsKey.MONTH)); return(null); } Nurture.Calendar calendar = new Nurture.Calendar(year, month, Def.INIT_DAY); return(calendar); }
private int initNurtureEnding() { int createdButtonCount = 0; NurtureEndingObject nurtureEndingTable = LobbyManager.Instance.DT.NurtureEnding; int count = nurtureEndingTable.Count; for (int id = 0; id < count; ++id) { string key = PlayerPrefsKey.GetKey(PlayerPrefsKey.ISLOCKED_NURTURE_ENDING, id); int value = CustomPlayerPrefs.GetInt(key, PlayerPrefsKey.TRUE_INTEGER); bool isLocked = PlayerPrefsKey.GetIntToBool(value); CGThumbnailButton btn = create(); btn.Set(nurtureEndingTable[id].image, AlbumType, isLocked); ++createdButtonCount; } return(createdButtonCount); }
private void loadAllStat(Nurture.Character character) { if (null == character) { Log.Error("not found Nurture.Character"); return; } int stress = CustomPlayerPrefs.GetInt(PlayerPrefsKey.STRESS, -1); int stamina = CustomPlayerPrefs.GetInt(PlayerPrefsKey.STAMINA, -1); int intellect = CustomPlayerPrefs.GetInt(PlayerPrefsKey.INTELLECT, -1); int grace = CustomPlayerPrefs.GetInt(PlayerPrefsKey.GRACE, -1); int charm = CustomPlayerPrefs.GetInt(PlayerPrefsKey.CHARM, -1); int attack = CustomPlayerPrefs.GetInt(PlayerPrefsKey.ATTACK, -1); int defense = CustomPlayerPrefs.GetInt(PlayerPrefsKey.DEFENSE, -1); int leadership = CustomPlayerPrefs.GetInt(PlayerPrefsKey.LEADERSHIP, -1); int tactic = CustomPlayerPrefs.GetInt(PlayerPrefsKey.TACTIC, -1); int morality = CustomPlayerPrefs.GetInt(PlayerPrefsKey.MORALITY, -1); int goodness = CustomPlayerPrefs.GetInt(PlayerPrefsKey.GOODNESS, -1); int sensibility = CustomPlayerPrefs.GetInt(PlayerPrefsKey.SENSIBILITY, -1); int arts = CustomPlayerPrefs.GetInt(PlayerPrefsKey.ARTS, -1); character.Stress = stress; character.Stamina = stamina; character.Intellect = intellect; character.Grace = grace; character.Charm = charm; character.Attack = attack; character.Defense = defense; character.Leadership = leadership; character.Tactic = tactic; character.Morality = morality; character.Goodness = goodness; character.Sensibility = sensibility; character.Arts = arts; }
private int initVacation() { int createdButtonCount = 0; VacationObject vacationTable = LobbyManager.Instance.DT.Vacation; int count = vacationTable.Count; // child for (int id = 0; id < count; ++id) { string key = PlayerPrefsKey.GetKey(PlayerPrefsKey.ISLOCKED_VACATION_CHILD, id); int value = CustomPlayerPrefs.GetInt(key, PlayerPrefsKey.TRUE_INTEGER); bool isLocked = PlayerPrefsKey.GetIntToBool(value); CGThumbnailButton btn = create(); btn.Set(vacationTable[id].childHood, AlbumType, isLocked); ++createdButtonCount; } // adult for (int id = 0; id < count; ++id) { string key = PlayerPrefsKey.GetKey(PlayerPrefsKey.ISLOCKED_VACATION_ADULT, id); int value = CustomPlayerPrefs.GetInt(key, PlayerPrefsKey.TRUE_INTEGER); bool isLocked = PlayerPrefsKey.GetIntToBool(value); CGThumbnailButton btn = create(); btn.Set(vacationTable[id].adultHood, AlbumType, isLocked); ++createdButtonCount; } return(createdButtonCount); }
protected void ClearContinueData() { Log.Debug("ClearContinueData"); CustomPlayerPrefs.DeleteKey(CONTINUE_KEY); }
protected void SetContinueData(string playerName) { Log.Debug(string.Format("SetContinueData; {0}({1})", CONTINUE_KEY, playerName)); CustomPlayerPrefs.SetString(CONTINUE_KEY, playerName); }
private void SaveGameOptions(IGameOptions gameOptions) { CustomPlayerPrefs.SetBool(StringConstants.PlayerPrefsKeys.IsSoundOn, gameOptions.IsSoundOn); CustomPlayerPrefs.SetBool(StringConstants.PlayerPrefsKeys.IsMusicOn, gameOptions.IsMusicOn); }