Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class onGameGUI : MonoBehaviour {
- public static onGameGUI GUI;
- //Keybindings
- Event keyEvent;
- Text buttonText;
- KeyCode newKey;
- bool waitingForKey;
- public GameObject textWait;
- [Header("Notification")]
- public GameObject panelLevelUp;
- public GameObject notifMainPanel;
- public Text notifText1;
- public Text notifText2;
- public GameObject iconInformation;
- //should be the image or logo for notfication
- [Header("Compass")]
- public GameObject compassMainPanel;
- public GameObject compassPointR;
- public GameObject compassPointL;
- [Header("Player")]
- public GameObject playerMainPanel;
- //public GameObject playerBloodBar;
- public GameObject playerTaunt1;
- public Image playerParangLogo;
- [Header("Mission")]
- public Text TextMission;
- public Text TextDescription;
- [Header("Sound Effects")]
- public GameObject inGameClickSFX;
- public GameObject inGameHoverSFX;
- public GameObject inGameAmbient;
- [Header("Player")]
- public GameObject player;
- private PlayerCombat combatScript;
- [Header("Tutorial Icon")]
- public GameObject iconAttack;
- public GameObject iconCamera;
- public GameObject iconCrouch;
- public GameObject iconDirection;
- public GameObject iconRun;
- public GameObject iconShield;
- public GameObject iconInteract;
- public GameObject iconSheath;
- public GameObject frameTutorial;
- public Text tutorialText;
- public GameObject iconCrystal;
- [Header("Level Bar")]
- public Text levelNumber;
- public Image levelBar;
- public static bool GameIsPaused = false;
- [Header("Warning Panel")]
- public GameObject warningpanel;
- public Sprite crosscheck;
- public GameObject textWallLevel;
- // Use this for initialization
- void Start () {
- combatScript = player.GetComponent<PlayerCombat>();
- notifMainPanel.gameObject.SetActive (false);
- waitingForKey = false;
- }
- // Update is called once per frame
- void Update () {
- //AmbientSound ();
- if (combatScript.swordState) {
- if (playerParangLogo != null){
- if (!playerParangLogo.enabled) {
- playerParangLogo.gameObject.SetActive (true);
- }
- }
- } else {
- if (playerParangLogo != null) {
- if (playerParangLogo.enabled) {
- playerParangLogo.gameObject.SetActive (false);
- }
- } else {
- Debug.Log ("null");
- }
- }
- if (waitingForKey)
- textWait.gameObject.SetActive (true);
- else
- textWait.gameObject.SetActive (false);
- }
- public void ShowWindow (GameObject panel){
- panel.SetActive (true);
- }
- public void CloseWindow (GameObject panel){
- panel.SetActive (false);
- }
- public void ShowDiamondNotification (string header, string body){
- notifText1.text = header;
- notifText2.text = body;
- StopCoroutine (showpanel());
- StartCoroutine (showpanel());
- }
- IEnumerator showpanel(){
- yield return new WaitForSeconds (1);
- notifMainPanel.SetActive (true);
- notifText1.gameObject.SetActive (true);
- notifText2.gameObject.SetActive (true);
- iconInformation.SetActive (true);
- yield return new WaitForSeconds (5);
- notifMainPanel.SetActive (false);
- notifText1.gameObject.SetActive (false);
- notifText2.gameObject.SetActive (false);
- iconInformation.SetActive (false);
- }
- public void ShowRectangleNotification(string teks){
- tutorialText.text = teks;
- StopCoroutine (showframe ());
- StartCoroutine (showframe ());
- }
- IEnumerator showframe(){
- yield return new WaitForSeconds (1);
- frameTutorial.SetActive (true);
- tutorialText.gameObject.SetActive (true);
- iconCrystal.SetActive (true);
- yield return new WaitForSeconds (5);
- frameTutorial.SetActive (false);
- tutorialText.gameObject.SetActive (false);
- iconCrystal.SetActive (false);
- }
- void OnGUI(){
- keyEvent = Event.current;
- if (keyEvent.isKey && waitingForKey) {
- newKey = keyEvent.keyCode;
- waitingForKey = false;
- }
- }
- public void StartAssignment(string keyName){
- if (!waitingForKey) {
- StartCoroutine(AssignKey(keyName));
- }
- }
- public void SendText(Text text){
- buttonText = text;
- }
- IEnumerator WaitForKey(){
- while (!keyEvent.isKey)
- yield return null;
- }
- public IEnumerator AssignKey(string keyName){
- waitingForKey = true;
- yield return WaitForKey();
- switch (keyName) {
- case "forward":
- GameManager_Master.gm.forward = newKey;
- buttonText.text = GameManager_Master.gm.forward.ToString ();
- PlayerPrefs.SetString ("forwardKey", GameManager_Master.gm.forward.ToString ());
- break;
- case "backward":
- GameManager_Master.gm.backward = newKey;
- buttonText.text = GameManager_Master.gm.backward.ToString ();
- PlayerPrefs.SetString ("backwardKey", GameManager_Master.gm.backward.ToString ());
- break;
- case "left":
- GameManager_Master.gm.left = newKey;
- buttonText.text = GameManager_Master.gm.left.ToString ();
- PlayerPrefs.SetString ("leftKey", GameManager_Master.gm.left.ToString ());
- break;
- case "right":
- GameManager_Master.gm.right = newKey;
- buttonText.text = GameManager_Master.gm.right.ToString ();
- PlayerPrefs.SetString ("rightKey", GameManager_Master.gm.right.ToString ());
- break;
- case "jump":
- GameManager_Master.gm.jump = newKey;
- buttonText.text = GameManager_Master.gm.jump.ToString ();
- PlayerPrefs.SetString ("jumpKey", GameManager_Master.gm.jump.ToString ());
- break;
- case "crouch":
- GameManager_Master.gm.crouch = newKey;
- buttonText.text = GameManager_Master.gm.crouch.ToString ();
- PlayerPrefs.SetString ("crouchKey", GameManager_Master.gm.crouch.ToString ());
- break;
- case "run":
- GameManager_Master.gm.run = newKey;
- buttonText.text = GameManager_Master.gm.run.ToString ();
- PlayerPrefs.SetString ("runKey", GameManager_Master.gm.run.ToString ());
- break;
- case "sword":
- GameManager_Master.gm.sword = newKey;
- buttonText.text = GameManager_Master.gm.sword.ToString ();
- PlayerPrefs.SetString ("swordKey", GameManager_Master.gm.sword.ToString ());
- break;
- case "interact":
- GameManager_Master.gm.interact = newKey;
- buttonText.text = GameManager_Master.gm.interact.ToString ();
- PlayerPrefs.SetString ("interactKey", GameManager_Master.gm.interact.ToString ());
- break;
- case "lightattack":
- GameManager_Master.gm.lightattack = newKey;
- buttonText.text = GameManager_Master.gm.lightattack.ToString ();
- PlayerPrefs.SetString ("lightattackKey", GameManager_Master.gm.lightattack.ToString ());
- break;
- case "shield":
- GameManager_Master.gm.shield = newKey;
- buttonText.text = GameManager_Master.gm.shield.ToString ();
- PlayerPrefs.SetString ("shieldKey", GameManager_Master.gm.shield.ToString ());
- break;
- case "pause":
- GameManager_Master.gm.pause = newKey;
- buttonText.text = GameManager_Master.gm.pause.ToString ();
- PlayerPrefs.SetString ("pauseKey", GameManager_Master.gm.pause.ToString ());
- break;
- case "map":
- GameManager_Master.gm.map = newKey;
- buttonText.text = GameManager_Master.gm.map.ToString ();
- PlayerPrefs.SetString ("mapKey", GameManager_Master.gm.map.ToString ());
- break;
- }
- yield return null;
- }
- public void DisableConfirmation(){
- warningpanel.gameObject.SetActive (false);
- //panel system dan quest raycast target = true
- }
- public void QuitConfirmation(){
- warningpanel.gameObject.SetActive (true);
- //panel system dan quest raycast target = false
- }
- public void ClickSound(){
- inGameClickSFX.GetComponent<AudioSource> ().Play ();
- }
- public void HoverSound(){
- inGameHoverSFX.GetComponent<AudioSource> ().Play ();
- }
- public void AmbientSound(){
- inGameAmbient.GetComponent<AudioSource> ().Play ();
- if (inGameAmbient.GetComponent<AudioSource> ().volume < 1f) {
- inGameAmbient.GetComponent<AudioSource> ().volume += 0.1f * Time.deltaTime;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement