Last active
February 23, 2019 08:40
-
-
Save ZeredaGames/03d20dcab289efb1dc5a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// CameraConroller.cs | |
// | |
// Author: | |
// ${ZeredaGames-AKA Thamas Bell} <${thamasbell@hotmail.com}> | |
// | |
// Copyright (c) ${2015} ${Thamas Bell} | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is | |
// furnished to do so, subject to the following conditions: | |
// | |
// The above copyright notice and this permission notice shall be included in | |
// all copies or substantial portions of the Software. | |
// | |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
// THE SOFTWARE. | |
using UnityEngine; | |
using UnityEngine.UI; | |
namespace ZG.Managers.CameraSettings | |
{ | |
public class CameraController : MonoBehaviour | |
{ | |
/// <summary> | |
/// The main camera. | |
/// </summary> | |
public Camera mainCamera; | |
/// <summary> | |
/// The state of the game. | |
/// </summary> | |
private CamState GameState; | |
/// <summary> | |
/// Different states of the controller. | |
/// </summary> | |
private enum CamState {CamOn,CamOff,CamAYS,CameraSettings} | |
/// <summary> | |
/// The cam text. | |
/// </summary> | |
public Text CamTxt,HintTxt,InfoTxt; | |
/// <summary> | |
/// Start this instance. | |
/// </summary> | |
void Start() | |
{ | |
Debug.Log (GameState); | |
GameState = CamState.CamOn; | |
} | |
/// <summary> | |
/// Update this instance. | |
/// </summary> | |
void update () | |
{ | |
if (Input.GetKeyDown(KeyCode.Escape)){ | |
GameState = CamState.CamAYS; | |
}else if (Input.GetKeyDown(KeyCode.Alpha0)) | |
{ | |
GameState = CamState.CameraSettings; | |
} | |
print (GameState); | |
if (GameState == CamState.CamOn) {CamOn();} | |
else if (GameState == CamState.CamOff) {CamOff();} | |
else if (GameState == CamState.CamAYS) {CamAYS();} | |
else if (GameState == CamState.CameraSettings) {CameraSettings();} | |
} | |
/// <summary> | |
/// Cams the on. | |
/// </summary> | |
void CamOn () | |
{ | |
Debug.Log (GameState); | |
CamTxt.text = "Camera ON"; | |
GameState = CamState.CamOn; | |
if (Input.GetKeyDown(KeyCode.Alpha9)) | |
{ | |
Debug.Log (GameState); | |
GameState = CamState.CamAYS; | |
CamTxt.text = "Camera ON"; | |
InfoTxt.text = "Press 0 to CANCEL or ESC to DISABLE Camera"; | |
HintTxt.text = "Turning the Camera OFF Sometimes BREAKS the Game!`this can be changed`"; | |
}else if (Input.GetKeyDown(KeyCode.Alpha0)) | |
{ | |
Debug.Log (GameState); | |
GameState = CamState.CameraSettings; | |
CamTxt.text = "Camera Settings"; | |
InfoTxt.text = "Press 0 to GO BACK to REGULAR CAMVIEW or ESC to DISABLE Camera"; | |
HintTxt.text = "Some Games have Multiple Camera views.\n" + | |
"Turning the Camera OFF Sometimes BREAKS the Game!`this can be changed`"; | |
} | |
} | |
/// <summary> | |
/// Cams the off. | |
/// </summary> | |
void CamOff () | |
{ | |
Debug.Log (GameState); | |
GameState = CamState.CamOff; | |
CamTxt.text = "Camera OFF"; | |
if (Input.GetKeyDown(KeyCode.Escape)) | |
{ | |
Debug.Log (GameState); | |
GameState = CamState.CamOff; | |
CamTxt.text = "Camera OFF"; | |
InfoTxt.text = "Press 0 to turn Cmera back ON or ESC to CLOSE the Program"; | |
HintTxt.text = "If you can't see anything Press 0.`this can be changed`"; | |
mainCamera.active = false; | |
if (Input.GetKeyDown(KeyCode.Escape)) | |
{ | |
int level=0; | |
Application.LoadLevel(level); | |
} | |
}else if (Input.GetKeyDown(KeyCode.Alpha0)) | |
{ | |
Debug.Log (GameState); | |
GameState = CamState.CameraSettings; | |
CamTxt.text = "Camera Settings"; | |
InfoTxt.text = "Press 0 to GO BACK to REGULAR CAMVIEW or ESC to DISABLE Camera"; | |
HintTxt.text = "Some Games have Multiple Camera views.\n" + | |
"Turning the Camera OFF Sometimes BREAKS the Game!`this can be changed`"; | |
mainCamera.active = true; | |
} | |
} | |
/// <summary> | |
/// Cams the AY. | |
/// </summary> | |
void CamAYS () | |
{ | |
Debug.Log (GameState); | |
GameState = CamState.CamAYS; | |
if (Input.GetKeyDown(KeyCode.Escape)) | |
{ | |
Debug.Log (GameState); | |
GameState = CamState.CamOff; | |
CamTxt.text = "Camera ON"; | |
InfoTxt.text = "Press 0 to turn Cmera back ON or ESC to CLOSE the Program"; | |
HintTxt.text = "If you can't see anything Press 0.`this can be changed`"; | |
}else if (Input.GetKeyDown(KeyCode.Alpha0)) | |
{ | |
Debug.Log (GameState); | |
GameState = CamState.CamOn; | |
CamTxt.text = "Camera ON"; | |
InfoTxt.text = "Press 0 to CANCEL or ESC to DISABLE Camera"; | |
HintTxt.text = "Some Games have Multiple Camera views.`this can be changed`"; | |
} | |
} | |
/// <summary> | |
/// Cameras the settings. | |
/// </summary> | |
void CameraSettings() | |
{ | |
Debug.Log (GameState); | |
if (Input.GetKeyDown(KeyCode.Alpha0)) | |
{ | |
Debug.Log (GameState); | |
GameState = CamState.CamOn; | |
CamTxt.text = "Camera ON"; | |
InfoTxt.text = "Press 0 to CANCEL or ESC to DISABLE Camera"; | |
HintTxt.text = "Some Games have Multiple Camera views.`this can be changed`"; | |
}else if (Input.GetKeyDown(KeyCode.Escape)) | |
{ | |
GameState = CamState.CameraSettings; | |
Debug.Log (GameState); | |
GameState = CamState.CamAYS; | |
CamTxt.text = "Camera On"; | |
InfoTxt.text = "Press 0 to turn Cmera back ON or ESC to CLOSE the Program"; | |
HintTxt.text = "If you can't see anything Press 0.`this can be changed`"; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ahahaha geeeze... i remember being so proud of this... i know soooo much more now.. funny to look back where i started till now. Made this when i did the Text 101 lesson on Unity Compete development 2D/3D learn to make games but writing code. lol 3 years ago now.