public flatButton() { Font = SystemFonts.MessageBoxFont; Padding = new Padding(6); _buttonState = buttonStates.Normal; DoubleBuffered = true; TextAlign = ContentAlignment.MiddleCenter; }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); if (e.Button == MouseButtons.Left) { _buttonState = buttonStates.Hover; Invalidate(); } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (e.Button == MouseButtons.Left) { _buttonState = buttonStates.Pressed; Invalidate(); } }
void OnMouseDown() { if (nextStateTime == 0.0f && currentState == StartButtonController.buttonStates.up) { nextStateTime = Time.time + downTime; upSprite.SetActive(false); downSprite.SetActive(true); currentState = StartButtonController.buttonStates.down; } }
void OnMouseDown() { if(nextStateTime == 0.0f && currentState == StartButtonController.buttonStates.up) { nextStateTime = Time.time + downTime; upSprite.SetActive(false); downSprite.SetActive(true); currentState = StartButtonController.buttonStates.down; } }
// Update is called once per frame void Update() { if (currentState == buttonStates.normal) { buttonSprite.color = colores[0]; } else if (currentState == buttonStates.selected) { buttonSprite.color = colores[1]; } else { buttonSprite.color = colores[2]; if (nextStateTime > 0.0f) { if (nextStateTime < Time.time) { // Retornar el botó a estat “no polsat” nextStateTime = 0.0f; currentState = MainMenuButton.buttonStates.selected; buttonSprite.color = colores[1]; if (name == "NewGame_Button") { PlayerPrefs.SetInt("NeedsToLoad", 0); SceneManager.LoadScene("Game", LoadSceneMode.Single); } else if (name == "LoadGame_Button") { Debug.Log("LoadGame was pressed"); PlayerPrefs.SetInt("NeedsToLoad", 1); SceneManager.LoadScene("Game", LoadSceneMode.Single); } else if (name == "ExitGame_Button") { PlayerPrefs.SetInt("NeedsToLoad", 0); Debug.Log("Se cerrará el juego"); #if UNITY_EDITOR // Application.Quit() does not work in the editor so // UnityEditor.EditorApplication.isPlaying need to be set to false to end the game UnityEditor.EditorApplication.isPlaying = false; #else Application.Quit(); #endif } } } } }
void Update() { if (nextStateTime > 0.0f) { if (nextStateTime < Time.time) { // Retornar el botó a estat “no polsat” nextStateTime = 0.0f; upSprite.SetActive(false); downSprite.SetActive(false); currentState = StartButtonController.buttonStates.up; // Començar el joc stateManager.startGame(); } } }
void Update() { if(nextStateTime > 0.0f) { if(nextStateTime < Time.time) { // Set the button back to its 'up' state nextStateTime = 0.0f; upSprite.SetActive(true); downSprite.SetActive(false); currentState = StartButtonController.buttonStates.up; // Start the game! stateManager.startGame(); } } }
void Update() { if (nextStateTime > 0.0f) { if (nextStateTime < Time.time) { // Set the button back to its 'up' state nextStateTime = 0.0f; upSprite.SetActive(true); downSprite.SetActive(false); currentState = StartButtonController.buttonStates.up; // Start the game! stateManager.startGame(); } } }
public void selectButton() { pauseMenu.pauseMenuButtons[pauseMenu.Posicion].currentState = PauseMenuButton.buttonStates.normal; if (name == "ResumeGame_Button") { pauseMenu.Posicion = 0; } else if (name == "SaveGame_Button") { pauseMenu.Posicion = 1; } else if (name == "MainMenuGame_Button") { pauseMenu.Posicion = 2; } else if (name == "ExitGame_Button") { pauseMenu.Posicion = 3; } currentState = PauseMenuButton.buttonStates.selected; }
void OnMouseOver() { if (Input.GetAxis("Mouse X") != 0 && Input.GetAxis("Mouse Y") != 0) { if (currentState == MainMenuButton.buttonStates.normal) { mainMenuButtonController.mainMenuButtons[mainMenuButtonController.Posicion].currentState = MainMenuButton.buttonStates.normal; if (name == "NewGame_Button") { mainMenuButtonController.Posicion = 0; } else if (name == "LoadGame_Button") { mainMenuButtonController.Posicion = 1; } else if (name == "ExitGame_Button") { mainMenuButtonController.Posicion = 2; } currentState = MainMenuButton.buttonStates.selected; } } }
// Use this for initialization void Start() { currentState = buttonStates.normal; buttonSprite = GetComponent <SpriteRenderer>(); buttonSprite.color = colores[0]; }
protected override void OnMouseLeave(EventArgs e) { base.OnMouseLeave(e); _buttonState = buttonStates.Normal; Invalidate(); }
protected override void OnMouseEnter(EventArgs e) { base.OnMouseEnter(e); _buttonState = buttonStates.Hover; Invalidate(); }
void OnMouseDown() { nextStateTime = Time.time + downTime; currentState = MainMenuButton.buttonStates.down; }
// Update is called once per frame void Update() { { if (currentState == buttonStates.normal) { buttonImage.color = colores[0]; } else if (currentState == buttonStates.selected) { buttonImage.color = colores[1]; } else { buttonImage.color = colores[2]; if (nextStateTime > 0.0f) { if (nextStateTime < Time.time) { // Retornar el botó a estat “no polsat” nextStateTime = 0.0f; currentState = PauseMenuButton.buttonStates.selected; buttonImage.color = colores[1]; if (name == "ResumeGame_Button") { pauseMenu.Resume(); } else if (name == "SaveGame_Button") { Debug.Log("SaveGame was pressed"); BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/playerData.dat", FileMode.OpenOrCreate); GameObject player = GameObject.FindGameObjectWithTag("Player"); GameData gameData = new GameData(); gameData.currentMaxHp = player.GetComponent <Player>().currentMaxHp; gameData.hp = player.GetComponent <Player>().hp; gameData.playerPositionX = player.transform.position.x; gameData.playerPositionY = player.transform.position.y; gameData.playerInitialMap = player.GetComponent <Player>().initialMap.name; bf.Serialize(file, gameData); file.Close(); pauseMenu.Resume(); } else if (name == "MainMenuGame_Button") { PlayerPrefs.SetInt("NeedsToLoad", 0); pauseMenu.Resume(); SceneManager.LoadScene("Main", LoadSceneMode.Single); } else if (name == "ExitGame_Button") { PlayerPrefs.SetInt("NeedsToLoad", 0); pauseMenu.Resume(); #if UNITY_EDITOR // Application.Quit() does not work in the editor so // UnityEditor.EditorApplication.isPlaying need to be set to false to end the game UnityEditor.EditorApplication.isPlaying = false; #else Application.Quit(); #endif } } } } } }
public void onClickButton() { nextStateTime = Time.time + downTime; currentState = PauseMenuButton.buttonStates.down; }