Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class HighlightAndBehaviour : MonoBehaviour
- {
- [SerializeField] Choice currentChoice;
- [SerializeField] Sprite startNormal, startHover, startPressed;
- [SerializeField] Sprite creditsNormal, creditsHover, creditsPressed;
- [SerializeField] Sprite exitNormal, exitHover, exitPressed;
- [SerializeField] SpriteRenderer startSR, creditsSR, exitSR;
- void Start()
- {
- StartCoroutine(StartChoice());
- }
- IEnumerator StartChoice()
- {
- while(currentChoice == Choice.Start)
- {
- startSR.sprite = startHover;
- if(Input.GetKeyDown(KeyCode.Return))
- {
- startSR.sprite = startPressed;
- // MOVE TO SCENE HERE
- currentChoice = Choice.Null;
- }
- if(Input.GetKeyDown(KeyCode.DownArrow))
- {
- startSR.sprite = startNormal;
- currentChoice = Choice.Credits;
- StartCoroutine(CreditsChoice());
- }
- yield return null;
- }
- }
- IEnumerator CreditsChoice()
- {
- while (currentChoice == Choice.Credits)
- {
- creditsSR.sprite = creditsHover;
- if (Input.GetKeyDown(KeyCode.Return))
- {
- creditsSR.sprite = creditsPressed;
- // MOVE TO CREDITS HERE
- currentChoice = Choice.Null;
- }
- if (Input.GetKeyDown(KeyCode.DownArrow))
- {
- creditsSR.sprite = creditsNormal;
- currentChoice = Choice.Exit;
- StartCoroutine(ExitChoice());
- }
- if (Input.GetKeyDown(KeyCode.UpArrow))
- {
- creditsSR.sprite = creditsNormal;
- currentChoice = Choice.Start;
- StartCoroutine(StartChoice());
- }
- yield return null;
- }
- }
- IEnumerator ExitChoice()
- {
- while (currentChoice == Choice.Exit)
- {
- exitSR.sprite = exitHover;
- if (Input.GetKeyDown(KeyCode.Return))
- {
- exitSR.sprite = exitPressed;
- // EXIT GAME HERE
- currentChoice = Choice.Null;
- }
- if (Input.GetKeyDown(KeyCode.UpArrow))
- {
- exitSR.sprite = exitNormal;
- currentChoice = Choice.Credits;
- StartCoroutine(CreditsChoice());
- }
- yield return null;
- }
- }
- }
- public enum Choice
- {
- Start,
- Credits,
- Exit,
- Null
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement