Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Intro_Scritping/Test_CYOA/Assets/Scripts/WorldUpdates.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
401 lines (339 sloc)
9.5 KB
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
using UnityEngine; | |
using System.Collections; | |
using UnityEngine.UI; | |
public class WorldUpdates : MonoBehaviour | |
{ | |
//Unity Text UI Stuff | |
public static string updateField; | |
Text updates; | |
//Click References | |
public Ray ray; | |
public RaycastHit hit; | |
//Assets, all of them | |
public GameObject enemy1; | |
public GameObject enemy2; | |
//Initialize Game | |
void Awake () | |
{ | |
updates = GetComponent<Text>(); | |
} | |
void Start() | |
{ | |
updateField = "..."; | |
} | |
void Update() | |
{ | |
ray = Camera.main.ScreenPointToRay(Input.mousePosition); | |
//Movement Updates | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "PlayerPos1") | |
{ | |
updateField = "update: moved"; | |
} | |
} | |
} | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "PlayerPos2") | |
{ | |
updateField = "update: moved"; | |
Debug.Log("moved!"); | |
} | |
} | |
} | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "PlayerPos3") | |
{ | |
updateField = "update: moved"; | |
} | |
} | |
} | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "PlayerPos4") | |
{ | |
updateField = "update: moved"; | |
} | |
} | |
} | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "PlayerPos5") | |
{ | |
updateField = "update: moved"; | |
} | |
} | |
} | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "PlayerPos6") | |
{ | |
updateField = "update: moved"; | |
} | |
} | |
} | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "PlayerPos7") | |
{ | |
updateField = "update: moved"; | |
} | |
} | |
} | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "PlayerPos8") | |
{ | |
updateField = "update: moved"; | |
} | |
} | |
} | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "PlayerPos9") | |
{ | |
updateField = "update: moved"; | |
} | |
} | |
} | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "PlayerPos10") | |
{ | |
updateField = "could this be the end?"; | |
} | |
} | |
} | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "PlayerPos11") | |
{ | |
updateField = "update: moved"; | |
} | |
} | |
} | |
//Object Updates | |
//Mega Gun | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "MegaGun") | |
{ | |
updateField = "update: recieved mega gun! damage increased!"; | |
} | |
} | |
} | |
//Health Kit | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "HealthKit") | |
{ | |
updateField = "update: health restored!"; | |
} | |
} | |
} | |
//Hidden Wall | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "**ANGLEDWALL**") | |
{ | |
updateField = "what type of creator?"; | |
} | |
} | |
} | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "DestroyWall") | |
{ | |
updateField = "maybe i can get past this?"; | |
} | |
} | |
} | |
//Floors - NOT working | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "Floors") | |
{ | |
updateField = "crazy floors, right?"; | |
} | |
} | |
} | |
//Enemies | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "Enemy1") | |
{ | |
updateField = "update: dealt and recieved damage!"; | |
} | |
} | |
} | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "Enemy2") | |
{ | |
updateField = "update: dealt and recieved damage!"; | |
} | |
} | |
} | |
//World Click Interactions | |
//Conversation | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "NPC") | |
{ | |
updateField = "hello! i hear that 23 is number 1"; | |
} | |
} | |
} | |
//Switch Puzzle | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "Switch1") | |
{ | |
updateField = "update: you hit 1"; | |
} | |
} | |
} | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "Switch2") | |
{ | |
updateField = "update: you hit 2"; | |
} | |
} | |
} | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "Switch3") | |
{ | |
updateField = "update: you hit 3"; | |
} | |
} | |
} | |
//Level up | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "XPCube") | |
{ | |
updateField = "level up! your durability has increased."; | |
} | |
} | |
} | |
//Victory Screen | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "TreasureTube") | |
{ | |
updateField = "did i win?"; | |
Application.LoadLevel(1); | |
} | |
} | |
} | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "TreasureTube1") | |
{ | |
updateField = "did i win?"; | |
Application.LoadLevel(1); | |
} | |
} | |
} | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "TreasureTube2") | |
{ | |
updateField = "did i win?"; | |
Application.LoadLevel(1); | |
} | |
} | |
} | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "TreasureTube3") | |
{ | |
updateField = "did i win?"; | |
Application.LoadLevel(1); | |
} | |
} | |
} | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "TreasureTube4") | |
{ | |
updateField = "did i win?"; | |
Application.LoadLevel(1); | |
} | |
} | |
} | |
if (Physics.Raycast(ray, out hit)) | |
{ | |
if (Input.GetKeyDown(KeyCode.Mouse0)) | |
{ | |
if (hit.transform.name == "TreasureTube5") | |
{ | |
updateField = "did i win?"; | |
Application.LoadLevel(1); | |
} | |
} | |
} | |
//Text - Update Field -- Keep Last | |
updates.text = updateField; | |
} | |
} |