void Start() { levelSelector = GameObject.Find("Level Selector").GetComponent <LevelSelector>(); playerData = GameObject.Find("Player Data").GetComponent <PlayerData>(); DisplayInfo(); Button startButton = transform.Find("Play Button").gameObject.GetComponent <Button>(); if (city.state == LevelSelectorCity.State.Open) { startButton.interactable = true; startButton.transform.GetChild(0).GetComponent <Text>().text = "Play"; startButton.GetComponent <Image>().color = Color.green; } else if (city.state == LevelSelectorCity.State.Locked) { startButton.interactable = false; startButton.transform.GetChild(0).GetComponent <Text>().text = "Locked"; startButton.GetComponent <Image>().color = Color.grey; } else if (city.state == LevelSelectorCity.State.Completed) { startButton.interactable = false; startButton.transform.GetChild(0).GetComponent <Text>().text = "Complete"; startButton.GetComponent <Image>().color = Color.yellow; transform.Find("Completed Panel").gameObject.SetActive(true); } }
protected override void _initialize() { if ((instance == null) || (instance == this)) // setup singleton { instance = this; } else { Debug.Log("Duplicate GameManager destroyed"); DestroyImmediate(this.gameObject); } //Retrieve the level names from the directory levelNames = searchForLevels(); // get level names //Create the list of buttons and their names if it hasn't already. levelButtons = new Button[levelNames.Length]; for (int i = 0; i < levelButtons.Length; i++) { levelButtons[i] = Instantiate(template, templateParent.transform); levelButtons[i].GetComponentInChildren <TextMeshProUGUI>().text = levelNames[i]; levelButtons[i].GetComponent <LevelButtonScript>().index = i; // set index for this button } GameManager.numLevels = levelButtons.Length; // set number of levels that exist in the game manager levelButtons[0].gameObject.SetActive(true); // make sure level 0 is always accessible. firstSelected = levelButtons[0]; }
public void Setup(LevelSelector selector, Sprite iconSprite, int idx, string levelName, bool isSelected) { myIcon = iconSprite; tfLevelName.text = levelName; selectedBG.gameObject.SetActive(isSelected); //selectedBG.color = isSelected ? selector.SelectedBGColor : selector.NonSelectedBGColor; if (myIcon != null) { point.color = Color.white; point.sprite = myIcon; } else { point.color = isSelected ? selector.SelectedPointColor : selector.NonSelectedPointColor; } tfLevelName.color = isSelected ? Color.black : Color.white; selectButton.onClick.AddListener(() => { selector.SelectLevel(idx); transform.DOPunchScale(new Vector3(0.2f, 0.2f, 0.2f), 0.2f, 10, 1f); }); }
/// <summary> /// Called by confirmMenu when returning. /// If gets success value, will create save the slot at number, else will do nothing /// </summary> /// <param name="retVal"></param> /// <param name="retString"></param> public override void _RespondToConfirm(int retVal, string retString) { switch (retVal) { case 0: if (GameManager.settings.saveNum <= 3 && GameManager.settings.saveNum >= 1 && GameManager.saveGame != null) // save existing game if it exists { SaveObj.SaveGame(GameManager.settings.saveNum, GameManager.saveGame); } GameManager.saveGame = new SaveObj(!retString.Equals("") ? retString : "Slot " + number); GameManager.settings.saveNum = number; SaveObj.SaveGame(number, GameManager.saveGame); SettingsObj.saveSettings(GameManager.settings); if (GameManager.saveGame.levelNumber >= 0 && GameManager.saveGame.levelNumber < levelSelector.levelButtons.Length) { LevelSelector.changeLevelHelper(GameManager.saveGame.levelNumber); GameManager.changeState(GameManager.gameplay, this); } else { onClick(levelSelector); } break; default: // canceled, do nothing break; } }
private void SelectLevel() { Transform currentPageObject = carouselMenu.GetCurrentPageObject(); if (currentPageObject == null) { return; } LevelSelector selectedLevel = currentPageObject.GetComponent <LevelSelector>(); selectedLevel.Select(); if (lastSelectedLevel != null) { lastSelectedLevel.Deselect(); } lastSelectedLevel = selectedLevel; LevelData currentLevelData = selectedLevel.levelData; if (currentLevelData != null) { UpdateLevelPreview(currentLevelData); } }
public static void LoadLevelProgress(LevelSelector levelSelector) { if (PlayerPrefs.HasKey("unlockedLevel")) { levelSelector.UnlockedLevels = PlayerPrefs.GetInt("unlockedLevel"); } }
public void Activate(LevelSelector ls) { levelSelector = ls; Cursor.visible = false; Invoke("EndHighpass", 1f); AudioManager.Instance.targetPitch = 1f; if (spelling) { methodName = "CheckLetters"; } if (noTouch) { methodName = "CheckTouch"; } if (survival) { methodName = "CheckAlive"; } if (methodName != null) { Invoke(methodName, checkDelay); } if (intro) { Invoke("SwapHints", 30f); hintSize = hints[0].localScale; } }
void OnEnable() { levelSelector = target as LevelSelector; handleTransform = levelSelector.transform; handleRotation = Quaternion.identity; tangents = new Vector3[levelSelector.availableLevels.Length,2]; }
public static int GetIndex() { // int index = Random.Range (0, wordList_Romaji.Length - 1); // Get Random number which has the same index for Hiragana, Katakana, and Romaji arrays int index = Random.Range(LevelSelector.getWordList_Length_Start(), LevelSelector.getWordList_Length_End()); // Get Random number based on LevelSelector Debug.Log("Index #" + index + ": " + wordList_Hiragana[index] + " " + wordList_Katakana[index] + " " + wordList_Romaji[index]); // Debug Log return(index); }
// Start is called before the first frame update void Start() { instance = this; hardmodeImage.color = new Color(1, 1, 1, hardmode ? 1 : 0.5f); autoplayImage.color = new Color(1, 1, 1, 1); prevChapter.interactable = false; ShowLevels(1, false); }
public void OpenLevelSelector() { sceneList.gameObject.SetActive(true); LevelSelector lselector = sceneList.GetComponent <LevelSelector>(); buttons = lselector.buttons; SelectButton(buttons[0]); }
private void InitLevels() { foreach (LevelData x in levelSelectorDatas) { LevelSelector levelSelector = Instantiate(levelSlotPrefab, slotParent).GetComponent <LevelSelector>(); levelSelector.levelData = x; LogUtils.LogWarning($"{levelSelector.levelData.levelName} was added."); } }
// Start is called before the first frame update void Start() { m_levelSelectorInstance = m_LevelSelector.GetComponent <LevelSelector>(); if (PlayerData.LastSelectedLevel == m_LevelID) { m_levelSelectorInstance.m_LevelPreviewImage.sprite = m_LevelPreviewImage; } }
private void Start() { if (levelSelector) { Destroy(levelSelector); } levelSelector = this; }
public MenuState(Game1 _game, GraphicsDevice _graphicsDevice, ContentManager _content) : base(_game, _graphicsDevice, _content) { //initialize instruction object gamemenuoptions = new GameMenuOptions(graphicsDevice, content); //initializing level selector levelSelector = new LevelSelector(_graphicsDevice, _content, _game, _game.gameManager_); var buttonTexture = content.Load <Texture2D>("Controls/gameButton"); var buttonFont = content.Load <SpriteFont>("Font/Font"); //Goku = new GameSprite(content.Load<Texture2D>("Background/Goku_UI"), new Vector2(900, 100), Color.White); gameBackground.Init(graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height, content.Load <Texture2D>("Background/GameBackground")); int gap = 50; var instructionButton = new Button(buttonTexture, buttonFont) { Position = new Vector2(50, 550 + gap), Text = "Instructions", }; instructionButton.Click += InstructionButton_Clicked; var quitButton = new Button(buttonTexture, buttonFont) { Position = new Vector2(50, 700 + gap), Text = "Quit", }; quitButton.Click += QuitButton_Clicked; var playButton = new Button(buttonTexture, buttonFont) { Position = new Vector2(50, 250 + gap), Text = "Play Game", }; playButton.Click += PlayGameButton_Clicked; var levelButton = new Button(buttonTexture, buttonFont) { Position = new Vector2(50, 400 + gap), Text = "Select Level", }; levelButton.Click += levelButton_Clicked; components = new List <Component>() { instructionButton, playButton, quitButton, levelButton, }; }
public void Deselect(LevelSelector selector) { selectedBG.gameObject.SetActive(false); if (myIcon != null) { point.sprite = myIcon; } point.color = myIcon != null ? Color.white : selector.NonSelectedPointColor; tfLevelName.color = Color.white; }
public void Select(LevelSelector selector) { selectedBG.gameObject.SetActive(true); if (myIcon != null) { point.sprite = myIcon; } point.color = myIcon != null ? Color.white : selector.SelectedPointColor; tfLevelName.color = Color.black; }
void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); } }
void Start() { if (s != null && s != this) { Destroy(gameObject); return; } SceneManager.sceneLoaded += OnSceneLoaded; s = this; DontDestroyOnLoad(this); }
private void UnlockLevel(Button button, int index, bool isJoker) { button.transform.Find("LevelNumber").GetComponent <TextMesh>().text = LevelSelector.DifferentiatedLevelLabel(index); button.transform.Find("Lock").gameObject.SetActive(false); button.MethodToCall.SetMethod(base.gameObject.GetComponent <LevelSelector>(), (!isJoker) ? "LoadLevel" : "LoadStarLevel", index.ToString()); ButtonAnimation component = button.GetComponent <ButtonAnimation>(); if (component != null) { component.RemoveInputListener(); } string sceneName = this.Levels[index].sceneName; int @int = GameProgress.GetInt(sceneName + "_stars", 0, GameProgress.Location.Local, null); bool flag = GameProgress.HasCollectedSnoutCoins(sceneName, 0); bool flag2 = GameProgress.HasCollectedSnoutCoins(sceneName, 1); bool flag3 = GameProgress.HasCollectedSnoutCoins(sceneName, 2); GameObject[] array = new GameObject[] { button.transform.Find("StarSet/Star1").gameObject, button.transform.Find("StarSet/Star2").gameObject, button.transform.Find("StarSet/Star3").gameObject, button.transform.Find("CoinSet/Star1").gameObject, button.transform.Find("CoinSet/Star2").gameObject, button.transform.Find("CoinSet/Star3").gameObject }; int num = 0; if (flag) { num++; } if (flag2) { num++; } if (flag3) { num++; } for (int i = 0; i < 3; i++) { bool flag4 = i + 1 <= @int; bool flag5 = i + 1 <= num || Singleton <BuildCustomizationLoader> .Instance.IsOdyssey; array[i].SetActive(flag4 && !flag5); array[i + 3].SetActive(flag4 && flag5); } if (isJoker) { GameObject gameObject = button.transform.Find("StarSetsLocked").gameObject; gameObject.SetActive(false); } }
public void OpenEpisode(LevelSelector episodeLevels) { this.m_currentEpisode = SceneManager.GetActiveScene().name; this.m_currentEpisodeType = GameManager.EpisodeType.Normal; this.m_currentEpisodeIndex = episodeLevels.EpisodeIndex; this.m_openingCutscene = episodeLevels.OpeningCutscene; this.m_midCutscene = episodeLevels.MidCutscene; this.m_endingCutscene = episodeLevels.EndingCutscene; this.m_levels = new List <EpisodeLevelInfo>(episodeLevels.Levels); this.m_starlevelLimits = new List <int>(episodeLevels.StarLevelLimits); this.m_pagesComingSoonBitmask = Convert.ToInt32(episodeLevels.m_pageTwoComingSoon) + Convert.ToInt32(episodeLevels.m_pageThreeComingSoon); }
void Start() { if (selector == null) { selector = this; lastTimeRange = GameController.Instance.LastPlayedTimeRange; } else if (selector != this) { Destroy(gameObject); } }
void Start() { gameManager = GameObject.FindWithTag("GameManager").GetComponent <GameManager>(); gameManager.Register_Clipboard(this); localizedTextManager = gameManager.GetComponent <LocalizedTextManager>(); buttonTextComponent = GetComponentInChildren <Text>(); offscreenPosition = new Vector3(transform.position.x, transform.position.y - offscreenOffset, transform.position.z); offscreenScale = transform.localScale * offscreenScalar; originalPosition = transform.position; originalScale = transform.localScale; createAndDestroyLevelRef = GameObject.FindGameObjectWithTag("persistentObject").GetComponent <CreateAndDestroyAppointment>(); selectorRef = GameObject.Find("LevelSelector").GetComponent <LevelSelector>(); createAndDestroyLevelRef.levelsAvailable = selectorRef.dayToGenerate.numAppointments; CreateAllAppointments(); // place badges badgeCheckOriginalPos = badgeCheck.transform.localPosition; badgeStarOriginalPos = badgeStar.transform.localPosition; badgeCheck.transform.position = new Vector3(badgeCheck.transform.position.x, badgeCheck.transform.position.y + distanceToPushBadges, badgeCheck.transform.position.z); badgeStar.transform.position = new Vector3(badgeStar.transform.position.x, badgeStar.transform.position.y + distanceToPushBadges, badgeStar.transform.position.z); // place showMe banner Vector3 showMeScreenEdge = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width * showMeBannerScreenPos_X, Screen.height * showMeBannerScreenPos_Y)); showMeOutPosition = new Vector3( showMeScreenEdge.x, showMeScreenEdge.y, showMeBanner.transform.position.z); showMeInPosition = new Vector3(showMeOutPosition.x - distanceToPushShowMeBanner, showMeOutPosition.y, showMeOutPosition.z); showMeBanner.transform.position = showMeInPosition; // show notifications at start of clipboard if (selectorRef.dayToGenerate.dayIndex_internal == 0) { GameObject.Find("NotificationManager").GetComponent <NotificationManager>().DisplayNotification(1, false); } else if (selectorRef.dayToGenerate.dayIndex_internal == 4) { GameObject.Find("NotificationManager").GetComponent <NotificationManager>().DisplayNotification(9, false); } textDay.text = localizedTextManager.GetLocalizedString("Day") + " " + (selectorRef.dayToGenerate.dayIndex_internal + 1); restartFromResultsScreenButton = GameObject.Find("RestartFromResultsScreenButton"); ShowRestartButton(false); isFirstCreation = false; }
public int index; // changed this to use ints, so loading the levels from other scripts is easier // This is set when instatiating from prefab /*public void changeString(string s) * { * this.s = s; * }*/ //This method is called on button pressed. public void doButtonThing() { //LevelSelector.changeLevel(s); //LevelSelector.changeLevel(index); if (index != GameManager.saveGame.levelNumber) // update and save the last level visited if it is different from the current last level visited. { GameManager.saveGame.levelNumber = index; SaveObj.SaveGame(GameManager.settings.saveNum, GameManager.saveGame); } LevelSelector.changeLevelHelper(index); // load level with given index number GameManager.changeState(GameManager.gameplay, LevelSelector.instance); // switch to game-mode }
/// <summary> /// load straight to last-visited-level if it is set to a valid number, else go to level selector /// </summary> public void resumeGame() { //Debug.Log("Resume Game does nothing right now"); if (GameManager.saveGame.levelNumber >= 0 && GameManager.saveGame.levelNumber < levelSelector.levelButtons.Length) { LevelSelector.changeLevelHelper(GameManager.saveGame.levelNumber); GameManager.changeState(GameManager.gameplay, this); } else { onClick(levelSelector); } }
//setting up singleton private void Awake() { //Check if instance already exists if (Instance == null) { Instance = this; } else if (Instance != this) { //Otherwise destroy this. Destroy(gameObject); } }
/// <summary> /// Saves all the data needed to ensure the levels remain unlocked. /// </summary> void SaveAll() { if (!PlayerPrefs.HasKey("Level 1")) { GameObject[] allButtons = GameObject.FindGameObjectsWithTag("LevelButton"); foreach (GameObject button in allButtons) { LevelSelector levelSelect = button.GetComponent <LevelSelector> (); PlayerPrefs.SetInt(levelSelect.levelText.text, levelSelect.unlocked); } } PlayerPrefs.Save(); }
private void Start() { bool anyLevelsCompleted = PlayerData .GetCompletionDatasWithType(LevelType.Enumerated) .Any(x => x.Completed); bool allLevelsCompleted = PlayerData .GetCompletionDatasWithType(LevelType.Enumerated) .All(x => x.Completed); LevelID firstIncompleteLevel = GetFirstIncompleteLevel(); // If all levels are completed then unlock free play mode if (allLevelsCompleted && !PlayerData.FreePlayUnlocked) { // Unlock free play mode PlayerData.FreePlayUnlocked = true; PlayerData.Save(); // Display a tutorial for free play tutorialManager.OpenTutorials(new TutorialData[] { freePlayTutorial }, true); } // Play button plays the first incomplete level, or goes to level selector if all are completed playButton.onClick.AddListener(() => { if (firstIncompleteLevel.IsValid) { GameplayManager.PlayLevel(firstIncompleteLevel); } else { LevelSelector.SelectLevelsWithType(LevelType.Enumerated); } }); // Level select button selects levels only if some have been completed levelSelectButton.interactable = anyLevelsCompleted; if (anyLevelsCompleted) { levelSelectButton.onClick.AddListener(() => LevelSelector.SelectLevelsWithType(LevelType.Enumerated)); } // Free play only unlocked if all levels are completed freePlayButton.interactable = allLevelsCompleted; if (allLevelsCompleted) { freePlayButton.onClick.AddListener(() => LevelSelector.SelectLevelsWithType(LevelType.FreePlay)); } // When delete data is confirmed, reload this scene deleteDataButton.OnConfirm.AddListener(() => SceneManager.LoadScene(SceneManager.GetActiveScene().name)); }
private void ToggleUnlockAllLevels() { if (levelSelector == null) { Debug.Log("Finding LevelSelector"); levelSelector = GameObject.FindObjectOfType <LevelSelector>(); Debug.Log(levelSelector == null ? "Not Found" : "Found"); } if (levelSelector != null) { levelSelector.allLevelsUnlocked = !levelSelector.allLevelsUnlocked; } }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100)) { LevelSelector tmp; tmp = hit.transform.gameObject.GetComponent <LevelSelector>(); if (tmp && !tmp.is_lock) { current = tmp; Debug.Log("levelLaunched"); current.launchLevel(); } else if (tmp) { //tmp.lockLevel(false); } } } if (Input.GetKey(KeyCode.R)) { PlayerPrefs.SetInt("tounlockLevel", 1); PlayerPrefs.SetInt("unlockedLevel", 0); } // List<GameObject> tmpParticleList = new List<GameObject>() ; // foreach(GameObject particle in particleList) // { // Light tmpLight = particle.GetComponent<Transform>().GetChild(1).GetComponent<Light>(); // tmpLight.range -= 0.01f; // if (tmpLight.range <= 0.1f) // { // Destroy(particle); // } // else // { // tmpParticleList.Add(particle); // } // } // particleList = tmpParticleList; if (particleList.Count != 0) { StartCoroutine(HandleLevelParticles()); } }
public static LevelSelector instance; //A reference to our game control script so we can access it statically. void Awake() { //If we don't currently have a game control... if (instance == null) { //...set this one to be it... instance = this; } //...otherwise... else if (instance != this) { //...destroy this one because it is a duplicate. Destroy(gameObject); } }
void Awake() { singleton = this; player = UserSettings.Instance.CurrentPlayer; }
void Start() { gameManager = GameObject.FindWithTag("GameManager").GetComponent<GameManager>(); gameManager.Register_Clipboard(this); localizedTextManager = gameManager.GetComponent<LocalizedTextManager>(); buttonTextComponent = GetComponentInChildren<Text>(); offscreenPosition = new Vector3(transform.position.x, transform.position.y - offscreenOffset, transform.position.z); offscreenScale = transform.localScale * offscreenScalar; originalPosition = transform.position; originalScale = transform.localScale; createAndDestroyLevelRef = GameObject.FindGameObjectWithTag("persistentObject").GetComponent<CreateAndDestroyAppointment>(); selectorRef = GameObject.Find("LevelSelector").GetComponent<LevelSelector>(); createAndDestroyLevelRef.levelsAvailable = selectorRef.dayToGenerate.numAppointments; CreateAllAppointments(); // place badges badgeCheckOriginalPos = badgeCheck.transform.localPosition; badgeStarOriginalPos = badgeStar.transform.localPosition; badgeCheck.transform.position = new Vector3(badgeCheck.transform.position.x, badgeCheck.transform.position.y + distanceToPushBadges, badgeCheck.transform.position.z); badgeStar.transform.position = new Vector3(badgeStar.transform.position.x, badgeStar.transform.position.y + distanceToPushBadges, badgeStar.transform.position.z); // place showMe banner Vector3 showMeScreenEdge = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width * showMeBannerScreenPos_X, Screen.height * showMeBannerScreenPos_Y)); showMeOutPosition = new Vector3( showMeScreenEdge.x, showMeScreenEdge.y, showMeBanner.transform.position.z); showMeInPosition = new Vector3(showMeOutPosition.x - distanceToPushShowMeBanner, showMeOutPosition.y, showMeOutPosition.z); showMeBanner.transform.position = showMeInPosition; // show notifications at start of clipboard if (selectorRef.dayToGenerate.dayIndex_internal == 0) { GameObject.Find("NotificationManager").GetComponent<NotificationManager>().DisplayNotification(1, false); } else if (selectorRef.dayToGenerate.dayIndex_internal == 4) { GameObject.Find("NotificationManager").GetComponent<NotificationManager>().DisplayNotification(9, false); } textDay.text = localizedTextManager.GetLocalizedString("Day") + " " + (selectorRef.dayToGenerate.dayIndex_internal + 1); restartFromResultsScreenButton = GameObject.Find("RestartFromResultsScreenButton"); ShowRestartButton(false); isFirstCreation = false; }