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 GridLifeSupport : MonoBehaviour {
- // check XY
- // XY area
- private float XnumberFloat;
- private float YnumberFloat;
- public int Xnumber;
- public int Ynumber;
- public static int XnumberStatic;
- public static int YnumberStatic;
- // public static int XnumberStatic;
- // public static int YnumberStatic;
- // Area
- // public bool IsPartOfRoom = false;
- public bool BuildMode = false;
- public bool CelingShow = false;
- public static bool CelingShowStatic = false;
- public bool ActiveObjectSet = false;
- public bool ActiveObject = false;
- public static bool ActiveObjectStatic = false;
- public bool DisabledObject = false;
- public int OxygenCount = 100;
- public int FireCount = 0;
- public bool LightState = false;
- public int MaterialNumber = 0;
- public static int MaterialNumberStatic = 0;
- // public int DangerCount = 0; // Most likely to be shown differently in game as different situations , or not
- // GameObject Area
- public GameObject LightObject;
- public GameObject CelingObject;
- public GameObject WallObject0;
- public GameObject WallObject1;
- public GameObject WallObject2;
- public GameObject WallObject3;
- public GameObject PylonObject0;
- public GameObject PylonObject1;
- public GameObject PylonObject2;
- public GameObject PylonObject3;
- public Material ObjectMaterial;
- public Material GridMaterial;
- public Material ErrorMaterial;
- public Material GoodMaterial;
- public int SelectPointVar0 = 0;
- public int SelectPointVar1 = 0;
- public int SelectPointVar2 = 0;
- public int SelectPointVar3 = 0;
- public string StringFront;
- public string StringBack;
- public string StringLeft;
- public string StringRight;
- private int SelectPointVarX0;
- private int SelectPointVarX2;
- private int SelectPointVarY1;
- private int SelectPointVarY3;
- public GameObject FrontObject; // Left
- public GameObject RightObject; // Right
- public GameObject BackObject; // Back
- public GameObject LeftObject; // Front
- private bool Area0 = false;
- private bool Area1 = false;
- private bool Area2 = false;
- private bool Area3 = false;
- private bool Pylon0 = false;
- private bool Pylon1 = false;
- private bool Pylon2 = false;
- private bool Pylon3 = false;
- private bool Wall0 = false;
- private bool Wall1 = false;
- private bool Wall2 = false;
- private bool Wall3 = false;
- public static Ray CameraRay;
- public bool SelectedFromCamera = false;
- private bool Looking = false;
- public string DesignatedName;
- public static int DesignatedNumberStatic;
- // TO STRING
- private int XnumberString;
- private int YnumberString;
- public bool Room;
- // Use this for initialization
- void Start () {
- // DesignatedNumber = LifeSupport.AmountOfTilesStatic;
- // DesignatedNumber = DesignatedNumberStatic;
- }
- void LookingVoid () {
- if (Input.GetButton ("Look")) {
- Looking = true;
- }
- else {
- Looking = false;
- }
- }
- // 0 is Left
- // 2 is Right
- // 1 is Back
- // 3 is Front
- // ActivateTile Start
- void ActivateTile(){
- // GameObject[] objs;
- // if (ActiveObjectSet == true) {
- // objs = GameObject.FindGameObjectsWithTag ("Tile");
- // foreach (GameObject GridFloor in objs) {
- // and has Ynumber == SelectPointVarY3 to be a specific object;
- //like if SelectPointVarY3 = 2 , then the SelectPointObjectY3 would be a specific object and if SelectPointVarY3 was another value, then would be a different object
- // if (GridFloor.GetComponent<GridLifeSupport> ().Ynumber == SelectPointVarY3) { //F
- // SelectPointVar3 = 0;
- // }
- // 0 is Left
- // 2 is Right
- // 1 is Back
- // 3 is Front
- if (FrontObject == null) { //F
- SelectPointVar3 = 1;
- }
- if (BackObject == null) { //B
- SelectPointVar1 = 1;
- }
- if (RightObject == null) { //L
- SelectPointVar2 = 1;
- }
- if (LeftObject == null) { //R
- SelectPointVar0 = 1;
- }
- // if (FrontObject != null) { //F
- // SelectPointVar3 = 0;
- // }
- // if (BackObject != null) { //B
- // SelectPointVar1 = 0;
- // }
- // if (RightObject != null) { //L
- // SelectPointVar2 = 0;
- // }
- // if (LeftObject != null) { //R
- // SelectPointVar0 = 0;
- // }
- if (FrontObject.name == StringFront) { //F
- SelectPointVar3 = 0;
- }
- if (BackObject.name == StringBack) { //B
- SelectPointVar1 = 0;
- }
- if (RightObject.name == StringRight) { //L
- SelectPointVar2 = 0;
- }
- if (LeftObject.name == StringLeft) { //R
- SelectPointVar0 = 0;
- }
- else {
- SelectPointVar0 = 1;
- SelectPointVar1 = 1;
- SelectPointVar2 = 1;
- SelectPointVar3 = 1;
- }
- // }
- // }
- }
- // ActivateTile End
- void XYNumbersToString(){
- this.name = DesignatedName + XnumberString + "," + YnumberString;
- XnumberString.ToString();
- YnumberString.ToString();
- }
- // Update is called once per frame
- void Update () {
- if (FrontObject == null) { //F
- FrontObject = GameObject.Find (StringFront);
- }
- if (BackObject == null) { //B
- BackObject = GameObject.Find (StringBack);
- }
- if (RightObject == null) { //L
- RightObject = GameObject.Find (StringRight);
- }
- if (LeftObject == null) { //R
- LeftObject = GameObject.Find (StringLeft);
- }
- XYNumbersToString ();
- // 0 is Left
- // 2 is Right
- // 1 is Back
- // 3 is Front
- XnumberString = Xnumber;
- YnumberString = Ynumber;
- SelectPointVarX0 = Xnumber - 2;
- SelectPointVarX2 = Xnumber + 2;
- SelectPointVarY1 = Ynumber + 2;
- SelectPointVarY3 = Ynumber - 2;
- //String Position Area
- StringFront = XnumberString + "," + SelectPointVarY3.ToString();
- StringBack = XnumberString + "," + SelectPointVarY1.ToString();
- StringRight = SelectPointVarX2.ToString() + "," + YnumberString;
- StringLeft = SelectPointVarX0.ToString() + "," + YnumberString;
- //String Position Area End
- XnumberStatic = Xnumber;
- YnumberStatic = Ynumber;
- // XY area
- XnumberFloat = this.transform.localPosition.x;
- YnumberFloat = this.transform.localPosition.y;
- Xnumber = (int)XnumberFloat ;
- Ynumber = (int)YnumberFloat ;
- LookingVoid ();
- // Mouse Raycast
- if (Looking == false) {
- if (Input.GetMouseButton (0)) {
- Camera theCamera = Camera.main;
- //Or Camera.main
- //can be set to variable
- Ray ray = theCamera.ScreenPointToRay (Input.mousePosition);
- RaycastHit hitInfo;
- CameraRay = ray;
- if (Physics.Raycast (ray, out hitInfo)) {
- if (hitInfo.collider.GetComponent<Collider> () == this.GetComponent<Collider> ()) {
- ActiveObject = true;
- SelectedFromCamera = true;
- if (SelectedFromCamera == true) {
- if (ActiveObject == true) {
- MaterialNumber = 3;
- }
- }
- }
- // if (hitInfo.collider.GetComponent<Collider> () != this.GetComponent<Collider>()) {
- // if (SelectedFromCamera == false) {
- // ActiveObject = false;
- // }
- // }
- }
- }
- if (Input.GetMouseButton (1)) {
- Camera theCamera = Camera.main;
- //Or Camera.main
- //can be set to variable
- Ray ray = theCamera.ScreenPointToRay (Input.mousePosition);
- RaycastHit hitInfo;
- CameraRay = ray;
- if (Physics.Raycast (ray, out hitInfo)) {
- if (hitInfo.collider.GetComponent<Collider> () == this.GetComponent<Collider> ()) {
- ActiveObject = false;
- SelectedFromCamera = false;
- if (MouseManager.EditRoomStatic == true) {
- if (ActiveObjectSet == true) {
- ActiveObjectSet = false;
- }
- }
- }
- }
- }
- }
- if (Input.GetButtonDown ("Enter")) {
- if (SelectedFromCamera == true) {
- ActiveObjectSet = true;
- ActivateTile ();
- }
- }
- // Mouse Raycast
- if (ActiveObjectSet == true) {
- ActiveObject = true;
- MaterialNumber = 1;
- }
- if (MouseManager.DisableCelingStatic == true) {
- if (ActiveObjectSet == true) {
- CelingObject.SetActive (false);
- }
- }
- if (MouseManager.DisableCelingStatic == false) {
- if (ActiveObjectSet == true) {
- CelingObject.SetActive (true);
- }
- }
- if (ActiveObjectSet != true) {
- CelingObject.SetActive (false);
- }
- CelingShow = CelingShowStatic;
- ActiveObjectStatic = ActiveObject;
- if (MouseManager.DisableGridStatic == false) {
- if (ActiveObject == false) {
- MaterialNumber = 0;
- }
- }
- if (MouseManager.DisableGridStatic == true) {
- if (MaterialNumber != 1) {
- SelectedFromCamera = false;
- ActiveObject = false;
- }
- if (ActiveObject == false) {
- MaterialNumber = -1;
- }
- }
- MeshRenderer ObjectRender = GetComponent<MeshRenderer> ();
- //Material change
- if (MaterialNumber <= 0) {
- LightState = false;
- }
- if (MaterialNumber <= -1) {
- GetComponent<Renderer> ().enabled = false;
- GetComponent<Collider> ().enabled = false;
- }
- if (MaterialNumber > -1) {
- GetComponent<Renderer> ().enabled = true;
- GetComponent<Collider> ().enabled = true;
- }
- if (MaterialNumber == 0) {
- ObjectRender.material = GridMaterial;
- }
- if (MaterialNumber == 1) {
- ObjectRender.material = ObjectMaterial;
- }
- if (MaterialNumber == 2) {
- ObjectRender.material = ErrorMaterial;
- }
- if (MaterialNumber == 3) {
- ObjectRender.material = GoodMaterial;
- }
- //Material change
- if (LightState == true) {
- LightObject.SetActive(true);
- }
- if (LightState == false) {
- LightObject.SetActive(false);
- }
- ////////////////////////////////// Wall Area
- // Wall Enable
- if (Wall0 == true) {
- WallObject0.SetActive(true);
- }
- if (Wall1 == true) {
- WallObject1.SetActive(true);
- }
- if (Wall2 == true) {
- WallObject2.SetActive(true);
- }
- if (Wall3 == true) {
- WallObject3.SetActive(true);
- }
- // Wall Disable
- if (Wall0 == false) {
- WallObject0.SetActive(false);
- }
- if (Wall1 == false) {
- WallObject1.SetActive(false);
- }
- if (Wall2 == false) {
- WallObject2.SetActive(false);
- }
- if (Wall3 == false) {
- WallObject3.SetActive(false);
- }
- // Pylon Enable
- if (Pylon0 == true) {
- PylonObject0.SetActive(true);
- }
- if (Pylon1 == true) {
- PylonObject1.SetActive(true);
- }
- if (Pylon2 == true) {
- PylonObject2.SetActive(true);
- }
- if (Pylon3 == true) {
- PylonObject3.SetActive(true);
- }
- // Pylon Disable
- if (Pylon0 == false) {
- PylonObject0.SetActive(false);
- }
- if (Pylon1 == false) {
- PylonObject1.SetActive(false);
- }
- if (Pylon2 == false) {
- PylonObject2.SetActive(false);
- }
- if (Pylon3 == false) {
- PylonObject3.SetActive(false);
- }
- //SelectPoint Variables
- if (SelectPointVar0 == 0) {
- Wall0 = false;
- Area0 = false;
- }
- if (SelectPointVar1 == 0) {
- Wall1 = false;
- Area1 = false;
- }
- if (SelectPointVar2 == 0) {
- Wall2 = false;
- Area2 = false;
- }
- if (SelectPointVar3 == 0) {
- Wall3 = false;
- Area3 = false;
- }
- if (SelectPointVar0 == 1) {
- Wall0 = true;
- Area0 = true;
- }
- if (SelectPointVar1 == 1) {
- Wall1 = true;
- Area1 = true;
- }
- if (SelectPointVar2 == 1) {
- Wall2 = true;
- Area2 = true;
- }
- if (SelectPointVar3 == 1) {
- Wall3 = true;
- Area3 = true;
- }
- // Pylon 0
- if (Area0 == true || Area3 == true) {
- Pylon0 = true;
- }
- // Pylon 1
- if (Area1 == true || Area0 == true) {
- Pylon1 = true;
- }
- // Pylon 2
- if (Area1 == true || Area2 == true) {
- Pylon2 = true;
- }
- // Pylon 3
- if (Area2 == true || Area3 == true) {
- Pylon3 = true;
- }
- //Disable Pylons if there is no wall connecting it
- // Pylon 0
- if (Area0 == false && Area3 == false) {
- Pylon0 = false;
- }
- // Pylon 1
- if (Area1 == false && Area0 == false) {
- Pylon1 = false;
- }
- // Pylon 2
- if (Area1 == false && Area2 == false) {
- Pylon2 = false;
- }
- // Pylon 3
- if (Area2 == false && Area3 == false) {
- Pylon3 = false;
- }
- ////////////////////////////////// Wall Area
- //End Update
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement