public void Reload() { GamePlayUI.SetActive(true); CloseScreen((int)Screens.Failscreen); PlayerDataController.SaveData("isLevelCompleted", true); LevelManager.instance.LoadLevel(true); }
public void LoadNextTutorial() { if (currentLevel != null) { Debug.Log("Destroying"); MonoBehaviour.Destroy(currentLevel); } if (index > 3) { LevelManager.instance.tm = null; LevelManager.instance.LoadLevel(false); PlayerDataController.SaveData("isRefreshDataEveryLaunch", false); UIManager.instance.OpenScreen((int)UIManager.Screens.GamePlayUI); UIManager.instance.CloseScreen((int)UIManager.Screens.GoodJobUI); return; } UIManager.instance.CloseScreen((int)UIManager.Screens.GoodJobUI); currentLevel = MonoBehaviour.Instantiate(tutorialLevels[index]); // activeLevelData = currentLevel.GetComponent<LevelData>(); LevelManager.instance.activeLevelData = currentLevel.GetComponent <LevelData>(); LevelManager.instance.activeLevel = currentLevel; GridConstructer.instance.Init(LevelManager.instance.activeLevelData, true); InitCurrentTutorial(); }
public void ToggleSound() { soundSetting = !soundSetting; PlayerDataController.SaveData("isSoundOpen", soundSetting); PlayerDataController.SaveData("isRefreshDataEveryLaunch", !soundSetting); soundSettingDisplay.sprite = soundSprites[soundSetting ? 1 : 0]; Debug.Log("Sound Toggled"); }
public void ToggleHaptic() { hapticSetting = !hapticSetting; PlayerDataController.SaveData("isVibrationOpen", hapticSetting); hapticSettingDisplay.sprite = hapticSprites[hapticSetting ? 1 : 0]; Debug.Log("Haptic Toggled"); }
public void UpdatePlayerGold(int amount) { if (amount != 0) { Gold += amount; PlayerDataController.SaveData("gold", Gold); UIManager.instance.UpdateGoldText(); } }
// It indicates that the interstitial ad is closed by clicking cross button/back button public void OnInterstitialDismiss() { //timer i sifirliyoruz Timer.Reset(); AdManager.instance.onComplete(PlayerDataController.data.whichVideoFor, AdManager.AD_STATES.NOT_COMPLETE); PlayerDataController.SaveData("whichVideoFor", ""); AMRSDK.loadInterstitial(); Debug.Log("Intersititial Ad dismiss!"); }
public void SaveShapes() { PlayerDataController.data.savedShapes = new List <MyTuples>(); foreach (var shape in GameManager.instance.currentShapes) { Shape shapeData = shape.GetComponent <Shape>(); PlayerDataController.data.savedShapes.Add(new MyTuples(shapeData.id, shapeData.spawnIndex)); } PlayerDataController.SaveData("savedShapes", FlatHelper.ToJson <MyTuples>(PlayerDataController.data.savedShapes)); }
// It indicates that the user deserves to receive a reward. You may need to store this information in a variable and give a reward // to the user after OnVideoDismiss() callback is called by showing some animations for instance. // Note: If OnVideoComplete callback is called for the ad, it is always called before OnVideoDismiss() callback. public void OnVideoComplete() { PlayerDataController.SaveData("isRewardedVideoWatched", true); AdManager.instance.onComplete(PlayerDataController.data.whichVideoFor, AdManager.AD_STATES.COMPLETE); if (PlayerDataController.data.GetVideoReward(PlayerDataController.data.whichVideoFor) > 0) { PlayerDataController.SaveData(PlayerDataController.data.whichVideoFor, PlayerDataController.data.GetVideoReward(PlayerDataController.data.whichVideoFor), true); } Debug.Log("Video Ad complete!"); }
public void SaveBlockStatusChange(CellManager placement, bool placed) { MyTuples myTuple = PlayerDataController.data.uncompletedLevel.GetTuple(placement.index.x, placement.index.y); if (myTuple.isFull != placed) { myTuple.isFull = placed; PlayerDataController.SaveData("uncompletedLevel", FlatHelper.ToJson <MyTuples>(PlayerDataController.data.uncompletedLevel)); } }
public void SaveMissionProgress(Mission mission) { // int k = 0; // foreach (var mission in activeLevelData.missions) // { string animalPlayerPrefsName = "animalProgress" + LevelManager.instance.activeLevelData.animalIndex[activeLevelData.missions.IndexOf(mission)]; PlayerDataController.SaveData(animalPlayerPrefsName, mission.Count); // k++; // } }
// It indicates that the rewarded video ad is closed by clicking cross button/back button. // It does not mean that the user deserves to receive a reward. You need to check whether OnVideoComplete callback is called or not. public void OnVideoDismiss() { if (PlayerDataController.data.isRewardedVideoWatched) { AdManager.instance.onComplete(PlayerDataController.data.whichVideoFor, AdManager.AD_STATES.COMPLETE); } else { AdManager.instance.onComplete(PlayerDataController.data.whichVideoFor, AdManager.AD_STATES.NOT_COMPLETE); } PlayerDataController.SaveData("whichVideoFor", ""); AMRSDK.loadRewardedVideo(); Debug.Log("Video Ad dismiss!"); }
IEnumerator RandomSelectAnimation(int cycleCount, int[] travelList, int whichTheme) { var elapsed = 0; var xInc = 234; var yInc = -233.5f; var defaultX = -354.0f; var defaultY = 443.0f; animatedSelectedTheme.SetActive(true); if (whichTheme == 0) { lastSelectedTheme1.sprite = openThemeSprite; } else { lastSelectedTheme2.sprite = openThemeSprite; } while (elapsed < cycleCount) { animatedSelectedTheme.GetComponent <RectTransform>().position = new Vector2( Screen.width / 2 + defaultX + xInc * (travelList[elapsed] % 4), Screen.height / 2 + defaultY + yInc * (int)(travelList[elapsed] / 4) ); yield return(new WaitForSeconds(.15f)); elapsed++; } animatedSelectedTheme.SetActive(false); if (whichTheme == 0) { PlayerDataController.ChangeValueInList("theme1", "item" + (travelList[travelList.Length - 1] + 1), true); PlayerDataController.SaveData("gold", PlayerDataController.data.gold - PlayerDataController.data.inventory1RandomGoldPrice); ChangeTheme1(travelList[travelList.Length - 1]); } else { PlayerDataController.ChangeValueInList("theme2", "item" + (travelList[travelList.Length - 1] + 1), true); PlayerDataController.SaveData("gold", PlayerDataController.data.gold - PlayerDataController.data.inventory2RandomGoldPrice); ChangeTheme2(travelList[travelList.Length - 1]); } UpdateGoldText(); StopCoroutine(randomSelectCoroutine); }
public void ShowRewarded(string rewardName, Action <string, AD_STATES> onState, Action <string, AD_STATES> onCmplt) { if (onCmplt != null) { onComplete = onCmplt; } if (PlayerDataController.data.isTest && Application.platform != RuntimePlatform.IPhonePlayer && Application.platform != RuntimePlatform.Android) { if (onState != null) { onState(rewardName, AD_STATES.READY); } isIntersititialOpen = false; PlayerDataController.SaveData("whichVideoFor", rewardName); Debug.Log("==========" + PlayerDataController.GetData <string>("whichVideoFor").ToString()); Simulator.SetActive(true); Simulator.transform.GetChild(0).gameObject.GetComponent <Text>().text = "Rewarded Video Ad"; AMR.AMRSdkConfig.instance.OnVideoShow(); if (testCoroutine != null) { StopCoroutine(testCoroutine); } Simulator.transform.Find("FinishItNow").gameObject.SetActive(true); testCoroutine = StartCoroutine(TestAdsDelay(PlayerDataController.data.rewardedDurationForTest)); return; } if (AMR.AMRSDK.isRewardedVideoReady()) { if (onState != null) { onState(rewardName, AD_STATES.READY); } } else { if (onState != null) { onState(rewardName, AD_STATES.NOT_READY); } } }
public void ShowIntersititial(string whichAd, Action <string, AD_STATES> onState, Action <string, AD_STATES> onCmplt) { if (onCmplt != null) { onComplete = onCmplt; } PlayerDataController.SaveData("whichVideoFor", whichAd); if (PlayerDataController.data.isTest && Application.platform != RuntimePlatform.IPhonePlayer && Application.platform != RuntimePlatform.Android && Timer.TimeCheck()) { if (onState != null) { onState(PlayerDataController.data.whichVideoFor, AD_STATES.READY); } isIntersititialOpen = true; Simulator.SetActive(true); Simulator.transform.GetChild(0).gameObject.GetComponent <Text>().text = "Intersitial Ad"; Simulator.transform.Find("FinishItNow").gameObject.SetActive(true); AMR.AMRSdkConfig.instance.OnInterstitialShow(); if (testCoroutine != null) { StopCoroutine(testCoroutine); } testCoroutine = StartCoroutine(TestAdsDelay(PlayerDataController.data.intersitialDurationForTest)); return; } if (AMR.AMRSDK.isInterstitialReady() && Timer.TimeCheck()) { if (onState != null) { onState("", AD_STATES.READY); } } else { if (onState != null) { onState("", AD_STATES.NOT_READY); } } }
public void ToggleVibrationState() { PlayerDataController.SaveData("isVibrationOpen", !PlayerDataController.data.isVibrationOpen); VibrateOpenIcon.SetActive(false); VibrateCloseIcon.SetActive(false); VibrateOpenRadioIcon.SetActive(false); VibrateCloseRadioIcon.SetActive(false); if (PlayerDataController.data.isVibrationOpen) { VibrateOpenIcon.SetActive(true); VibrateOpenRadioIcon.SetActive(true); } else { VibrateCloseIcon.SetActive(true); VibrateCloseRadioIcon.SetActive(true); } }
public void ChangeTheme2(int itemIndex) { if (itemIndex == PlayerDataController.data.selectedTheme2) { return; } PlayerDataController.SaveData("selectedTheme2", itemIndex); lastSelectedTheme2.sprite = openThemeSprite; for (int i = 0; i < theme2Images.Length; i++) { if (theme2Images[i].transform.parent.name == "Item" + (itemIndex + 1)) { theme2Images[i].gameObject.SetActive(true); theme2Images[i].sprite = Theme2Sprites[itemIndex]; theme2Images[i].transform.parent.GetComponent <Button>().enabled = true; theme2Images[i].transform.parent.GetComponent <Image>().sprite = selectedThemeSprite; lastSelectedTheme2 = theme2Images[i].transform.parent.GetComponent <Image>(); break; } } }
// It indicates that the loaded rewarded video ad is shown to the user.(Note: It does not mean that the user deserves a reward) // It is immediately called after the loaded ad is shown to the user using AMRSDK.showRewardedVideo() public void OnVideoShow() { PlayerDataController.SaveData("isRewardedVideoWatched", false); }
public void LoadLevel(bool refreshLevelColors) { var realLevelNum = PlayerDataController.data.levelNum; var fakeLevelNum = (realLevelNum) % levels.Length; if (GameManager.instance.getNextShapeCor != null) { GameManager.instance.StopCoroutine(GameManager.instance.getNextShapeCor); } GameManager.emptyCellSlots = 81; Player.main.ApplyAndResetGoldInfo(); if (activeLevel != null) { Destroy(activeLevel); } activeLevel = Instantiate(levels[fakeLevelNum]); activeLevelData = activeLevel.GetComponent <LevelData>(); if (refreshLevelColors) { PartTheme newPartTheme = FlatHelper.GetRandomEnumType <PartTheme>(); while (newPartTheme == lastPartTheme) { newPartTheme = FlatHelper.GetRandomEnumType <PartTheme>(); } var loadedTheme = Resources.LoadAll("Parts/" + newPartTheme.ToString(), typeof(Sprite)); lastPartTheme = newPartTheme; activeLevelData.partTheme = newPartTheme; activeLevelData.levelPartSprites = new List <Sprite>(); foreach (var theme in loadedTheme) { activeLevelData.levelPartSprites.Add(theme as Sprite); } PlayerDataController.SaveData("levelPartTheme", (int)newPartTheme); } else { lastPartTheme = activeLevelData.partTheme; } GridConstructer.instance.Init(activeLevelData, false); PlayerDataController.SaveData("isBonusLevel", false); levelText.text = "LEVEL " + realLevelNum; if (PlayerDataController.data.isLevelCompleted) { PlayerDataController.ResetLevelData(); foreach (var mission in activeLevelData.missions) { SaveMissionProgress(mission); } GameManager.instance.GameModeType = activeLevelData.startingMode; GameManager.instance.getNextShapeCor = GameManager.instance.StartCoroutine(GameManager.instance.GetNextShapes()); GameManager.instance.CheckEmptyCellCount(); UIManager.instance.OpenScreen((int)UIManager.Screens.LevelInfoUI); } else { LoadLevelDataFromSave(); } // AdManager.instance.ShowIntersititial("", (name, state) => // { // //state check // }, (name, state) => // { // //complete check // }); }
public void PassNewLevel() { PlayerDataController.SaveData("isLevelCompleted", true); PlayerDataController.SaveData("levelNum", PlayerDataController.data.levelNum + 1); LoadLevel(false); }