// Use this for initialization void Start() { if (GameStateClass.Instance == null) { GameObject g = Instantiate(m_persistantObjectPrefab, transform.parent); GameStateClass gameStateClass = g.GetComponent <GameStateClass> (); gameStateClass.Initialise(); } int highestUnlockedLevel = 0; for (int i = 0; i < GameStateClass.NUMBER_OF_LEVELS; i++) { GameObject levelButton = Instantiate(m_levelButtonPrefab); LevelButton lb = levelButton.GetComponent <LevelButton>(); lb.SetText("Level " + (i + 1)); lb.SetLevelNumber(i); Debug.Log("m_unlockedLevels " + i + " = " + GameStateClass.Instance.m_unlockedLevels[i]); if (GameStateClass.Instance.m_unlockedLevels[i]) { lb.SetImage(m_levelIcons[i]); highestUnlockedLevel = i; } else { lb.SetImage(m_levelLockedPadlock); } levelButton.transform.SetParent(m_levelButtonsPanel); levelButton.transform.localScale = new Vector3(1f, 1f, 1f); } m_levelCarousel.MoveToLevel(highestUnlockedLevel, GameStateClass.Instance.GetLastPlayedLevelNumber()); }
void FillList() { foreach (var level in levelList) { GameObject newbutton = Instantiate(WorldButton) as GameObject; LevelButton button = newbutton.GetComponent <LevelButton>(); button.LevelText.text = level.LevelText; //1-1, 1-2, 1-3, 1-4, ... etc. button.unlocked = level.Unlocked; button.GetComponent <Button>().interactable = level.Playable; button.GetComponent <Button>().onClick.AddListener(() => loadLevels(button.LevelText.text)); newbutton.AddComponent <BoxCollider2D>(); if (PlayerPrefs.GetInt(button.LevelText.text) == 1) { button.unlocked = 1; level.Playable = true; } else { button.unlocked = 0; level.Playable = false; } newbutton.transform.SetParent(WorldSelect); } SaveAll(); }
void Start() { List <int> finishedLevels = _gameModel.GetFinishedLevels(); int maxLevel = _gameConfig.MaxLevel; for (int i = 1; i <= maxLevel; i++) { LevelButton newButton = Instantiate(_levelButtonPrefab); newButton.SetLevel(i); if (finishedLevels.Contains(i)) { newButton.SetPlayed(); } else if (i <= _gameModel.GetMaxPlayableLevel()) { newButton.SetPlayable(); } else { newButton.SetBlocked(); } newButton.gameObject.SetActive(true); newButton.gameObject.transform.SetParent(transform); newButton.transform.localScale = new Vector3(1, 1, 1); newButton.transform.localPosition = Vector3.zero; } }
void FillList() { foreach (var level in LevelList) { GameObject Newbutton = Instantiate(Levelbutton) as GameObject; LevelButton btn = Newbutton.GetComponent <LevelButton>(); //calling of the Levelbutton btn.leveltext.text = level.LevelText; //leveltext is called from LevelButton Script and level.LevelText is of this same script. if (PlayerPrefs.GetInt("Level" + btn.leveltext.text) == 1) { level.UnLocked = 1; level.IsInteractable = true; } btn.unlock = level.UnLocked; btn.GetComponent <Button>().interactable = level.IsInteractable; btn.GetComponent <Button>().onClick.AddListener(() => Loadlevels("Level" + btn.leveltext.text)); if (PlayerPrefs.GetInt("Level" + btn.leveltext.text + "_score") > 0) { btn.star1.SetActive(true); } if (PlayerPrefs.GetInt("Level" + btn.leveltext.text + "_score") >= 500) { btn.star2.SetActive(true); } if (PlayerPrefs.GetInt("Level" + btn.leveltext.text + "_score") >= 999) { btn.star3.SetActive(true); } Newbutton.transform.SetParent(Spacer); } SaveAll(); }
private void InitializeLevelButtons() { int levelIndex = 0; foreach (Level level in section.LevelList) { GameObject button = GameObject.Instantiate(levelButtonPrefab, buttonsPanelLocation.transform, false); LevelButton levelButton = button.GetComponent <LevelButton>(); if (LevelPersistence.IsLevelUnlocked(level.LevelNumber.ToString()) || level.Unlocked) { levelButton.LevelNumber.text = (levelIndex + 1).ToString(); levelButton.GetComponent <Button>().interactable = true; } else { levelButton.LevelNumber.text = ""; levelButton.GetComponent <Button>().interactable = false; } ButtonLevelClickHandler(levelButton, level); levelIndex++; } }
private void Start() { _loadLevel = GetComponent <LoadLevel>(); _levelButton = GetComponent <LevelButton>(); _canvasGroup = GetComponent <CanvasGroup>(); _currentLevelName = _loadLevel.SceneName; if (!_isUnlock) { if (PlayerPrefs.HasKey(_currentLevelName)) { _isUnlock = true; _canvasGroup.alpha = 1; _canvasGroup.interactable = true; } } if (_isUnlock) { if (PlayerPrefs.GetInt(_currentLevelName) >= PlayerPrefs.GetInt($"previous {_currentLevelName}") || !PlayerPrefs.HasKey($"previous {_currentLevelName}")) { _levelButton.SetSpritesOfStars(PlayerPrefs.GetInt(_currentLevelName)); PlayerPrefs.SetInt($"previous {_currentLevelName}", PlayerPrefs.GetInt(_currentLevelName)); } else { _levelButton.SetSpritesOfStars(PlayerPrefs.GetInt($"previous {_currentLevelName}")); } } }
public void EnableLevelButton() { if (LevelButton != null) { LevelButton.SetActive(true); } }
public void DisableLevelButton() { if (LevelButton != null) { LevelButton.SetActive(false); } }
public void CreateLevelButtons() { if (levelButtonPrefab == null) { return; } for (int i = 0; i < LevelDatabase.GetLevelsLength(); i++) { GameObject levelButtonClone = Instantiate(levelButtonPrefab) as GameObject; levelButtonClone.transform.SetParent(levelPanelContent, false); LevelData levelData = LevelDatabase.GetLevel(i); Sprite sprite = Resources.Load(levelImagePath + levelData.title, typeof(Sprite)) as Sprite; Image image = levelButtonClone.GetComponent <Image> (); if (image != null) { image.sprite = sprite; } LevelButton levelButton = levelButtonClone.GetComponent <LevelButton> (); levelButton.SetLevelButton(levelData); } }
/// <summary> /// Change result of level (number of stars) /// </summary> /// <param name="btnGO"></param> /// <param name="resultPassing"></param> private void ChangeLevelButtonResult(GameObject btnGO, Level.ResultPassing resultPassing) { //Text btnText = btnGO.GetComponentInChildren<Text>(); //btnText.text = resultPassing.ToString(); LevelButton levelButton = btnGO.GetComponent <LevelButton>(); switch (resultPassing) { case Level.ResultPassing.Low: levelButton.SetLevelStars(1); //Debug.Log("Low"); break; case Level.ResultPassing.Middle: levelButton.SetLevelStars(2); //Debug.Log("Middle"); break; case Level.ResultPassing.High: levelButton.SetLevelStars(3); //Debug.Log("High"); break; } }
protected override void LoadScreenContent(ContentManager content) { background = new ScrollBackground(content); backgroundCopy = new ScrollBackground(content); windowWidth = GraphicsDeviceManager.DefaultBackBufferWidth; backgroundCopy.Position.X = -windowWidth; //resumeButton = new Button(content, "Go!", new Vector2(180, 400), Color.White); exitButton = new Button(content, "Main Menu", new Vector2(300, 400), Color.White); levelFont = content.Load <SpriteFont>(@"Fonts/tileFont"); titleFont = content.Load <SpriteFont>(@"Fonts/screenFont"); levelTile = content.Load <Texture2D>(@"Images/LevelSelectTile"); padlock = content.Load <Texture2D>(@"Images/Padlock"); checkmark = content.Load <Texture2D>(@"Images/Checkmark"); levelList = new List <LevelButton>(); //draw level buttons short level = 1; int xOffset = 70; int yOffset = 45; for (int i = 0; i < MAX_ROWS; i++) { for (int j = 0; j < MAX_COLS; j++) { levelButton = new LevelButton(content, level.ToString(), level, new Vector2(j * 70f + xOffset, i * 70f + yOffset), Color.Red); levelList.Add(levelButton); //there should be 50 of these level++; } } }
// Start is called before the first frame update void Awake() { string sceneName = SceneManager.GetActiveScene().name; Debug.Log(sceneName); int index = int.Parse(sceneName[sceneName.Length - 1].ToString()); string activeScene = SceneManager.GetActiveScene().name; char episodeIndex = activeScene[activeScene.Length - 1]; for (int i = 0; i < sceneAmountSO.episodeScriptableObjects[index - 1].numberOfScene; i++) { GameObject button = Instantiate(buttonPrefab, content); button.GetComponent <Image>().sprite = buttonBackgroundSprite; button.name = $"Level{i + 1}"; LayoutElement layoutElement = button.AddComponent <LayoutElement>(); layoutElement.minWidth = layoutElement.minHeight = buttonSize; LevelButton levelButton = button.GetComponent <LevelButton>(); levelButton.text.text = (i + 1).ToString(); levelButton.SetSceneNameAndLoadStars(episodeIndex, i + 1); } }
public void generateLevels() { IEnumerable <PChapter> chapters = dConnector.GetAllChapters(); int i = 1; foreach (PChapter chapter in chapters) { //Generate Chapters GameObject newButton = Instantiate(chapterButton) as GameObject; ChapterButton cButton = newButton.GetComponent <ChapterButton>(); cButton.nameLabel.text = chapter.Name; cButton.lockedLabel.text = chapter.Locked?"Locked":"Unlocked"; newButton.transform.SetParent(contentPanel); ToConsole(chapter); //Generate Levels int j = 1; IEnumerable <PLevel> levels = dConnector.GetAllLevelsInChapterById(chapter.Id); foreach (PLevel level in levels) { GameObject newLevelButton = Instantiate(levelButton) as GameObject; LevelButton lButton = newLevelButton.GetComponent <LevelButton>(); lButton.nameLabel.text = level.Name; lButton.lockedLabel.text = level.Locked?"Locked":"Unlocked"; lButton.levelNumber.text = "#" + j; j++; newLevelButton.transform.SetParent(contentPanel); ToConsole(level); } i++; } }
public void SetButton() { LevelButton.SelectButton?.CloseObject(); this.OpenObject(); LevelButton.SelectButton = this; }
public LevelMenuState() { int buttonSpacing = 20; // add a background SpriteGameObject background = new SpriteGameObject("Backgrounds/spr_levelselect", 0, "background"); this.Add(background); // add the level button LevelButton levelButton = new LevelButton(1, "Sprites/spr_level_solved"); levelButton.Position = new Vector2(390, 180); this.Add(levelButton); // add the level button LevelButton levelButton2 = new LevelButton(2, "Sprites/spr_level_solved"); levelButton2.Position = new Vector2(390 + buttonSpacing + levelButton.Width, 180); this.Add(levelButton2); // add a back button backButton = new Button("Sprites/spr_button_back", 1); backButton.Position = new Vector2((GameEnvironment.Screen.X - backButton.Width) / 2, 750); this.Add(backButton); }
public void CompleteLevel(bool complete) { if (complete && currentLevel == lastOpened) { int btnCount = levelButtons.Length; if (lastCompleted < btnCount) { LevelButton completedBtn = levelButtons[lastCompleted]; completedBtn.SetState(LevelState.Completed); } //if (lastOpened - 1 < btnCount) //WORKS FINE //{ // LevelButton completedBtn = levelButtons[lastOpened - 1]; // completedBtn.SetState(LevelState.Completed); //} if (lastOpened < btnCount) { LevelButton openedBtn = levelButtons[lastOpened];//is next - opened greater for 1 openedBtn.SetState(LevelState.Open); } lastCompleted++; lastOpened++; SaveData(); } InvokeClickRoutine(false); }
void Awake() { grid = GetComponent <GridLayoutGroup>(); grid.cellSize = new Vector2(200, 200); grid.spacing = new Vector2(100, 100); HelpFunctions.DestroyChilds(transform); List <TextAsset> maps = SaveLoadManager.GetMaps().ToList(); for (int i = 0; i < maps.Count; i++) { LevelButton level = Instantiate <LevelButton>(prefabLevel); level.SetCall(maps[i].name); level.Count = i; Transform temp = level.transform; temp.SetParent(transform); temp.localScale = Vector3.one; temp.localPosition = Vector3.zero; } }
void FillList() { foreach (var level in LevelList) { GameObject newButton = Instantiate(levelButton) as GameObject; LevelButton button = newButton.GetComponent <LevelButton>(); Button bu = button.GetComponent <Button>(); button.LevelText.text = level.LevelText; if (PlayerPrefs.GetInt("level-" + button.LevelText.text) == 1) { level.Unlocked = 1; level.IsInteractable = true; } button.unlocked = level.Unlocked; bu.interactable = level.IsInteractable; bu.onClick.AddListener(() => LoadLevel("level-" + button.LevelText.text)); newButton.transform.SetParent(Content); bu.transition = Selectable.Transition.Animation; Animator animator = newButton.AddComponent <Animator>(); animator.runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>("Pikatan/ButtonStageSelect"); newButton.GetComponent <Image>().sprite = sprite; } SaveAll(); GameObject b = GameObject.Find("Contant").transform.GetChild(0).gameObject; EventSystem.current.SetSelectedGameObject(b); }
public LevelMenuState() { PlayingState playingState = GameEnvironment.GameStateManager.GetGameState("playingState") as PlayingState; List <Level> levels = playingState.Levels; // add a background SpriteGameObject background = new SpriteGameObject("Backgrounds/spr_levelselect", 0, "background"); Add(background); // add the level buttons for (int i = 0; i < 12; i++) { int row = i / 4; int column = i % 4; LevelButton level = new LevelButton(i + 1, levels[i], 1); level.Position = new Vector2(column * (level.Width + 20), row * (level.Height + 20)) + new Vector2(390, 180); Add(level); } // add a back button backButton = new Button("Sprites/spr_button_back", 1); backButton.Position = new Vector2((GameEnvironment.Screen.X - backButton.Width) / 2, 750); Add(backButton); }
public void showOn(LevelButton other) { if (other.IsUnlocked()) { GetComponent <Image>().color = new Color32(53, 139, 226, 140); } else { GetComponent <Image>().color = new Color32(217, 29, 29, 140); } if (other.IsUnlocked()) { text.SetText(other.description); } else { text.SetText("You need to complete the previous level"); } transform.position = other.transform.position + offset; gameObject.SetActive(true); }
void ListAdd() { foreach (Levels level in levelList) { GameObject newButton = Instantiate(button) as GameObject; LevelButton newBTN = newButton.GetComponent <LevelButton>(); newBTN.levelTextBTN.text = level.levelText; if (PlayerPrefs.GetInt("Level " + newBTN.levelTextBTN.text) == 1) { level.unlocked = 1; level.enabled = true; level.activeText = true; } newBTN.unlockedBTN = level.unlocked; newBTN.GetComponent <Button>().interactable = level.enabled; newBTN.GetComponentInChildren <Text>().enabled = level.activeText; newBTN.GetComponent <Button>().onClick.AddListener(() => ClickLevel("Level " + newBTN.levelTextBTN.text)); newButton.transform.SetParent(buttonLocation, false); } }
private void FillList() { foreach (var level in levelList) { GameObject newbutton = Instantiate(levelSelectButton); LevelButton button = newbutton.GetComponent <LevelButton>(); button.levelText.text = level.levelText; if (PlayerPrefs.GetInt("Level" + button.levelText.text) == 1) { level.unLock = 1; level.isInteractible = true; } button.levelUnlockint = level.unLock; button.GetComponent <Button>().interactable = level.isInteractible; button.levelLockedImg.enabled = (level.unLock != 1) ? true : false; button.GetComponent <Button>().onClick.AddListener(() => LoadLevel("Level" + button.levelText.text)); button.GetComponent <Button>().onClick.AddListener(() => AudioManager.Instance.Play("ButtonSound")); button.GetComponent <Button>().onClick.AddListener(() => MenuManager.Instance.SwitchToHUD()); newbutton.transform.SetParent(buttonParent); } // SaveLevelData(); }
void Start() { restartButton.SetActive(false); LevelButton.SetActive(false); quitButton.SetActive(false); ResumeButton.SetActive(false); ControlsButton.SetActive(false); //Подключение анимации и физики rb2d = GetComponent <Rigidbody2D>(); anim = GetComponent <Animator>(); extraJumps = extraJumpsValue; health1.SetActive(true); health2.SetActive(true); health3.SetActive(true); emptyhealth1.SetActive(false); emptyhealth2.SetActive(false); emptyhealth3.SetActive(false); //Health playerLayer = this.gameObject.layer; enemyLayer = LayerMask.NameToLayer("Enemy"); Physics2D.IgnoreLayerCollision(playerLayer, enemyLayer, false); rend = GetComponent <Renderer>(); color = rend.material.color; //Attack attackTrigger.enabled = false; //Box picketFence.enabled = true; //KnifeButton KnifeActive.SetActive(true); KnifeActive1.SetActive(true); KnifeActive2.SetActive(true); NoKnifeActive.SetActive(false); NoKnifeActive1.SetActive(false); NoKnifeActive2.SetActive(false); }
public void UpdateStates() { Level[] progressViewerLevels = ProgressViewer.instance.playableLevels; foreach (GameObject LevelButton in levelButtons) { foreach (Level level in progressViewerLevels) { if (level.SceneName.Equals(LevelButton.GetComponent <LevelButton>().LevelName)) { LevelButton.GetComponent <LevelButton>().LevelCompleted = level.SceneWon; } } } for (int i = 1; i < levelButtons.Length; i++) { if (levelButtons[i - 1].GetComponent <LevelButton>().LevelCompleted) { levelButtons[i].GetComponent <Button>().interactable = true; levelButtons[i].transform.GetChild(2).gameObject.SetActive(false); } else { levelButtons[i].GetComponent <Button>().interactable = false; levelButtons[i].transform.GetChild(2).gameObject.SetActive(true); } } }
protected virtual void AddLevelButton(int levelIndex) { if (buttonPrefab == null) { Debug.LogError("Добавьте префаб кнопки"); return; } GameObject newButton = Instantiate(buttonPrefab) as GameObject; newButton.transform.SetParent(grid.transform, false); newButton.transform.SetSiblingIndex(levelIndex); newButton.name = "LevelButton" + (levelIndex + 1); LevelButton button = newButton.GetComponent <LevelButton>(); if (button != null) { button.levelIndex = levelIndex; #if UNITY_EDITOR if (!EditorApplication.isPlaying) { button.Init(); } #endif } }
private void Awake() { if (gameObject.name.Equals("Default")) { LevelButton.SelectButton = this; OpenObject(); } }
public void StartLevel(LevelButton button) { var levelId = button.LevelSettings.Id; GameProgress.SelectLevel(levelId); SceneManager.LoadScene(1); }
void FillList() { //return; foreach (var level in levelList) { GameObject newbutton = Instantiate(levelButton) as GameObject; newbutton.GetComponent <RectTransform>().parent = Spacer.GetComponent <RectTransform>(); newbutton.GetComponent <RectTransform>().localPosition = new Vector3(0, 0, 0); newbutton.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1); LevelButton button = newbutton.GetComponent <LevelButton>(); button.levelText.text = level.levelText; if (PlayerPrefs.GetInt("Level " + button.levelText.text) == 1) { level.Unlocked = 1; level.isInteractable = true; } button.unlocked = level.Unlocked; button.GetComponent <Button>().interactable = level.isInteractable; button.GetComponent <Button>().onClick.AddListener(() => loadLevel("Level " + button.levelText.text)); Time.timeScale = 1; // Set Star for each Level int highScore = PlayerPrefs.GetInt("Level " + button.levelText.text + "highScoreLevel"); levelNum = Int32.Parse(button.levelText.text); if (levelNum > 3) { ratioScore = levelNum * 0.25f; } else { ratioScore = 1; } if (highScore > 0) { button.Star1.SetActive(true); } if (highScore >= (80 * ratioScore)) { button.Star2.SetActive(true); } if (highScore >= (150 * ratioScore)) { button.Star3.SetActive(true); } } SaveAll(); }
private void Awake() { for (int i = 0; i < GameManager.LevelsCount; i++) { LevelButton newButton = Instantiate(_levelButtonPrefab, _levelHorisontalGroup); newButton.Initialize($"Level {i + 1}", i); } }
void SaveAll() { GameObject[] allButtons = GameObject.FindGameObjectsWithTag("LevelButton"); foreach (GameObject buttons in allButtons) { LevelButton button = buttons.GetComponent <LevelButton>(); PlayerPrefs.SetInt("Level" + button.LevelText.text, button.unlocked); } }
public LevelMenuState() { PlayingState playingState = GameEnvironment.GameStateManager.GetGameState("playingState") as PlayingState; List<Level> levels = playingState.Levels; // add a background SpriteGameObject background = new SpriteGameObject("Backgrounds/spr_levelselect", 0, "background"); this.Add(background); // add the level buttons for (int i = 0; i < 12; i++) { int row = i / 4; int column = i % 4; LevelButton level = new LevelButton(i + 1, levels[i], 1); level.Position = new Vector2(column * (level.Width + 20), row * (level.Height + 20)) + new Vector2(390, 180); this.Add(level); } // add a back button backButton = new Button("Sprites/spr_button_back", 1); backButton.Position = new Vector2((GameEnvironment.Screen.X - backButton.Width) / 2, 750); this.Add(backButton); }
void Awake() { image = GetComponent<Image> (); button = GetComponentInParent<LevelButton> (); }
void Awake() { level = GetComponent<LevelButton> (); button = GetComponent<Button> (); }
public override void OnInspectorGUI() { button = (LevelButton)target; profile = button.profile; if (profile.levelID == 0 || profile.levelID != target.GetInstanceID ()) { if (profile.levelID != target.GetInstanceID ()) profile = profile.GetClone(); profile.levelID = target.GetInstanceID (); } button.name = (button.transform.GetSiblingIndex () + 1).ToString(); parametersFade.target = GUILayout.Toggle(parametersFade.target, "Level Parameters", EditorStyles.foldout); if (EditorGUILayout.BeginFadeGroup (parametersFade.faded)) { profile.width = Mathf.RoundToInt (EditorGUILayout.Slider ("Width", 1f * profile.width, 5f, 12f)); profile.height = Mathf.RoundToInt (EditorGUILayout.Slider ("Height", 1f * profile.height, 5f, 12f)); profile.chipCount = Mathf.RoundToInt (EditorGUILayout.Slider ("Count of Possible Colors", 1f * profile.chipCount, 3f, 6f)); profile.stonePortion = EditorGUILayout.Slider ("Stone Portion (" + Mathf.RoundToInt(profile.stonePortion * 100f).ToString() + "%)", profile.stonePortion, 0f, 0.7f); EditorGUILayout.BeginHorizontal (); EditorGUILayout.LabelField ("Score Stars", GUILayout.ExpandWidth(true)); profile.firstStarScore = Mathf.Max(EditorGUILayout.IntField (profile.firstStarScore, GUILayout.ExpandWidth(true)), 1); profile.secondStarScore = Mathf.Max(EditorGUILayout.IntField (profile.secondStarScore, GUILayout.ExpandWidth(true)), profile.firstStarScore+1); profile.thirdStarScore = Mathf.Max(EditorGUILayout.IntField (profile.thirdStarScore, GUILayout.ExpandWidth(true)), profile.secondStarScore+1); EditorGUILayout.EndHorizontal (); profile.limitation = (Limitation) EditorGUILayout.EnumPopup ("Limitation", profile.limitation); switch (profile.limitation) { case Limitation.Moves: profile.moveCount = Mathf.Clamp(EditorGUILayout.IntField("Move Count", profile.moveCount), 10, 50); break; case Limitation.Time: profile.duraction = Mathf.Max(0, EditorGUILayout.IntField("Session duration", profile.duraction)); break; } profile.target = (FieldTarget) EditorGUILayout.EnumPopup ("Target", profile.target); colorModeFade.target = profile.target == FieldTarget.Color; if (EditorGUILayout.BeginFadeGroup (colorModeFade.faded)) { defaultColor = GUI.color; profile.targetColorCount = Mathf.RoundToInt(EditorGUILayout.Slider("Targets Count", profile.targetColorCount, 1, profile.chipCount)); for (int i = 0; i < 6; i++) { GUI.color = chipColor[i]; if (i < profile.targetColorCount) profile.SetTargetCount(i, Mathf.Clamp(EditorGUILayout.IntField("Color " + alphabet[i].ToString(), profile.GetTargetCount(i)), 1, 999)); else profile.SetTargetCount(i, 0); } GUI.color = defaultColor; } EditorGUILayout.EndFadeGroup (); sugarDropFade.target = profile.target == FieldTarget.SugarDrop; if (EditorGUILayout.BeginFadeGroup(sugarDropFade.faded)) { profile.targetSugarDropsCount = Mathf.RoundToInt(EditorGUILayout.Slider("Sugar Count", profile.targetSugarDropsCount, 1, 20)); } EditorGUILayout.EndFadeGroup(); } EditorGUILayout.EndFadeGroup (); EditorGUILayout.Space (); EditorGUILayout.BeginHorizontal (EditorStyles.toolbar, GUILayout.ExpandWidth(true)); defaultColor = GUI.color; GUI.color = currentMode == EditMode.Slot ? unpressedColor : defaultColor; if (GUILayout.Button("Slot", EditorStyles.toolbarButton, GUILayout.Width(40))) currentMode = EditMode.Slot; GUI.color = currentMode == EditMode.Chip ? unpressedColor : defaultColor; if (GUILayout.Button("Chip", EditorStyles.toolbarButton, GUILayout.Width(40))) currentMode = EditMode.Chip; GUI.color = currentMode == EditMode.PowerUp ? unpressedColor : defaultColor; if (GUILayout.Button("PowerUp", EditorStyles.toolbarButton, GUILayout.Width(70))) currentMode = EditMode.PowerUp; if (profile.target == FieldTarget.Jelly) { GUI.color = currentMode == EditMode.Jelly ? unpressedColor : defaultColor; if (GUILayout.Button("Jelly", EditorStyles.toolbarButton, GUILayout.Width(50))) currentMode = EditMode.Jelly; } GUI.color = currentMode == EditMode.Block ? unpressedColor : defaultColor; if (GUILayout.Button("Block", EditorStyles.toolbarButton, GUILayout.Width(50))) currentMode = EditMode.Block; GUI.color = currentMode == EditMode.Wall ? unpressedColor : defaultColor; if (GUILayout.Button("Wall", EditorStyles.toolbarButton, GUILayout.Width(40))) currentMode = EditMode.Wall; GUI.color = defaultColor; GUILayout.FlexibleSpace (); if (GUILayout.Button ("Reset", EditorStyles.toolbarButton, GUILayout.Width (40))) profile = new LevelProfile (); EditorGUILayout.EndVertical (); // Slot modes if (currentMode == EditMode.Slot) { EditorGUILayout.BeginHorizontal (EditorStyles.toolbar, GUILayout.ExpandWidth(true)); defaultColor = GUI.color; GUI.color = toolID == "Slots" ? unpressedColor : defaultColor; if (GUILayout.Button("Slots", EditorStyles.toolbarButton, GUILayout.Width(40))) toolID = "Slots"; GUI.color = toolID == "Generators" ? unpressedColor : defaultColor; if (GUILayout.Button("Generators", EditorStyles.toolbarButton, GUILayout.Width(70))) toolID = "Generators"; GUI.color = toolID == "Teleports" ? unpressedColor : defaultColor; if (GUILayout.Button("Teleports", EditorStyles.toolbarButton, GUILayout.Width(70))) toolID = "Teleports"; if (profile.target == FieldTarget.SugarDrop) { GUI.color = toolID == "Sugar Drop" ? unpressedColor : defaultColor; if (GUILayout.Button("Sugar Drop", EditorStyles.toolbarButton, GUILayout.Width(70))) toolID = "Sugar Drop"; } GUI.color = defaultColor; GUILayout.FlexibleSpace (); EditorGUILayout.EndHorizontal (); } // Chip modes if (currentMode == EditMode.Chip) { EditorGUILayout.BeginHorizontal (EditorStyles.toolbar, GUILayout.ExpandWidth(true)); string key; defaultColor = GUI.color; GUI.color = toolID == "Random" ? unpressedColor : defaultColor; if (GUILayout.Button("Random", EditorStyles.toolbarButton, GUILayout.Width(50))) toolID = "Random"; for (int i = 0; i < profile.chipCount; i++) { key = "Color " + alphabet[i]; GUI.color = toolID == key ? unpressedColor * chipColor[i] : defaultColor * chipColor[i]; if (GUILayout.Button(key, EditorStyles.toolbarButton, GUILayout.Width(50))) toolID = key; } GUI.color = toolID == "Stone" ? unpressedColor : defaultColor; if (GUILayout.Button("Stone", EditorStyles.toolbarButton, GUILayout.Width(40))) toolID = "Stone"; GUI.color = defaultColor; GUILayout.FlexibleSpace (); EditorGUILayout.EndHorizontal (); } // Block modes if (currentMode == EditMode.Block) { EditorGUILayout.BeginHorizontal (EditorStyles.toolbar, GUILayout.ExpandWidth(true)); defaultColor = GUI.color; GUI.color = toolID == "Simple Block" ? unpressedColor : defaultColor; if (GUILayout.Button("Simple Block", EditorStyles.toolbarButton, GUILayout.Width(80))) toolID = "Simple Block"; GUI.color = toolID == "Weed" ? unpressedColor : defaultColor; if (GUILayout.Button("Weed", EditorStyles.toolbarButton, GUILayout.Width(40))) toolID = "Weed"; GUI.color = toolID == "Branch" ? unpressedColor : defaultColor; if (GUILayout.Button("Branch", EditorStyles.toolbarButton, GUILayout.Width(50))) toolID = "Branch"; GUI.color = defaultColor; GUILayout.FlexibleSpace (); EditorGUILayout.EndHorizontal (); } EditorGUILayout.BeginVertical (EditorStyles.inspectorDefaultMargins); rect = GUILayoutUtility.GetRect (profile.width * (cellSize + slotOffect), profile.height * (cellSize + slotOffect)); rect.x += slotOffect; rect.y += slotOffect; EditorGUILayout.BeginHorizontal (); DrawModeTools (); EditorGUILayout.EndHorizontal (); EditorGUILayout.EndVertical (); switch (currentMode) { case EditMode.Slot: DrawSlot(); break; case EditMode.Chip: DrawChip(); break; case EditMode.PowerUp: DrawPowerUp(); break; case EditMode.Jelly: DrawJelly(); break; case EditMode.Block: DrawBlock(); break; case EditMode.Wall: DrawWall(); break; } button.profile = profile; EditorUtility.SetDirty (button); }