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 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 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 }
// 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 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); }
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); }
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; } }
/********** 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 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); }
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; }
public int AbilityLevel(AbilityType abilityType) { return(CustomPlayerPrefs.GetInt($"{AbilityLevelKey}_{abilityType}", 0)); }
private MainCharacter loadMainCharacter(Nurture.Calendar calendar) { if (null == calendar) { Log.Error("not found calendar"); return(null); } string name = CustomPlayerPrefs.GetString(PlayerPrefsKey.NAME, null); if (null == name) { Log.Error(string.Format("not found Player's '{0}'", PlayerPrefsKey.NAME)); return(null); } int zodiac = CustomPlayerPrefs.GetInt(PlayerPrefsKey.ZODIAC, -1); if (false == Enum.IsDefined(typeof(EZodiac), zodiac)) { Log.Error(string.Format("not found '{0}'", PlayerPrefsKey.ZODIAC)); return(null); } int age = Def.INIT_AGE + (calendar.Year - Def.INIT_YEAR); int condition = CustomPlayerPrefs.GetInt(PlayerPrefsKey.CONDITION, -1); if (false == Enum.IsDefined(typeof(Nurture.ECondition), condition)) { Log.Error(string.Format("not found '{0}'", PlayerPrefsKey.CONDITION)); return(null); } int[] actionCount = new int[Manager.Instance.DT.Action.Count]; int numAction = actionCount.Length; for (int id = 0; id < numAction; ++id) { string key = PlayerPrefsKey.GetKey(PlayerPrefsKey.ACTION_COUNT, id); int value = CustomPlayerPrefs.GetInt(key, -1); if (value < 0) { Log.Error(string.Format("not found '{0}'", key)); return(null); } actionCount[id] = value; } int constitution = CustomPlayerPrefs.GetInt(PlayerPrefsKey.CONSTITUTION, -1); if (false == Enum.IsDefined(typeof(EConstitution), constitution)) { Log.Error(string.Format("not found '{0}'", PlayerPrefsKey.CONSTITUTION)); return(null); } int money = CustomPlayerPrefs.GetInt(PlayerPrefsKey.MONEY, -1); if (money < Def.MIN_MONEY) { Log.Error(string.Format("not found '{0}'", PlayerPrefsKey.MONEY)); return(null); } int wearingCostumeId = CustomPlayerPrefs.GetInt(PlayerPrefsKey.WEARING_COSTUME, -1); if (false == ExtMainCharacterCostume.IsValid(wearingCostumeId)) { Log.Error(string.Format("not found '{0}'", PlayerPrefsKey.WEARING_COSTUME)); return(null); } Wardrobe wardrobe = new Wardrobe(); int costumeCount = Manager.Instance.DT.MainCharacterCostume.Count; for (int id = 0; id < costumeCount; ++id) { string key = PlayerPrefsKey.GetKey(PlayerPrefsKey.ISBUY_COSTUME, id); int value = CustomPlayerPrefs.GetInt(key, -1); if (-1 == value) { Log.Error(string.Format("not found '{0}'", key)); return(null); } bool isBuy = PlayerPrefsKey.GetIntToBool(value); CostumeController costume = new CostumeController(id, isBuy); wardrobe.CostumeList.Add(costume); } EZodiac z = (EZodiac)zodiac; Nurture.ECondition c = (Nurture.ECondition)condition; EConstitution cs = (EConstitution)constitution; MainCharacter mc = new MainCharacter(name, z, age, c, actionCount, cs, money, wardrobe, wearingCostumeId); return(mc); }