04.07.2022

This commit is contained in:
Plotnikov
2022-07-04 13:15:35 +03:00
parent 5fad2bcf6b
commit 696daa0b2e
7224 changed files with 3814576 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ButtonClick : MonoBehaviour
{
//Button load; // Что за Button ?
Manager mgr;
//int state = 0;
// Start is called before the first frame update
void Start()
{
GameObject manager = GameObject.Find("Manager");
mgr = manager.GetComponent<Manager>();
// load = GameObject.Find("Button");
Debug.Log(mgr);
}
private void OnMouseDown()
{
//Debug.Log("clickPanel button");
//Debug.Log(mgr.stepPanels["Panel0506"].GetComponent<panel>().switchesList["toggle4_0506"].GetComponent<Switch>());
//GameObject manager = GameObject.Find("Manager");
//manager.GetComponent<Manager>().SwitchTo2D();
/*if(state == 1)
{
state = 0;
}
else
{
state = 1;
}*/
//mgr.stepPanels["Panel0506"].GetComponent<panel>().switchesList["toggle4_0506"].GetComponent<Switch>().setState((int)state);
//mgr.stepPanels["Panel0506"].GetComponent<panel>().switchesList["toggle4_0506"].GetComponent<Switch>().setState(0);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 88c1feab0260b1346b6aad3e958149f4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using UnityEngine;
using System.Collections;
public class FPS : MonoBehaviour
{
int oldFPS=0;
int cnt = 0;
void OnGUI()
{
int fps = (int)(1.0f / Time.deltaTime);
if (fps != oldFPS) cnt++;
if(cnt > 40)
{
cnt = 0; oldFPS = fps;
}
GUILayout.Label("FPS = " + oldFPS);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bcd6fbf5c6eb2b649a341de8917e4e8f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
using UnityEngine;
using System.Collections;
public class FPS : MonoBehaviour
{
private GUIStyle guiStyle = new GUIStyle();
int oldFPS=0;
int cnt = 0;
void OnGUI()
{
int fps = (int)(1.0f / Time.deltaTime);
if (fps != oldFPS) cnt++;
if(cnt > 40)
{
cnt = 0; oldFPS = fps;
}
guiStyle.fontSize = 22;
GUILayout.Label("FPS = " + oldFPS, guiStyle);
}
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 540931fcf4aa1c542a306bb2bc9c0d71
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,67 @@
//using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
//using Debug = UnityEngine.Debug;
public class Handle2 : MonoBehaviour, IPointerDownHandler
{
public GameObject handle_on;
public GameObject handle_off;
// Start is called before the first frame update
void Start()
{
handle_off.SetActive(true);
handle_on.SetActive(false);
}
// Update is called once per frame
//void Update()
//{
/* Vector2 CurMousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
if (Input.GetMouseButtonUp(0))
{
//Для работы Raycast необходимо, чтоб объект имел компонент Collider
//В rayHit мы занесем результат выполнения команды Raycast
//там будет либо null, если raycast никого не задел, либо первый
//объект, стоящий на пути мышки (какой объект будет первым
//решает его положение Z в мировом пространстве)
RaycastHit2D rayHit = Physics2D.Raycast(CurMousePos, Vector2.zero);
if (rayHit.transform !=null)
{
Debug.Log("Selected object: "+ rayHit.transform.name);
// handle_on.SetActive(true);
}
} */
//}
public void OnPointerDown(PointerEventData eventData)
{
Vector2 CurMousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
RaycastHit2D rayHit = Physics2D.Raycast(CurMousePos, Vector2.zero);
if (rayHit.transform !=null)
{
Debug.Log("Selected object: "+ rayHit.transform.name);
}
}
/* void OnMouseDown()
{
print("handle_off click");
handle_off.SetActive(false);
handle_on.SetActive(true);
} */
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 04c3a3c59fcc95e45b604e5b9d34fa8b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,27 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HoldPanelsRedactor : MonoBehaviour
{
public void HoldPanelLeft()
{
GameObject.Find("Panel1 Hidden Elements").transform.localPosition = new
Vector3(-1000f, 0, 0);
}
public void UnHoldPanelLeft()
{
GameObject.Find("Panel1 Hidden Elements").transform.localPosition = new
Vector3(0, 0, 0);
}
public void HoldPanelRight()
{
GameObject.Find("Panel2 Hidden Elements").transform.localPosition = new
Vector3(1000f, -13.99999f, 0);
}
public void UnHoldPanelRight()
{
GameObject.Find("Panel2 Hidden Elements").transform.localPosition = new
Vector3(-4.999922f, -13.99999f, 0);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f8aef503e3f86fc4c8fa17c8bed51355
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cb212bb1d3a05d54fa6148fa571e3317
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a6f284d2f29abec428e4781e1237150a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5a7929b6b9f250541823c41e705ef7f0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,193 @@
<<<<<<< HEAD
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class drCol112 : MonoBehaviour
{
protected Vector3 mousePosition;
protected Vector2 a; // Vector2 deltaPosition
public string typeDrag = null;
public float dragMin, dragMax;
public bool clamp = false;
[HideInInspector] public Vector2 dd;//для передачи в connection
[HideInInspector] public bool _delta = false;//для передачи в connection
[HideInInspector] public bool isDrag = false;
Manager man;
Camera cam;//камера для канваса с панелями
private void Awake()
{
dd = new Vector2(transform.localPosition.x, transform.localPosition.y);
if (man == null) man = GameObject.Find("Manager").GetComponent<Manager>();
cam = man.cam;
}
public void OnMouseDown()
{
calculationBegin();
}
public void OnMouseDrag()
{
calculationDrag();
}
public void OnMouseUp()
{
dd = new Vector2(transform.localPosition.x, transform.localPosition.y);
if (typeDrag == "x" && (dd.x == dragMin || dd.x == dragMax))
{
_delta = true;
}
else if (typeDrag == "y" && (dd.y == dragMin || dd.y == dragMax))
{
_delta = true;
}
else
{
_delta = false;
}
isDrag = false;
}
public void calculationBegin()
{
//a = new Vector2(Input.mousePosition.x - transform.localPosition.x, Input.mousePosition.y - transform.localPosition.y);
mousePosition = cam.ScreenToWorldPoint(Input.mousePosition);//mousePosition = Input.mousePosition;
a = new Vector2(mousePosition.x - transform.localPosition.x, mousePosition.y - transform.localPosition.y);
isDrag = true;
}
public void calculationDrag()
{
if (man.mode == "scedit" || man.mode == "play")
return;
mousePosition = cam.ScreenToWorldPoint(Input.mousePosition);//mousePosition = Input.mousePosition;
Vector2 q = new Vector2(mousePosition.x, mousePosition.y);
Vector3 b = new Vector3(q.x - a.x, q.y - a.y, transform.localPosition.z);
if (typeDrag == "x")
{
b.x = (clamp) ? Mathf.Clamp(b.x, dragMin, dragMax) : b.x;
transform.localPosition = new Vector3(b.x, transform.localPosition.y, transform.localPosition.z);
}
else
if (typeDrag == "y")
{
b.y = (clamp) ? Mathf.Clamp(b.y, dragMin, dragMax) : b.y;
transform.localPosition = new Vector3(transform.localPosition.x, b.y, transform.localPosition.z);
}
else
{
transform.localPosition = b;
}
}
public void SetState(int b)
{
float bf = (clamp) ? Mathf.Clamp((float)b/100f, dragMin, dragMax) : b/100;
//b += (int)(dragMax - dragMin) / 2;
if (typeDrag == "x")
transform.localPosition = new Vector3(bf, transform.localPosition.y, transform.localPosition.z);
else
if (typeDrag == "y")
transform.localPosition = new Vector3(transform.localPosition.x, bf, transform.localPosition.z);
}
}
=======
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class drCol112 : MonoBehaviour
{
protected Vector3 mousePosition;
protected Vector2 a; // Vector2 deltaPosition
public string typeDrag = null;
public float dragMin, dragMax;
public bool clamp = false;
[HideInInspector] public Vector2 dd;//для передачи в connection
[HideInInspector] public bool _delta = false;//для передачи в connection
[HideInInspector] public bool isDrag = false;
Manager man;
Camera cam;//камера для канваса с панелями
private void Awake()
{
dd = new Vector2(transform.localPosition.x, transform.localPosition.y);
if (man == null) man = GameObject.Find("Manager").GetComponent<Manager>();
cam = man.cam;
}
public void OnMouseDown()
{
calculationBegin();
}
public void OnMouseDrag()
{
calculationDrag();
}
public void OnMouseUp()
{
dd = new Vector2(transform.localPosition.x, transform.localPosition.y);
if (typeDrag == "x" && (dd.x == dragMin || dd.x == dragMax))
{
_delta = true;
}
else if (typeDrag == "y" && (dd.y == dragMin || dd.y == dragMax))
{
_delta = true;
}
else
{
_delta = false;
}
isDrag = false;
}
public void calculationBegin()
{
//a = new Vector2(Input.mousePosition.x - transform.localPosition.x, Input.mousePosition.y - transform.localPosition.y);
mousePosition = cam.ScreenToWorldPoint(Input.mousePosition);//mousePosition = Input.mousePosition;
a = new Vector2(mousePosition.x - transform.localPosition.x, mousePosition.y - transform.localPosition.y);
isDrag = true;
}
public void calculationDrag()
{
if (man.mode == "scedit" || man.mode == "play")
return;
mousePosition = cam.ScreenToWorldPoint(Input.mousePosition);//mousePosition = Input.mousePosition;
Vector2 q = new Vector2(mousePosition.x, mousePosition.y);
Vector3 b = new Vector3(q.x - a.x, q.y - a.y, transform.localPosition.z);
if (typeDrag == "x")
{
b.x = (clamp) ? Mathf.Clamp(b.x, dragMin, dragMax) : b.x;
transform.localPosition = new Vector3(b.x, transform.localPosition.y, transform.localPosition.z);
}
else
if (typeDrag == "y")
{
b.y = (clamp) ? Mathf.Clamp(b.y, dragMin, dragMax) : b.y;
transform.localPosition = new Vector3(transform.localPosition.x, b.y, transform.localPosition.z);
}
else
{
transform.localPosition = b;
}
}
public void SetState(int b)
{
float bf = (clamp) ? Mathf.Clamp((float)b/100f, dragMin, dragMax) : b/100;
//b += (int)(dragMax - dragMin) / 2;
if (typeDrag == "x")
transform.localPosition = new Vector3(bf, transform.localPosition.y, transform.localPosition.z);
else
if (typeDrag == "y")
transform.localPosition = new Vector3(transform.localPosition.x, bf, transform.localPosition.z);
}
}
>>>>>>> 3b1b9479a46e90d056b92897ea9f8422b25fc052

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ebc4de7888e30984680948b2b1c6b5d0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fcc0046aa8c948d419b8c9b95e2af94a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,186 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class ArrowToText : MonoBehaviour//frame1 0115
{
public GameObject arrow;//стрелочка на шкале
//public Text speed;//счетчик
public TextMeshPro speed;//счетчик
public GameObject frame;//цветная рамка
float rotateZ; //предыдущее значение rotateZ
float d, d1; //коэффициенты d (0-100), d1 (100-350)
float k; //текущее значение счетчика в float
bool reverse = false; //направление
(int scale,int count) min = ( 0, 40 );//минимальное значение счетчика
int max = 350;//максимальное значение счетчика
float waitTime = 0.005f;//время для корутины
bool point = false;//нажатие на счетчик
private Coroutine coroutine;
private void Start()
{
//Debug.Log($"min.Item1 = {min.scale}");
d = 100 / (125-112);
d1 = 4.7f;
OnK();
scaleText();
Rever();
}
private void Update()
{
if (rotateZ != arrow.gameObject.transform.eulerAngles.z)
{
ref readonly bool dragArrow = ref arrow.gameObject.GetComponent<Handler>().drag;
if (dragArrow)
{
if (coroutine != null)
{
StopCoroutine(coroutine);
point = false;
}
OnK();
scaleText();
Rever();
}
}
}
private void scaleText()
{
int ko = (int)k;
if (ko <320)
{
speed.color = Color.white;
if (frame.gameObject.GetComponent<ButtonCheckable3>() != null)
{
frame.gameObject.GetComponent<ButtonCheckable3>().EnableSprite(0);
}
}
else
{
speed.color = Color.red;
if (frame.gameObject.GetComponent<ButtonCheckable3>() != null)
{
frame.gameObject.GetComponent<ButtonCheckable3>().EnableSprite(1);
}
}
ko = ko / 10 * 10;
if (ko < min.count)
{
//speed.text = "";
speed.SetText("");
}
else
{
//speed.text = ko.ToString();
speed.SetText(ko.ToString());
}
}
private void OnK()
{
rotateZ = arrow.gameObject.transform.eulerAngles.z;
if(rotateZ > 111)
{
//Debug.Log($"здесь до 100");
k = (125 - rotateZ) * d;
}
if (rotateZ < 111&& rotateZ != 111)
{
//Debug.Log($"здесь после 100");
k = (90 - rotateZ) * d1+200;
}
if (rotateZ > 110.4&&rotateZ< 111.4)
{
//Debug.Log($"111 = 100");
k = 100f;
}
}
private void OnMouseDown()//нажатие на счетчик
{
//Debug.Log("кликнули");
point = !point;
if (point)
{
Rever();
if (reverse)
{
k--;
coroutine = StartCoroutine(AltNumber());
}
else
{
k++;
coroutine = StartCoroutine(AltNumber());
}
}
else
{
if (coroutine != null) StopCoroutine(coroutine);
}
}
private void Rever()
{
if (k <= min.scale)
{
reverse = false;
}
else if (k >= max)
{
reverse = true;
}
}
IEnumerator AltNumber()
{
while (point)
{
scaleText();
if (k<100)
{
//Debug.Log($"здесь до 100");
rotateZ = 125f - k / d;
}
if (k>100)
{
//Debug.Log($"здесь после 100");
rotateZ = 90 - (k - 200) / d1;
}
if (k >99&&k<101)
{
//Debug.Log($"111 = 100");
rotateZ =111;
}
arrow.gameObject.transform.localRotation = Quaternion.Euler(0f, 0f, rotateZ);
if (reverse)
{
k--;
}
else
{
k++;
}
Rever();
yield return new WaitForSeconds(waitTime);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: afc158455bff7b24d823abb363d0f527
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,45 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
//TextBarPressure
public class BarPressure : MonoBehaviour
{
[HideInInspector]
public string textValue_="";
private (string, string) defaultValue_ = ("766 мм рт.ст", "1013 гѕ");
private TextMeshPro text_;
//private Text text_;
void Start()
{
text_ = this.GetComponent<TextMeshPro>();
var txt= (textValue_ == "") ? defaultValue_.Item1 : textValue_;
text_.SetText(txt);
/*text_ = this.gameObject.GetComponent<Text>();
text_.text = (textValue_ == "") ? defaultValue_.Item1 : textValue_;*/
}
private void OnMouseDown()//нажатие на счетчик
{
if(textValue_ == "")
{
var txt = (text_.text == defaultValue_.Item2) ? defaultValue_.Item1 : defaultValue_.Item2;
text_.SetText(txt);
}
else
{
text_.SetText(textValue_);
}
/*if(textValue_ == "")
{
text_.text = (text_.text == defaultValue_.Item2) ? defaultValue_.Item1 : defaultValue_.Item2;
}
else
{
text_.text = textValue_;
}*/
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3f14814a73c530147842864cd374c0af
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,132 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ColliderIgnore : MonoBehaviour
{
/* Collider2D[] colliders;
[ContextMenuItem("0115", "On0115")]
// [ContextMenuItem("0107", "On0107")]
// [ContextMenuItem("0108", "On0108")]
// [ContextMenuItem("0124", "On0124")]
// [ContextMenuItem("0125", "On0125")]
[ContextMenuItem("0112", "On0112")]
[ContextMenuItem("0114", "On0114")]
[ContextMenuItem("0117", "On0117")]
[ContextMenuItem("0204", "On0204")]
[ContextMenuItem("0207", "On0207")]
[ContextMenuItem("0601", "On0601")]
[ContextMenuItem("0507", "On0507")]
[SerializeField] private string[] nameColliders;
void On0115() => nameColliders = new string[] { "Arrow0115", "Button2_0115", "RotateAvia", "index0115", "TextBarPressure", "Frame2Text_115", "Frame2_0115", "Frame3Text115", "Frame3_0115", "Frame4_0115", "Frame4Text", "Poplavok0115" };
//void On0107() => nameColliders = new string[] { "Handle4_0107", "Handle5_0107" };
//void On0108() => nameColliders = new string[] { "Handle4_0108", "Handle5_0108" };
//void On0124() => nameColliders = new string[] { "Handle4_0124", "Handle5_0124" };
//void On0125() => nameColliders = new string[] { "Handle4_0125", "Handle5_0125" };
void On0112() => nameColliders = new string[] { "handle0112", "blenker0112_1", "blenker0112_2", "airPlane0112", "poplavok0112" };
void On0114() => nameColliders = new string[] { "Arrow0114", "Scale1_0114_2", "Scale1_0114_1" };
void On0117() => nameColliders = new string[] { "arrow1_0117_4", "arrow1_0117_3", "arrow1_0117_2", "arrow2_0117_2" };
void On0204() => nameColliders = new string[] { "Handle1_0204_2", "Handle2_0204_2" };
void On0207() => nameColliders = new string[] { "Handle1_0207_2", "Handle2_0207_2" };
void On0601() => nameColliders = new string[] { "bazatop_0601" };
void On0507() => nameColliders = new string[] { "Button1_0507_1", "Button2_0507_1", "Button3_0507_1" };
private void Awake()
{
colliders = transform.parent.GetComponentsInChildren<Collider2D>();
//nameColliders = new string[] { "Button2_0115", "RotateAvia", "index0115", "TextBarPressure", "Frame2Text_115", "Frame2_0115", "Frame3Text115", "Frame3_0115", "Frame4_0115", "Frame4Text", "Poplavok0115" };
for (int k = 0; k < nameColliders.Length; k++)
{
for (int i = 0; i < colliders.Length; i++)
{
if (colliders[i].name == nameColliders[k] && colliders[i].gameObject.GetComponent<ExitColliderIgnore>() == null)
{
colliders[i].gameObject.AddComponent<ExitColliderIgnore>();
colliders[i].gameObject.GetComponent<ExitColliderIgnore>().pan = this.gameObject.GetComponent<ColliderIgnore>();
}
}
}
}
private void Start()
{
//cam = GameObject.Find("Camera").GetComponent<Camera>();
if (man == null) man = GameObject.Find("Manager").GetComponent<Manager>();
cam = man.cam;
}
public void OnMouseEnter()
{
ChangeColliderIgnore(false);
}
public void OnMouseExit()
{
ChangeColliderIgnore(true);
}
public void ChangeColliderIgnore(bool enableCollider, string colliderTrue)
{
if (enableCollider)
{
for (int i = 0; i < colliders.Length; i++)
{
colliders[i].enabled = enableCollider;
}
}
else
{
for (int k = 0; k < nameColliders.Length; k++)
{
for (int i = 0; i < colliders.Length; i++)
{
if (colliders[i].name != colliderTrue)
{
colliders[i].enabled = enableCollider;
}
else
{
colliders[i].enabled = true;
}
}
}
}
}
Camera cam;
Manager man;
void Update()
{
if (!cam.gameObject.activeSelf) return;
Vector2 CurMousePos = cam.ScreenToWorldPoint(Input.mousePosition);
if (Input.GetMouseButtonUp(0))
{
RaycastHit2D[] allHits = Physics2D.RaycastAll(CurMousePos, Vector2.zero);
bool flag = true;
for (int k = 0; k < nameColliders.Length; k++)
{
for (int i = 0; i < allHits.Length; i++)
{
if (allHits[i].transform.name != nameColliders[k])
{
ChangeColliderIgnore(flag, "");
// Debug.Log($"flag = {flag} allHits[i].transform.name = {allHits[i].transform.name}");
}
else
{
flag = false;
ChangeColliderIgnore(flag, nameColliders[k]);
//Debug.Log($"flag = {flag} allHits[i].transform.name = {allHits[i].transform.name}");
break;
}
}
if (!flag) break;
}
}
}*/
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 61f3ed9fcc3f8e343957de775a8bbc3a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,12 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ExitColliderIgnore : MonoBehaviour
{
/* public ColliderIgnore pan;
public void OnMouseExit()
{
pan.ChangeColliderIgnore(true, "");
}*/
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b5f185c6060b5384c99eae696e9d2c38
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,22 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HLightParent : MonoBehaviour
{
private HlightBtn arrow;
private void Awake()
{
arrow = transform.GetComponentInParent<HlightBtn>();
}
public void OnMouseEnter()
{
arrow.OnMouseEnter();
}
public void OnMouseExit()
{
arrow.OnMouseExit();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e06d96d0bad5b0648810607139c93874
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,36 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HlightBtn : MonoBehaviour
{
private SpriteRenderer arrow;
private SpriteRenderer arrowDown;
private void Awake()
{
arrow = transform.GetComponent<SpriteRenderer>();
arrow.enabled = false;
var nameA = this.name.Substring(0, this.name.Length) + "_arrow";
arrowDown = transform.Find(nameA).gameObject.GetComponent<SpriteRenderer>();
arrowDown.enabled = false;
}
public void OnMouseEnter()
{
arrow.enabled = true;
}
public void OnMouseExit()
{
arrow.enabled = false;
}
private void OnMouseDown()
{
arrowDown.enabled = true;
arrow.enabled = false;
}
private void OnMouseUp()
{
arrowDown.enabled = false;
arrow.enabled = true;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 85a678afbbf56f84eb33baa4163a54d8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,13 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class IndexH : MonoBehaviour//index0115
{
[SerializeField]
private GameObject connectScale;
[SerializeField]
public GameObject frame;
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: aa1408457d090864cb68232e029a14b7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,129 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class ScaleToText : MonoBehaviour//frame3 0115
{
public GameObject scale;//шкала
//public Text altitude;//счетчик
public TextMeshPro altitude;//счетчик
public GameObject frame;
float Y; //пердыдущее значение y
float d; //коэффициент
float k; //текущее значение счетчика в float
bool reverse = false; //направление
int min = -130;//минимальное значение счетчика
int max = 6760;//максимальное значение счетчика
float waitTime = 0.005f;//время для корутины
[HideInInspector] public bool point = false;//нажатие на счетчик
private Coroutine coroutine;
private void Start()
{
d = 3450 / 1800f;
OnK();
scaleText();
Rever();
}
private void Update()
{
if (Y != scale.gameObject.transform.localPosition.y)
{
OnK();
scaleText();
Rever();
}
}
private void scaleText()
{
int ko = (int)k;
if (ko >= 0)
{
altitude.color = Color.white;
if (frame.gameObject.GetComponent<ButtonCheckable3>()!= null)
{
frame.gameObject.GetComponent<ButtonCheckable3>().EnableSprite(0);
}
}
else
{
altitude.color = Color.yellow;
if (frame.gameObject.GetComponent<ButtonCheckable3>() != null)
{
frame.gameObject.GetComponent<ButtonCheckable3>().EnableSprite(1);
}
}
if (ko > 100 || ko < -100)
{
ko = ko / 10 * 10;
}
//altitude.text = ko.ToString();
altitude.SetText(ko.ToString());
}
private void OnK()
{
Y = scale.gameObject.transform.localPosition.y;
k = -Y * d + 3310f;
}
private void OnMouseDown()//нажатие на счетчик
{
point = !point;
if (point)
{
Rever();
if (reverse)
{
k--;
coroutine = StartCoroutine(AltNumber());
}
else
{
k++;
coroutine = StartCoroutine(AltNumber());
}
}
else
{
if(coroutine!=null)StopCoroutine(coroutine);
}
}
private void Rever()
{
if (k <= min)
{
reverse = false;
}else if(k >= max)
{
reverse = true;
}
}
IEnumerator AltNumber()
{
while (point)
{
scaleText();
Y = (k - 3310f) / -d;
scale.gameObject.transform.localPosition = new Vector3(scale.gameObject.transform.localPosition.x, Y, scale.gameObject.transform.localPosition.z);
if (reverse)
{
k--;
}
else
{
k++;
}
Rever();
yield return new WaitForSeconds(waitTime);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c31b2b42328c5cb46b49cb6fffeee26d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,170 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using UnityEditor;
//[AddComponentMenu("Transform/Follow Transform")]
[RequireComponent(typeof(TextMeshPro))]
[RequireComponent(typeof(Collider2D))]
public class ScaleToText4 : MonoBehaviour
{
[Header("Objects")]
public GameObject scale;//шкала с которой связан счетчик
public TextMeshPro countNumber;//счетчик
public GameObject frame;//рамка
[SerializeField] private GameObject Panel;// родительская панель
private float Y; // (оставила название) предыдущее значение изменяемой координаты, в данном случае y
private float d; //коэффициент
private float k; //текущее значение счетчика в float
private bool reverse = false; //направление
[Header("Variables")]
[SerializeField] private int min = -340;// минимальное значение счетчика для frame3 =-130
[SerializeField] private int max = 340;// максимальное значение счетчика для frame3 =6760
[SerializeField] private float deltaScale = 15f;// дельта шкалы для frame3 =3450
[SerializeField] private float deltaCoorScale = 105f;// дельта координат шкалы (сколько юнитов координат в deltaScale) для frame3 =1800
[SerializeField] private float startCoorScale = 1263f;// координаты шкалы для счетчика 0
[Space(15)]
[Tooltip("x or y")] [SerializeField] private string typeXY="y";// тип сериализуемый
[Space(10)]
[SerializeField] private float waitTime = 0.05f;//время для корутины
[HideInInspector] public bool point = false;//нажатие на счетчик
private Coroutine coroutine;
private void Start()
{
countNumber = transform.GetComponent<TextMeshPro>();
d = deltaCoorScale / deltaScale;//высчитывается дельта координат к дельте шкалы
OnK();
scaleText();
Rever();
waitTime = 0.005f;
}
private void Update()
{
if ((typeXY == "x"&&Y != scale.gameObject.transform.localPosition.x)|| (typeXY == "y" && Y != scale.gameObject.transform.localPosition.y))//проверка типа
{
OnK();
scaleText();
Rever();
}
}
private void scaleText()
{
//Debug.Log($"k = {k}");
int ko = (int)k;
//Debug.Log($"ko = {ko}");
if (typeXY == "y" && Panel.transform.name == "Panel0115")//проверка типа начало
{
if (ko >= 0)
{
countNumber.color = Color.white;
if (frame.gameObject.GetComponent<ButtonCheckable3>() != null)
{
frame.gameObject.GetComponent<ButtonCheckable3>().EnableSprite(0);
}
}
else
{
countNumber.color = Color.yellow;
if (frame.gameObject.GetComponent<ButtonCheckable3>() != null)
{
frame.gameObject.GetComponent<ButtonCheckable3>().EnableSprite(1);
}
}
if (ko > 100 || ko < -100)
{
ko = ko / 10 * 10;
}
} else if (typeXY == "x" && Panel.transform.name == "Panel0115"){
if (ko < 0)
{
ko = 360 + ko;
}
}
//проверка типа конец
// altitude.text = ko.ToString();
countNumber.SetText(ko.ToString());
}
private void OnK()
{
Y = (typeXY == "x")? scale.gameObject.transform.localPosition.x: scale.gameObject.transform.localPosition.y;//проверка типа
k = -(Y- startCoorScale) / d;//дельта
}
private void OnMouseDown()//нажатие на счетчик
{
/*point = !point;
//Debug.Log($"point = {point}");
if (point)
{
Rever();
if (reverse)
{
k-=0.5f;
coroutine = StartCoroutine(AltNumber());
}
else
{
k+=0.5f;
coroutine = StartCoroutine(AltNumber());
}
}
else
{
if (coroutine != null) StopCoroutine(coroutine);
}*/
}
private void Rever()
{
//Debug.Log($" вне условия k = {k}; min = {min}; max = {max}");
if (k <= min)
{
//Debug.Log($"1. k <= min; {k}<= {min}");
reverse = false;
}
else if (k >= max)
{
//Debug.Log($"2. k >= max; {k}>= {max}");
reverse = true;
}
}
IEnumerator AltNumber()
{
while (point)
{
scaleText();
Y = -(k *d) + startCoorScale;//дельта
if (typeXY == "x")
{
scale.gameObject.transform.localPosition = new Vector3(Y, scale.gameObject.transform.localPosition.y, scale.gameObject.transform.localPosition.z);
//Debug.Log($"scale.gameObject.transform.localPosition = {scale.gameObject.transform.localPosition}");
}
else if(typeXY == "y"){
scale.gameObject.transform.localPosition = new Vector3(scale.gameObject.transform.localPosition.x, Y, scale.gameObject.transform.localPosition.z);
}
//scale.gameObject.transform.localPosition = new Vector3(scale.gameObject.transform.localPosition.x, Y, scale.gameObject.transform.localPosition.z);//проверка типа
if (reverse)
{
k-=0.5f;
}
else
{
k+=0.5f;
}
Rever();
yield return new WaitForSeconds(waitTime);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ec232e97710198048af530ebc0ed7609
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,118 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class Variometer : MonoBehaviour//frame2 0115
{
public GameObject arrow;
[HideInInspector]
public string textValue_ = "";
private string defaultValue_ = "0";
//private Text text_;
private TextMeshPro text_;
private int k=0; //текущее значение счетчика в float
private int max = 30;
private int min = -30;
bool reverse = false; //направление
float waitTime = 0.2f;//время для корутины
bool point = false;//нажатие на счетчик
private Coroutine coroutine;
void Start()
{
//text_ = this.gameObject.GetComponent<Text>();
//text_.text = (textValue_ == "") ? defaultValue_ : textValue_;
text_ = this.GetComponent<TextMeshPro>();
var txt = (textValue_ == "") ? defaultValue_ : textValue_;
text_.SetText(txt);
}
private void VarText()
{
if (k >= 0)
{
if (arrow.gameObject.GetComponent<ButtonCheckable3>() != null)
{
arrow.gameObject.GetComponent<ButtonCheckable3>().EnableSprite(0);
}
}
else
{
if (arrow.gameObject.GetComponent<ButtonCheckable3>() != null)
{
arrow.gameObject.GetComponent<ButtonCheckable3>().EnableSprite(1);
}
}
textValue_ = k.ToString();
if (k < 0)
{
//text_.text = textValue_.Substring(1, textValue_.Length - 1);
var txt = textValue_.Substring(1, textValue_.Length - 1);
text_.SetText(txt);
}
else
{
//text_.text = textValue_;
text_.SetText(textValue_);
}
}
private void OnMouseDown()//нажатие на счетчик
{
point = !point;
if (point)
{
Rever();
if (reverse)
{
k--;
coroutine = StartCoroutine(VarNumber());
}
else
{
k++;
coroutine = StartCoroutine(VarNumber());
}
}
else
{
if (coroutine != null) StopCoroutine(coroutine);
}
}
private void Rever()
{
if (k <= min)
{
reverse = false;
}
else if (k >= max)
{
reverse = true;
}
}
IEnumerator VarNumber()
{
while (point)
{
VarText();
if (reverse)
{
k--;
}
else
{
k++;
}
Rever();
yield return new WaitForSeconds(waitTime);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: faea90728be5e6b48ad7baff2eb5ff1f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 23d9ff4a5f222bc47b56f83d9e756d3e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class AngleToNumber : MonoBehaviour
{
public Handler handle;//крутилка
public TextMeshPro number;//счетчик
private void Start()
{
handle = this.gameObject.GetComponent<Handler>();
}
private void LateUpdate()
{
if (handle.drag)
{
var k = handle.gameObject.transform.localEulerAngles.z;
int count = 9-(int)(handle.gameObject.transform.localEulerAngles.z / 36);
number.text = count.ToString();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bf0f870d3d9c0584e974de7e474657bd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,21 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AngleCollider : MonoBehaviour
{
public int countA;
public GameObject parObject;
Manager man;
public void OnMouseDown()
{
man = GameObject.Find("Manager").GetComponent<Manager>();
if (man.mode == "scedit" || man.mode == "play")
return;
parObject.gameObject.GetComponent<RotateAngle>().OnCollider(countA);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0dc76b077141a1f4290434561f864fd4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,165 @@
<<<<<<< HEAD
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ButtonCheckable : MonoBehaviour
{
Dictionary<string, GameObject> buttonStatesList = new Dictionary<string, GameObject>();
// int posCount;
// int currentPos;
GameObject goUp;
GameObject goDown;
public bool isChecked = false;
public bool isStarted = false;
Image goUp_Img=null, goDown_Img=null;
SpriteRenderer goUp_SR = null, goDown_SR = null;
Manager man;
void Start()
{
man = GameObject.Find("Manager").GetComponent<Manager>();
// Debug.Log(go.name);
Transform[] buttonStates = this.GetComponentsInChildren<Transform>();
// Debug.Log(btnList.Length);
// goUp = new GameObject();
// goDown = new GameObject();
for (int i = 0; i < buttonStates.Length; i++)
{
if (i == 0) continue;
if (string.Compare(buttonStates[i].name.Substring(buttonStates[i].name.Length - 2), "up") == 0) // this.name.Length - 3
goUp = buttonStates[i].gameObject;
if (string.Compare(buttonStates[i].name.Substring(buttonStates[i].name.Length - 4), "down") == 0) // this.name.Length - 3
goDown = buttonStates[i].gameObject;
}
goUp_Img = goUp.GetComponent<Image>();
goUp_SR = goUp.GetComponent<SpriteRenderer>();
goDown_Img = goDown.GetComponent<Image>();
goDown_SR = goDown.GetComponent<SpriteRenderer>();
if (goUp_Img != null) goUp_Img.enabled = !isChecked;
if (goUp_SR != null) goUp_SR.enabled = !isChecked;
if (goDown_Img != null) goDown_Img.enabled = isChecked;
if (goDown_SR != null) goDown_SR.enabled = isChecked;
isStarted = true;
}
void OnMouseDown()
{
if (man.mode == "scedit" || man.mode == "play")
return;
OnCheck();
}
public void OnCheck()
{
if (goUp == null || goDown == null) Start();
if (goUp == null || goDown == null) return;
try
{
isChecked = !isChecked;
if (goUp_Img != null) goUp_Img.enabled = !isChecked;
if (goUp_SR != null) goUp_SR.enabled = !isChecked;
if (goDown_Img != null) goDown_Img.enabled = isChecked;
if (goDown_SR != null) goDown_SR.enabled = isChecked;
}
catch (Exception e)
{
Debug.LogError(e.Message);
}
}
public void SetState(int st)
{
if (st == 0) isChecked = true; else isChecked = false;
OnCheck();
}
}
=======
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ButtonCheckable : MonoBehaviour
{
Dictionary<string, GameObject> buttonStatesList = new Dictionary<string, GameObject>();
// int posCount;
// int currentPos;
GameObject goUp;
GameObject goDown;
public bool isChecked = false;
public bool isStarted = false;
Image goUp_Img=null, goDown_Img=null;
SpriteRenderer goUp_SR = null, goDown_SR = null;
Manager man;
void Start()
{
man = GameObject.Find("Manager").GetComponent<Manager>();
// Debug.Log(go.name);
Transform[] buttonStates = this.GetComponentsInChildren<Transform>();
// Debug.Log(btnList.Length);
// goUp = new GameObject();
// goDown = new GameObject();
for (int i = 0; i < buttonStates.Length; i++)
{
if (i == 0) continue;
if (string.Compare(buttonStates[i].name.Substring(buttonStates[i].name.Length - 2), "up") == 0) // this.name.Length - 3
goUp = buttonStates[i].gameObject;
if (string.Compare(buttonStates[i].name.Substring(buttonStates[i].name.Length - 4), "down") == 0) // this.name.Length - 3
goDown = buttonStates[i].gameObject;
}
goUp_Img = goUp.GetComponent<Image>();
goUp_SR = goUp.GetComponent<SpriteRenderer>();
goDown_Img = goDown.GetComponent<Image>();
goDown_SR = goDown.GetComponent<SpriteRenderer>();
if (goUp_Img != null) goUp_Img.enabled = !isChecked;
if (goUp_SR != null) goUp_SR.enabled = !isChecked;
if (goDown_Img != null) goDown_Img.enabled = isChecked;
if (goDown_SR != null) goDown_SR.enabled = isChecked;
isStarted = true;
}
void OnMouseDown()
{
if (man.mode == "scedit" || man.mode == "play")
return;
OnCheck();
}
public void OnCheck()
{
if (goUp == null || goDown == null) Start();
if (goUp == null || goDown == null) return;
try
{
isChecked = !isChecked;
if (goUp_Img != null) goUp_Img.enabled = !isChecked;
if (goUp_SR != null) goUp_SR.enabled = !isChecked;
if (goDown_Img != null) goDown_Img.enabled = isChecked;
if (goDown_SR != null) goDown_SR.enabled = isChecked;
}
catch (Exception e)
{
Debug.LogError(e.Message);
}
}
public void SetState(int st)
{
if (st == 0) isChecked = true; else isChecked = false;
OnCheck();
}
}
>>>>>>> 3b1b9479a46e90d056b92897ea9f8422b25fc052

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dbc28422848bda5459d5b1d421f29df7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,59 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
/* Работает на любое количество спрайтов, переключает по очереди */
public class ButtonCheckable3 : MonoBehaviour
{
//Dictionary<string, GameObject> buttonStatesList3 = new Dictionary<string, GameObject>();
List<GameObject> buttonStatesList3 = new List<GameObject>();
int click = 0;
Manager man;
void Start()
{
man = GameObject.Find("Manager").GetComponent<Manager>();
Transform[] buttonStates = this.GetComponentsInChildren<Transform>();
for (int i = 0; i < buttonStates.Length; i++)
if (buttonStates[i].name != this.name)
{
buttonStates[i].gameObject.SetActive(false);
buttonStatesList3.Add(buttonStates[i].gameObject);
}
//EnableSprite(click);
UnityObject curUO = man.objects.FindHandler(this.gameObject.name);
curUO.SetObjectState(click);
//debug:
/*if (this.name == "mfi3_Lamp5_1")
Debug.Log("Lamp5_1 states = " + (buttonStates.Length + 1) + " active = " + this.gameObject.active + " activeInHierarchy = " + this.gameObject.activeInHierarchy);
for (int i = 0; i < buttonStates.Length; i++)
if (buttonStates[i].name != this.name)
{
if (this.name == "mfi3_Lamp5_1")
Debug.Log(buttonStates[i].name + " active = " + buttonStates[i].gameObject.active + " activeInHierarchy = " + buttonStates[i].gameObject.activeInHierarchy);
} */
}
void OnMouseDown()
{
if (man.mode == "scedit" || man.mode == "play")
return;
click++;
if (click > buttonStatesList3.Count - 1) click = 0;
//Debug.Log("количество кликов + " + click);
//EnableSprite(click);
UnityObject curUO = man.objects.FindHandler(this.gameObject.name);
curUO.SetObjectState(click);
}
public void EnableSprite(int n)
{
if (n >= buttonStatesList3.Count)
return;
buttonStatesList3.ForEach(_buttonStatesList3 => _buttonStatesList3.gameObject.SetActive(false));
buttonStatesList3[n].gameObject.SetActive(true);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1a8fcc88003622547ac936dcfda3b30d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,307 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class Connection : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
{
public GameObject[] connects;
[ContextMenuItem("Button", "OnButton")]
[ContextMenuItem("ButtonCheckable", "OnButtonCheckable")]
[ContextMenuItem("ButtonCheckable3", "OnButtonCheckable3")]
[ContextMenuItem("Switch", "OnSwitch")]
[ContextMenuItem("Handler", "OnHandler")]
[ContextMenuItem("HideCollider", "OnHideCollider")]
[ContextMenuItem("ScaleToScaleX", "OnScaleToScaleX")]
public string typeThis;// = null;//"Button". "ButtonCheckable", "ButtonCheckable3", "Switch" (êðûøêà âûêëþ÷àåò òóìáëåðû), "Handler", "HideCollider", "ScaleToScaleX"(115), CoverStateToCoverState 0701 0702,
void OnButton() => typeThis = "Button";
void OnButtonCheckable() => typeThis = "ButtonCheckable";
void OnButtonCheckable3() => typeThis = "ButtonCheckable3";
void OnSwitch() => typeThis = "Switch";
void OnHandler() => typeThis = "Handler";
void OnHideCollider() => typeThis = "HideCollider";
void OnScaleToScaleX() => typeThis = "ScaleToScaleX";
[SerializeField] private int index=0;
private float d;//
private DragCollider _drag;
private Vector2 xy;
private bool _delta = false;
private PointerEventData data;
Manager man;
private void Start()
{
man = GameObject.Find("Manager").GetComponent<Manager>();
xy = new Vector2(this.gameObject.transform.localPosition.x, this.gameObject.transform.localPosition.y);
for (int i = 0; i < connects.Length; i++)
{
switch (typeThis)
{
case "Handler":
connects[i].gameObject.GetComponent<PolygonCollider2D>().enabled = !connects[i].gameObject.GetComponent<PolygonCollider2D>().enabled;
break;
case "ScaleToScaleX":
_drag = connects[i].gameObject.transform.GetComponent<DragCollider>();
ref readonly string typeDrag = ref _drag.typeDrag;
if (typeDrag == "x")
{
d = connects[i].gameObject.transform.localPosition.x - xy.x;
}
else
{
d = connects[i].gameObject.transform.localPosition.y - xy.y;
}
break;
default:
break;
}
}
}
private void OnMouseEnter()
{
for (int i = 0; i < connects.Length; i++)
{
switch (typeThis)
{
case "HideCollider":
if (connects[i].gameObject.GetComponent<Collider2D>() != null)
{
connects[i].gameObject.GetComponent<Collider2D>().enabled = false;
}
break;
default:
break;
}
}
}
private void OnMouseExit()
{
for (int i = 0; i < connects.Length; i++)
{
switch (typeThis)
{
case "HideCollider":
if (connects[i].gameObject.GetComponent<Collider2D>() != null)
{
connects[i].gameObject.GetComponent<Collider2D>().enabled = true;
}
break;
default:
break;
}
}
}
void OnMouseDown()
{
if(man == null) man = GameObject.Find("Manager").GetComponent<Manager>();
if (man.mode == "scedit" || man.mode == "play")
return;
xy = new Vector2(this.gameObject.transform.localPosition.x, this.gameObject.transform.localPosition.y);
for (int i = 0; i < connects.Length; i++)
{
switch (typeThis)
{
case "Button":
connects[i].gameObject.GetComponent<myButton>().OnDown();
break;
case "ButtonCheckable":
connects[i].gameObject.GetComponent<ButtonCheckable>().OnCheck();
break;
case "ButtonCheckable3":
connects[i].gameObject.GetComponent<ButtonCheckable3>().EnableSprite(index);
break;
case "Switch":
connects[i].gameObject.GetComponent<Switch>().setState(0);
Transform[] btnList = connects[i].gameObject.GetComponentsInChildren<Transform>();
string currentSw3Dname = connects[i].name.Substring(0, connects[i].name.Length) + "_3D";
GameObject currentSw3D = GameObject.Find(currentSw3Dname);
//Debug.Log($"currentSw3Dname {currentSw3Dname}");
Switch3DRotate sw3Drotate = currentSw3D.GetComponent<Switch3DRotate>();
sw3Drotate.RotateVertikalSwitch(2);
break;
case "Handler":
connects[i].gameObject.GetComponent<PolygonCollider2D>().enabled=!connects[i].gameObject.GetComponent<PolygonCollider2D>().enabled;
break;
case "CoverStateToCoverState":
//Debug.Log($"connects[i].gameObject.GetComponent<CoverState>() {connects[i].gameObject.GetComponent<CoverState>() != null}");
connects[i].gameObject.GetComponent<CoverState>().switchOn();
break;
case "ScaleToScaleX":
ref readonly string typeDrag = ref _drag.typeDrag;
ref readonly bool _delta2 = ref _drag._delta;
_delta = _delta2;
if (typeDrag == "x" && !_delta)
{
d = connects[i].gameObject.transform.localPosition.x - xy.x;
}
else if (typeDrag == "y" && !_delta)
{
d = connects[i].gameObject.transform.localPosition.y - xy.y;
//Debug.Log($"d = {d}");
}
break;
default:
break;
}
}
}
void OnMouseUp()
{
if (man.mode == "scedit" || man.mode == "play")
return;
for (int i = 0; i < connects.Length; i++)
{
switch (typeThis)
{
case "Button":
connects[i].gameObject.GetComponent<myButton>().OnUp();
break;
default:
break;
}
}
}
public void OnBeginDrag(PointerEventData eventData)
{
if (man.mode == "scedit" || man.mode == "play")
return;
xy = new Vector2(this.gameObject.transform.localPosition.x, this.gameObject.transform.localPosition.y);
for (int i = 0; i < connects.Length; i++)
{
switch (typeThis)
{
case "ScaleToScaleX":
ref readonly string typeDrag = ref _drag.typeDrag;
ref readonly bool _delta2 = ref _drag._delta;
_delta = _delta2;
if (typeDrag == "x" && !_delta)
{
d = connects[i].gameObject.transform.localPosition.x - xy.x;
}
else if (typeDrag == "y" && !_delta)
{
d = connects[i].gameObject.transform.localPosition.y - xy.y;
}
break;
default:
break;
}
}
}
public void Update()
{
if (man.mode == "scedit" || man.mode == "play")
return;
for (int i = 0; i < connects.Length; i++)
{
switch (typeThis)
{
case "ScaleToScaleX":
if (connects[i].gameObject.transform.GetComponent<IndexH>() != null)
{
GameObject frame = connects[i].gameObject.transform.GetComponent<IndexH>().frame;
if (frame.GetComponent<ScaleToText>() != null || frame.GetComponent<ScaleToText4>() != null)
{
bool point = (frame.GetComponent<ScaleToText>() != null) ? frame.GetComponent<ScaleToText>().point : frame.GetComponent<ScaleToText4>().point;
bool isDrag = this.GetComponent<DragCollider>().isDrag;
if (point || isDrag)
{
OnDrag(data);
//Debug.Log($"point in connection = {point}");
}
else
{
OnBeginDrag(data);
}
}
}
break;
default:
break;
}
}
}
public void OnDrag(PointerEventData eventData)
{
if (man.mode == "scedit" || man.mode == "play")
return;
for (int i = 0; i < connects.Length; i++)
{
switch (typeThis)
{
case "ScaleToScaleX":
ref readonly bool clamp = ref _drag.clamp;
ref readonly string typeDrag = ref _drag.typeDrag;
ref readonly float dragMin = ref _drag.dragMin;
ref readonly float dragMax = ref _drag.dragMax;
/*GameObject frame = connects[i].gameObject.transform.GetComponent<IndexH>().frame;
bool point = (frame.GetComponent<ScaleToText4>()!=null) ? frame.GetComponent<ScaleToText4>().point:false;*/
//ref readonly Vector2 dd = ref _drag.dd;
ref bool _delta2 = ref _drag._delta;
//Debug.Log($"OnDrag in connection = true");
if (clamp && typeDrag == "x")
{
//Debug.Log($"clamp && typeDrag == x");
if (this.gameObject.transform.localPosition.x + d >= dragMin && this.gameObject.transform.localPosition.x + d <= dragMax)
{
/*if(point) d = -2532;
Debug.Log($" point = {point}");
Debug.Log($" d = {d}");*/
_delta = false;
connects[i].gameObject.transform.localPosition = new Vector3(this.gameObject.transform.localPosition.x + d, connects[i].gameObject.transform.localPosition.y, connects[i].gameObject.transform.localPosition.z);
//Debug.Log($" connects[i].gameObject.transform.localPosition = {connects[i].gameObject.transform.localPosition}");
}
else
{
_delta = true;
}
}
else if (clamp && typeDrag == "y")
{
if (this.gameObject.transform.localPosition.y + d >= dragMin && this.gameObject.transform.localPosition.y + d <= dragMax)
{
_delta = false;
connects[i].gameObject.transform.localPosition = new Vector3(connects[i].gameObject.transform.localPosition.x, this.gameObject.transform.localPosition.y + d, connects[i].gameObject.transform.localPosition.z);
}
else
{
_delta = true;
}
}
_delta2 = _delta;
xy = new Vector2(this.gameObject.transform.localPosition.x, this.gameObject.transform.localPosition.y);
//connects[i].gameObject.transform.localPosition = new Vector3(this.gameObject.transform.localPosition.x + d, connects[i].gameObject.transform.localPosition.y, connects[i].gameObject.transform.localPosition.z);
break;
default:
break;
}
}
}
public void OnEndDrag(PointerEventData eventData)
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d5728f4aaf90d4346a89f56279343cc8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,39 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Cover : MonoBehaviour
{
List<string> coverStatesListNames = new List<string>();
//Dictionary<string, GameObject> switcheStatesList = new Dictionary<string, GameObject>();
public Dictionary<string, CoverState> coverStatesList = new Dictionary<string, CoverState>();
// int posCount;
// int currentPos;
void Start()
{
// Debug.Log(go.name);
Transform[] coverStates = this.GetComponentsInChildren<Transform>();
// Debug.Log(btnList.Length);
for (int i = 0; i < coverStates.Length; i++)
{
if (i == 0) continue;
// Debug.Log(btnList[i].gameObject.name);
coverStates[i].gameObject.AddComponent<CoverState>();
coverStatesListNames.Add(coverStates[i].gameObject.name);
coverStatesList.Add(coverStates[i].gameObject.name, coverStates[i].gameObject.GetComponent<CoverState>());
}
//coverStatesListNames.Sort();
//setState(0);
setState(0);
}
public void setState(int state)
{
coverStatesList[coverStatesListNames[state]].switchOn();
}
public void setState(string swName)
{
coverStatesList[swName].switchOn();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ce1306d71d9016241afe6729b45d63e7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,44 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Cover2 : MonoBehaviour
{
List<GameObject> buttonStatesList3 = new List<GameObject>();
Manager man;
int click = 0;
void Start()
{
man = GameObject.Find("Manager").GetComponent<Manager>();
Transform[] buttonStates = this.GetComponentsInChildren<Transform>();
for (int i = 0; i < buttonStates.Length; i++)
{
if ((!buttonStates[i].name.Equals(this.name)) && buttonStates[i].name.StartsWith(this.name))
{
buttonStates[i].gameObject.SetActive(false);
buttonStatesList3.Add(buttonStates[i].gameObject);
}
}
EnableSprite(0);
}
void OnMouseUp()
{
if (man.mode == "scedit" || man.mode == "play")
return;
click++;
if (click > buttonStatesList3.Count - 1) click = 0;
//Debug.Log("êîëè÷åñòâî êëèêîâ + " + click);
EnableSprite(click);
}
public void EnableSprite(int n)
{
buttonStatesList3.ForEach(_buttonStatesList3 => _buttonStatesList3.gameObject.SetActive(false));
buttonStatesList3[n].gameObject.SetActive(true);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b8387cd22c69b81429e949f9a21922cf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,138 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CoverState : MonoBehaviour
{
public Cover3DVrotate cw3DVrotate;
public Cover3DHrotate cw3DHrotate;
Manager man;
public void Start()
{
man = GameObject.Find("Manager").GetComponent<Manager>();
}
void OnMouseDown()
{
if (man.mode == "scedit" || man.mode == "play")
return;
switchOn();
//Switch3DVrotate sw3DVrotate = this.GetComponent<Switch3DVrotate>();
/* Transform[] btnList = this.transform.parent.gameObject.GetComponentsInChildren<Transform>();
for (int i = 0; i < btnList.Length; i++)
{
if (i == 0) continue;
if (btnList[i].gameObject.GetComponent<SpriteRenderer>() != null)
{
btnList[i].gameObject.GetComponent<SpriteRenderer>().enabled = true;
btnList[i].gameObject.GetComponent<BoxCollider2D>().enabled = true;
}
if (btnList[i].gameObject.GetComponent<Image>() != null)
{
btnList[i].gameObject.GetComponent<Image>().enabled = true;
btnList[i].gameObject.GetComponent<BoxCollider2D>().enabled = true;
}
}
if (this.gameObject.GetComponent<SpriteRenderer>() != null)
{
this.gameObject.GetComponent<SpriteRenderer>().enabled = false;
this.gameObject.GetComponent<BoxCollider2D>().enabled = false;
}
else
if (this.gameObject.GetComponent<Image>() != null)
{
this.gameObject.GetComponent<Image>().enabled = false;
this.gameObject.GetComponent<BoxCollider2D>().enabled = false;
}*/
}
public void switchOn()
{
Transform[] btnList = this.transform.parent.gameObject.GetComponentsInChildren<Transform>();
for (int i = 1; i < btnList.Length; i++)
{
//if (i == 0) continue;
if (btnList[i].gameObject.GetComponent<SpriteRenderer>() != null)
{
btnList[i].gameObject.GetComponent<SpriteRenderer>().enabled = true;
btnList[i].gameObject.GetComponent<BoxCollider2D>().enabled = true;
}
else
if (btnList[i].gameObject.GetComponent<Image>() != null)
{
btnList[i].gameObject.GetComponent<Image>().enabled = true;
btnList[i].gameObject.GetComponent<BoxCollider2D>().enabled = true;
}
}
//this.gameObject.GetComponent<Image>().enabled = true;
if (this.gameObject.GetComponent<SpriteRenderer>() != null)
{
this.gameObject.GetComponent<SpriteRenderer>().enabled = false;
this.gameObject.GetComponent<BoxCollider2D>().enabled = false;
ConnectWith3d();
ConnectWith3dh();
}
else
if (this.gameObject.GetComponent<Image>() != null)
{
this.gameObject.GetComponent<Image>().enabled = false;
this.gameObject.GetComponent<BoxCollider2D>().enabled = false;
ConnectWith3d();
ConnectWith3dh();
}
if(man == null) man = GameObject.Find("Manager").GetComponent<Manager>();
// частные случаи работы крышек, переключателей и др., не предусматриваемые механикой файла objects.xml - короче "костыли"
if (this.transform.parent.gameObject.name == "Cover1_0502" && this.gameObject.name.EndsWith("_2"))
man.objects.Find("Tumbler2_0502").SetObjectState(2);
if (this.transform.parent.gameObject.name == "Cover2_0511" && this.gameObject.name.EndsWith("_2"))
man.objects.Find("Tumbler2_0511").SetObjectState(0);
}
public void ConnectWith3d()
{
string currentSw3Dname = this.transform.parent.name.Substring(0, transform.parent.name.Length) + "_3D";
GameObject currentSw3D = GameObject.Find(currentSw3Dname);
if (currentSw3D != null)
{
Cover3DVrotate cw3DVrotate = currentSw3D.GetComponent<Cover3DVrotate>();
if (cw3DVrotate != null)
cw3DVrotate.Rotate(int.Parse(this.name.Substring(this.name.Length - 1)));
}
}
public void ConnectWith3dh()
{
string currentSw3DHname = this.transform.parent.name.Substring(0, transform.parent.name.Length) + "_3D";
//Debug.Log(currentSw3DHname);
GameObject currentSw3DH = GameObject.Find(currentSw3DHname);
if (currentSw3DH != null)
{
Cover3DHrotate cw3DHrotate = currentSw3DH.GetComponent<Cover3DHrotate>();
if (cw3DHrotate != null)
cw3DHrotate.RotateH(int.Parse(this.name.Substring(this.name.Length - 1)));
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ce461297d7952f2459443070a25ec5a2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,73 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class Drag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
{
protected Vector3 mousePosition;
protected Vector2 a; // Vector2 deltaPosition
public string typeDrag = null;
public float dragMin, dragMax;
public bool clamp=false;
[HideInInspector] public Vector2 dd;//для передачи в connection
[HideInInspector] public bool _delta = false;//для передачи в connection
private void Start()
{
dd = new Vector2(transform.localPosition.x, transform.localPosition.y);
}
public virtual void OnBeginDrag(PointerEventData data)
{
calculationBegin();
}
public virtual void OnDrag(PointerEventData data)
{
calculationDrag();
}
public void OnEndDrag(PointerEventData data)
{
dd = new Vector2(transform.localPosition.x, transform.localPosition.y);
if (typeDrag == "x" && (dd.x == dragMin || dd.x == dragMax))
{
_delta = true;
}
else if (typeDrag == "y" && (dd.y == dragMin || dd.y == dragMax))
{
_delta = true;
}
else
{
_delta = false;
}
}
public void calculationBegin()
{
a = new Vector2(Input.mousePosition.x - transform.localPosition.x, Input.mousePosition.y - transform.localPosition.y);
}
public void calculationDrag()
{
mousePosition = Input.mousePosition;
Vector2 q = new Vector2(mousePosition.x, mousePosition.y);
Vector3 b = new Vector3(q.x - a.x, q.y - a.y, transform.localPosition.z);
if (typeDrag == "x")
{
b.x = (clamp) ? Mathf.Clamp(b.x, dragMin, dragMax) : b.x;
transform.localPosition = new Vector3(b.x, transform.localPosition.y, transform.localPosition.z);
}
else if (typeDrag == "y")
{
b.y = (clamp) ? Mathf.Clamp(b.y, dragMin, dragMax) : b.y;
transform.localPosition = new Vector3(transform.localPosition.x, b.y, transform.localPosition.z);
}
else
{
transform.localPosition = b;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 65c1c1952aca7e641ab54adc14022f44
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,94 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DragCollider : MonoBehaviour
{
protected Vector3 mousePosition;
protected Vector2 a; // Vector2 deltaPosition
public string typeDrag = null;
public float dragMin, dragMax;
public bool clamp = false;
[HideInInspector] public Vector2 dd;//для передачи в connection
[HideInInspector] public bool _delta = false;//для передачи в connection
[HideInInspector] public bool isDrag = false;
Camera cam;//камера для канваса с панелями
Manager man;
private void Awake()
{
dd = new Vector2(transform.localPosition.x, transform.localPosition.y);
if (man == null) man = GameObject.Find("Manager").GetComponent<Manager>();
cam = man.cam;
}
public void OnMouseDown()
{
calculationBegin();
}
public void OnMouseDrag()
{
calculationDrag();
}
public void OnMouseUp()
{
dd = new Vector2(transform.localPosition.x, transform.localPosition.y);
if (typeDrag == "x" && (dd.x == dragMin || dd.x == dragMax))
{
_delta = true;
}
else if (typeDrag == "y" && (dd.y == dragMin || dd.y == dragMax))
{
_delta = true;
}
else
{
_delta = false;
}
isDrag = false;
}
public void calculationBegin()
{
a = new Vector2(Input.mousePosition.x - transform.localPosition.x, Input.mousePosition.y - transform.localPosition.y);
/*mousePosition = cam.ScreenToWorldPoint(Input.mousePosition);//mousePosition = Input.mousePosition;
a = new Vector2(mousePosition.x - transform.localPosition.x, mousePosition.y - transform.localPosition.y);*/
isDrag = true;
}
public void calculationDrag()
{
if (man.mode == "scedit" || man.mode == "play")
return;
/*mousePosition = cam.ScreenToWorldPoint(Input.mousePosition);*/
mousePosition = Input.mousePosition;
Vector2 q = new Vector2(mousePosition.x, mousePosition.y);
Vector3 b = new Vector3(q.x - a.x, q.y - a.y, transform.localPosition.z);
if (typeDrag == "x")
{
b.x = (clamp) ? Mathf.Clamp(b.x, dragMin, dragMax) : b.x;
transform.localPosition = new Vector3(b.x, transform.localPosition.y, transform.localPosition.z);
}
else if (typeDrag == "y")
{
b.y = (clamp) ? Mathf.Clamp(b.y, dragMin, dragMax) : b.y;
transform.localPosition = new Vector3(transform.localPosition.x, b.y, transform.localPosition.z);
}
else
{
transform.localPosition = b;
}
}
public void SetState(int b)
{
b = (clamp) ? (int)Mathf.Clamp((float)b, dragMin, dragMax) : b;
//b += (int)(dragMax - dragMin) / 2;
if (typeDrag == "x")
transform.localPosition = new Vector3(b, transform.localPosition.y, transform.localPosition.z);
else if (typeDrag == "y")
transform.localPosition = new Vector3(transform.localPosition.x, b, transform.localPosition.z);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 231cfd8c832c9de4db7d791231ceda82
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,27 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DragMask : MonoBehaviour
{
private void OnMouseEnter()
{
}
public void OnMouseDown()
{
}
public void OnMouseDrag()
{
}
public void OnMouseUp()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 65c9b7010d95cbd42879610e90285332
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5927e0332f09efe40a5e5919a5319e1b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,50 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MyBtnCheck3 : MonoBehaviour
{
List<GameObject> buttonStatesList3 = new List<GameObject>();
int click = 1;
Manager man;
void Start()
{
man = GameObject.Find("Manager").GetComponent<Manager>();
Transform[] buttonStates = this.GetComponentsInChildren<Transform>();
for (int i = 0; i < buttonStates.Length; i++)
{
if (buttonStates[i].name.Length > this.name.Length)
{
//Debug.Log(buttonStates[i] + " В массив ");
buttonStates[i].gameObject.SetActive(false);
buttonStatesList3.Add(buttonStates[i].gameObject);
}
}
EnableSprite(click);
}
void OnMouseDown()
{
if (man.mode == "scedit" || man.mode == "play")
return;
EnableSprite(0);
}
void OnMouseUp()
{
if (man.mode == "scedit" || man.mode == "play")
return;
click++;
if (click > buttonStatesList3.Count - 1) click = 1;
//Debug.Log("количество кликов + " + click);
EnableSprite(click);
}
public void EnableSprite(int n)
{
buttonStatesList3.ForEach(_buttonStatesList3 => _buttonStatesList3.gameObject.SetActive(false));
buttonStatesList3[n].gameObject.SetActive(true);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 353a6fbef5f528449b02e9bb1baea85b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,189 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Panel2D : MonoBehaviour
{
//public ScriptA m_someOtherScriptOnAnotherGameObject;
// Start is called before the first frame update
public Dictionary<string, GameObject> switchesList = new Dictionary<string, GameObject>(); // Обычные переключатели
Dictionary<string, GameObject> switchesListHold = new Dictionary<string, GameObject>(); // Переключатели которые не фиксируются
Dictionary<string, GameObject> buttonList = new Dictionary<string, GameObject>();
Dictionary<string, GameObject> buttonCheckList = new Dictionary<string, GameObject>(); // Нажимно-отжимные, с тегом buttonscheck
Dictionary<string, GameObject> buttonCheckList3 = new Dictionary<string, GameObject>(); // Переключатели и кнопки с любым количеством спрайтов,переключающиеся друг за другом
Dictionary<string, GameObject> mybtnCheckList3 = new Dictionary<string, GameObject>(); // Переключатели и кнопки с нажатием (первый объект),с любым количеством спрайтов,переключающиеся друг за другом
Dictionary<string, GameObject> coverList = new Dictionary<string, GameObject>(); // Крышки и колпачки
Dictionary<string, GameObject> handlerList = new Dictionary<string, GameObject>(); // Крутилки
Dictionary<string, GameObject> rotateAngleList = new Dictionary<string, GameObject>(); // Крутилки
Manager man;
Camera cam;//камера для канваса с панелями
string layerName;
Collider2D[] coll2d;
public bool isStarted = false;
void Start()
{
if(!isStarted)
StartCoroutine(Init());
}
public IEnumerator Init()
{
man = GameObject.Find("Manager").GetComponent<Manager>();
cam = man.cam;
layerName = LayerMask.LayerToName(gameObject.layer);
coll2d = this.gameObject.GetComponentsInChildren<Collider2D>();
UnityObject uObj = man.objects.Find(this.gameObject.name);
while (!man.objects.isLoaded)
yield return null;
// Debug.Log("Start 2D " + this.gameObject.name);
if (uObj == null)
yield break;
List<UnityObject> switches = uObj.FindChildsWithTag("toggle");
foreach (UnityObject sw in switches)
{
sw.gameObject.AddComponent<Switch>();
switchesList.Add(sw.gameObject.name, sw.gameObject);
//Debug.Log("Имена sw " + sw.name);
}
List<UnityObject> switcheshold = uObj.FindChildsWithTag("togglehold");
foreach (UnityObject swh in switcheshold)
{
//Debug.Log(swh);
swh.gameObject.AddComponent<SwitchHold>();
switchesListHold.Add(swh.gameObject.name, swh.gameObject);
}
List<UnityObject> buttons = uObj.FindChildsWithTag("buttons");
foreach (UnityObject btn in buttons)
{
btn.gameObject.AddComponent<myButton>();
buttonList.Add(btn.gameObject.name, btn.gameObject);
//Debug.Log("Имена sw " + sw.name);
}
List<UnityObject> buttonscheck = uObj.FindChildsWithTag("buttonscheck");
foreach (UnityObject _buttonscheck in buttonscheck)
{
_buttonscheck.gameObject.AddComponent<ButtonCheckable>();
buttonCheckList.Add(_buttonscheck.gameObject.name, _buttonscheck.gameObject);
if (!_buttonscheck.gameObject.activeInHierarchy && !_buttonscheck.gameObject.GetComponent<ButtonCheckable>().isStarted)
{
string nm = _buttonscheck.gameObject.transform.parent.gameObject.name;
GameObject parentGO = _buttonscheck.gameObject.transform.parent.parent.gameObject;
if (nm == "view2_0801" || nm == "view2_0802" || nm == "view3_0801" || nm == "view3_0802" ||
nm == "Handle3_0701" || nm == "Handle3_0702")
{
parentGO.SetActive(true);
while (!_buttonscheck.gameObject.GetComponent<ButtonCheckable>().isStarted)
yield return null;
parentGO.SetActive(false);
}
}
}
List<UnityObject> buttonscheck3 = uObj.FindChildsWithTag("buttonscheck3");
foreach (UnityObject _buttonscheck3 in buttonscheck3)
{
_buttonscheck3.gameObject.AddComponent<ButtonCheckable3>();
buttonCheckList3.Add(_buttonscheck3.gameObject.name, _buttonscheck3.gameObject);
}
List<UnityObject> mybtnCheck = uObj.FindChildsWithTag("myBtnCheck");
foreach (UnityObject _mybtnCheck in mybtnCheck)
{
_mybtnCheck.gameObject.AddComponent<MyBtnCheck3>();
mybtnCheckList3.Add(_mybtnCheck.gameObject.name, _mybtnCheck.gameObject);
}
List<UnityObject> cover = uObj.FindChildsWithTag("cover");
foreach (UnityObject _cover in cover)
{
_cover.gameObject.AddComponent<Cover>();
coverList.Add(_cover.gameObject.name, _cover.gameObject);
}
List<UnityObject> handler = uObj.FindChildsWithTag("handles");
foreach (UnityObject _handler in handler)
{
if(_handler.gameObject.GetComponent<Handler>() == null)
_handler.gameObject.AddComponent<Handler>();
if (!_handler.gameObject.activeInHierarchy && !_handler.gameObject.GetComponent<Handler>().isStarted)
{
string nm = _handler.gameObject.name;
GameObject parentGO = _handler.gameObject.transform.parent.gameObject;
if (nm == "view2_0801" || nm == "view2_0802" || nm == "view3_0801" || nm == "view3_0802" ||
nm == "Handle3_0701" || nm == "Handle3_0702")
{
parentGO.SetActive(true);
parentGO.SetActive(false);
}
}
while (!_handler.gameObject.GetComponent<Handler>().isStarted)
yield return null;
//if (_handler.gameObject.name == "Handle3_0701" || _handler.gameObject.name == "Handle3_0702")
// Debug.Log("Init Panel2D: handler " + _handler.gameObject.name + " is started " + _handler.gameObject.GetComponent<Handler>().isStarted);
handlerList.Add(_handler.gameObject.name, _handler.gameObject);
}
List<UnityObject> rotateangle = uObj.FindChildsWithTag("rotateangle");
foreach (UnityObject _rotateangle in rotateangle)
{
_rotateangle.gameObject.AddComponent<RotateAngle>();
rotateAngleList.Add(_rotateangle.gameObject.name, _rotateangle.gameObject);
}
// switchesList["Toggle1_0213"].GetComponent<Switch>().setState(0);
//Debug.Log("End Start 2D " + this.gameObject.name);
isStarted = true;
/*for (int i = 0; i < man.objects.obj.Count; i++)
{
UnityObject uo = man.objects.obj[i];
if (uo == null) continue;
List<UnityObject> objs = uo.FindChildsWithTag("Untagged");
foreach (UnityObject _handler in objs)
if (_handler.gameObject.GetComponent<Handler>() != null)
Debug.Log("Untagged handles " + _handler.gameObject.name);
}*/
}
private void EnableCollider( bool isEnable)
{
for (int i = 0; i < coll2d.Length; i++)
{
coll2d[i].enabled = isEnable;
}
}
public void setEnabled()
{
cam.cullingMask |= 1 << LayerMask.NameToLayer(layerName);
this.gameObject.SetActive(true);
if (layerName.StartsWith("MFI")) EnableCollider(true);
}
public void setDisabled()
{
cam.cullingMask = 0;
if (!layerName.StartsWith("MFI"))
{
this.gameObject.SetActive(false);
}
else
{
EnableCollider(false);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9c209ec1c3824ab49808dd1be0fa0afd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,95 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using TMPro;
public class RotateAngle : MonoBehaviour
{
public float defaultAngle = 0; // угол устанавливаемый по дефолту. угол 0 по часам
private List<GameObject> angles;
private List<float> angleArray;
float[] NewArrayAngle;
public int count = -1, countAngle = 0;
bool reverse = true;
Manager man;
void Start()
{
man = GameObject.Find("Manager").GetComponent<Manager>();
//transform.localRotation = Quaternion.Euler(0f, 0f, -defaultAngle);
string n = gameObject.name;
angles = new List<GameObject>();
angleArray = new List<float>();
foreach (CircleCollider2D gr in this.transform.parent.GetComponentsInChildren<CircleCollider2D>())
{
string s = gr.name;
if ((!s.Equals(n)) && s.StartsWith(n))
{
count++;
angles.Add(gr.gameObject);
var at = Mathf.Atan2(gr.gameObject.transform.position.x - transform.position.x, gr.gameObject.transform.position.y - transform.position.y) * Mathf.Rad2Deg;
angleArray.Add(at);
gr.gameObject.AddComponent<AngleCollider>().countA = count;
gr.gameObject.GetComponent<AngleCollider>().parObject = this.gameObject;
}
}
NewArrayAngle = angleArray.ToArray();
OnCollider(0);
}
public void OnCollider(int c)
{
if (!tryNewAngle(c)) return;
transform.localRotation = Quaternion.Euler(0f, 0f, -NewArrayAngle[c]);
countAngle=c;
}
public void OnMouseDown()
{
if (man.mode == "scedit" || man.mode == "play")
return;
bool newReverse = reverse;
int newcountAngle = countAngle;
if (countAngle == count)
{
newReverse = true;
}else if(countAngle == 0)
{
newReverse = false;
}
//reverse = (countAngle == count|| countAngle == 0) ? !reverse:reverse;
newcountAngle = (!newReverse) ? countAngle+1 : countAngle - 1;
if (!tryNewAngle(newcountAngle))
{
newReverse = reverse;
return;
}
countAngle = newcountAngle; reverse = newReverse;
OnCollider(countAngle);
}
bool tryNewAngle(int c)
{
// частные случаи работы крышек, переключателей и др., не предусматриваемые механикой файла objects.xml - короче "костыли"
if (this.gameObject.name == "Handle2_0511") // Panel0511
{
Handler H1 = man.objects.Find("Handle1_0511").gameObject.GetComponent<Handler>();
if (c == 1 && H1.currentAngle <= 11 && H1.currentAngle > -18)
return false;
if (c == 2 && H1.currentAngle <= 11 && H1.currentAngle > -47)
return false;
switch(c) {
case 0: H1.endDragMin = 11; break;
case 1: H1.endDragMin = -18; break;
case 2: H1.endDragMin = -47; break;
}
}
return true;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 73e9252e05600f748a7bfcdc929475a0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,97 @@
<<<<<<< HEAD
using System.Collections.Generic;
using UnityEngine;
public class Switch : MonoBehaviour
{
List<string> switcheStatesListNames = new List<string>();
//Dictionary<string, GameObject> switcheStatesList = new Dictionary<string, GameObject>();
public Dictionary<string, SwitchState> switcheStatesList = new Dictionary<string, SwitchState>();
bool isStarted = false;
// int posCount;
// int currentPos;
void Start()
{
if (isStarted) return;
// Debug.Log(go.name);
Transform[] switchStates = this.GetComponentsInChildren<Transform>();
// Debug.Log(btnList.Length);
for (int i = 0; i < switchStates.Length; i++)
{
if (i == 0) continue;
// Debug.Log(btnList[i].gameObject.name);
switchStates[i].gameObject.AddComponent<SwitchState>();
switcheStatesListNames.Add(switchStates[i].gameObject.name);
switcheStatesList.Add(switchStates[i].gameObject.name, switchStates[i].gameObject.GetComponent<SwitchState>());
}
switcheStatesListNames.Sort();
if(switcheStatesListNames.Count>0)
switcheStatesList[switcheStatesListNames[0]].switchOn();
isStarted = true;
//setState(1);
}
public void setState(int state)
{
if (!isStarted) Start();
if (state >= 0 && state < switcheStatesListNames.Count)
switcheStatesList[switcheStatesListNames[state]].switchOn();
else
Debug.LogError("Ошибка установки состояния " + state + " объекта " + this.gameObject.name);
}
public void setState(string swName)
{
if (!isStarted) Start();
switcheStatesList[swName].switchOn();
}
}
=======
using System.Collections.Generic;
using UnityEngine;
public class Switch : MonoBehaviour
{
List<string> switcheStatesListNames = new List<string>();
//Dictionary<string, GameObject> switcheStatesList = new Dictionary<string, GameObject>();
public Dictionary<string, SwitchState> switcheStatesList = new Dictionary<string, SwitchState>();
bool isStarted = false;
// int posCount;
// int currentPos;
void Start()
{
if (isStarted) return;
// Debug.Log(go.name);
Transform[] switchStates = this.GetComponentsInChildren<Transform>();
// Debug.Log(btnList.Length);
for (int i = 0; i < switchStates.Length; i++)
{
if (i == 0) continue;
// Debug.Log(btnList[i].gameObject.name);
switchStates[i].gameObject.AddComponent<SwitchState>();
switcheStatesListNames.Add(switchStates[i].gameObject.name);
switcheStatesList.Add(switchStates[i].gameObject.name, switchStates[i].gameObject.GetComponent<SwitchState>());
}
switcheStatesListNames.Sort();
if(switcheStatesListNames.Count>0)
switcheStatesList[switcheStatesListNames[0]].switchOn();
isStarted = true;
//setState(1);
}
public void setState(int state)
{
if (!isStarted) Start();
if (state >= 0 && state < switcheStatesListNames.Count)
switcheStatesList[switcheStatesListNames[state]].switchOn();
else
Debug.LogError("Ошибка установки состояния " + state + " объекта " + this.gameObject.name);
}
public void setState(string swName)
{
if (!isStarted) Start();
switcheStatesList[swName].switchOn();
}
}
>>>>>>> 3b1b9479a46e90d056b92897ea9f8422b25fc052

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1ea15b77f0adfa74fbcd95b872bbb96f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,63 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class SwitchHold : MonoBehaviour
{
List<string> switcheHoldStatesListNames = new List<string>();
//Dictionary<string, GameObject> switcheStatesList = new Dictionary<string, GameObject>();
public Dictionary<string, SwitchHoldState> switcheHoldStatesList = new Dictionary<string, SwitchHoldState>();
// int posCount;
// int currentPos;
void Start()
{
// Debug.Log(go.name);
Transform[] switchStates = this.GetComponentsInChildren<Transform>();
// Debug.Log(btnList.Length);
for (int i = 0; i < switchStates.Length; i++)
{
if (i == 0) continue;
//Debug.Log(switchStates[i].gameObject.name + " switchStates");
switchStates[i].gameObject.AddComponent<SwitchHoldState>();
switcheHoldStatesListNames.Add(switchStates[i].gameObject.name);
switcheHoldStatesList.Add(switchStates[i].gameObject.name, switchStates[i].gameObject.GetComponent<SwitchHoldState>());
}
switcheHoldStatesListNames.Sort();
//Debug.Log(switcheHoldStatesListNames + " switchStates List");
setState(2);
}
public void setState(int state)
{
switcheHoldStatesList[switcheHoldStatesListNames[state]].switchOn();
}
public void setState(string swName)
{
switcheHoldStatesList[swName].switchOn();
}
/* void OnMouseDown()
{
Transform[] btnList = this.transform.parent.gameObject.GetComponentsInChildren<Transform>();
for (int i = 0; i < btnList.Length; i++)
{
if (i == 0) continue;
btnList[i].gameObject.GetComponent<SpriteRenderer>().enabled = false;
Debug.Log("btnList[i] + " + btnList[i]);
}
// Debug.Log(" + " + click);
click++;
}*/
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9c4311345fc0f6e4da54c0c6a98e5413
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,86 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SwitchHoldState : MonoBehaviour
{
Manager man;
// public Switch3DRotate sw3Drotate;
public Switch3DHRotate sw3DHrotate;
void Start()
{
Transform[] btnList = this.transform.parent.gameObject.GetComponentsInChildren<Transform>();
for (int i = 1; i < btnList.Length; i++)
{
if (i == 1) continue;
btnList[i].gameObject.GetComponent<SpriteRenderer>().enabled = false;
}
man = GameObject.Find("Manager").GetComponent<Manager>();
btnList[3].gameObject.GetComponent<SpriteRenderer>().enabled = true;
}
void OnMouseDown()
{
if (man.mode == "scedit" || man.mode == "play")
return;
Transform[] btnList = this.transform.parent.gameObject.GetComponentsInChildren<Transform>();
for (int i = 1; i < btnList.Length; i++)
{
//if (i == 1) continue;
btnList[i].gameObject.GetComponent<SpriteRenderer>().enabled = false;
}
this.gameObject.GetComponent<SpriteRenderer>().enabled = true;
// btnList[1].gameObject.GetComponent<SpriteRenderer>().enabled = false;
ConnectWith3DSwitchHorizontal();
}
void OnMouseUp()
{
if (man.mode == "scedit" || man.mode == "play")
return;
Transform[] btnList = this.transform.parent.gameObject.GetComponentsInChildren<Transform>();
for (int i = 1; i < btnList.Length; i++)
{
//if (i == 1) continue;
btnList[i].gameObject.GetComponent<SpriteRenderer>().enabled = false;
}
btnList[3].gameObject.GetComponent<SpriteRenderer>().enabled = true;
// Временный костыль возврата переключателя после отжатия, ситчаем что у всех таких выключателей возврат в середину
string currentSw3DHname = this.name.Substring(0, this.name.Length - 1) + "3D";
GameObject currentSw3DH = GameObject.Find(currentSw3DHname);
Switch3DHRotate sw3DHrotate = currentSw3DH.GetComponent<Switch3DHRotate>();
if (sw3DHrotate != null)
//sw3DHrotate.RotateHorizontalSwitch(btnList.Length - 1, int.Parse(this.name.Substring(this.name.Length - 1)));
sw3DHrotate.RotateHorizontalSwitch(2);
}
public void switchOn()
{
Transform[] btnList = this.transform.parent.gameObject.GetComponentsInChildren<Transform>();
for (int i = 1; i < btnList.Length; i++)
btnList[i].gameObject.GetComponent<SpriteRenderer>().enabled = false;
this.gameObject.GetComponent<SpriteRenderer>().enabled = true;
}
public void ConnectWith3DSwitchHorizontal()
{
Transform[] btnList = this.transform.parent.gameObject.GetComponentsInChildren<Transform>();
string currentSw3DHname = this.name.Substring(0, this.name.Length - 1) + "3D";
GameObject currentSw3DH = GameObject.Find(currentSw3DHname);
Switch3DHRotate sw3DHrotate = currentSw3DH.GetComponent<Switch3DHRotate>();
if (sw3DHrotate != null)
//sw3DHrotate.RotateHorizontalSwitch(btnList.Length - 1, int.Parse(this.name.Substring(this.name.Length - 1)));
sw3DHrotate.RotateHorizontalSwitch(int.Parse(this.name.Substring(this.name.Length - 1)) - 1);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: da9395e1f430aa141a05cff7871070d6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,89 @@
using UnityEngine;
using UnityEngine.UI;
public class SwitchState : MonoBehaviour
{
//public Switch3DRotate sw3Drotate;
public Switch3DHRotate sw3DHrotate;
Manager man;
void Start()
{
//sw3Drotate = FindObjectOfType<Switch3DRotate>();
// Debug.Log(sw3Drotate + " объекты" );
man = GameObject.Find("Manager").GetComponent<Manager>();
}
void OnMouseDown()
{
if (man.mode == "scedit" || man.mode == "play")
return;
Transform[] btnList = this.transform.parent.gameObject.GetComponentsInChildren<Transform>();
for (int i = 0; i < btnList.Length; i++)
{
if (i == 0) continue;
if(btnList[i].gameObject.GetComponent<Image>()!=null)
btnList[i].gameObject.GetComponent<Image>().enabled = false;
else
btnList[i].gameObject.GetComponent<SpriteRenderer>().enabled = false;
}
//this.gameObject.GetComponent<Image>().enabled = true;
if (this.gameObject.GetComponent<Image>() != null)
this.gameObject.GetComponent<Image>().enabled = true;
else
this.gameObject.GetComponent<SpriteRenderer>().enabled = true;
//Debug.Log(int.Parse(this.name.Substring(this.name.Length - 1)) + " конец этого");
//if(sw3Drotate!=null) ConnectWith3DSwitchVertikal();
//if (sw3DHrotate!=null) ConnectWith3DSwitchHorizontal();
ConnectWith3DSwitchVertikal();
ConnectWith3DSwitchHorizontal();
}
/*Функция связывает вертикальные выключатели 2D и 3D */
public void ConnectWith3DSwitchVertikal()
{
Transform[] btnList = this.transform.parent.gameObject.GetComponentsInChildren<Transform>();
string currentSw3Dname = this.name.Substring(0, this.name.Length - 1) + "3D";
GameObject currentSw3D = GameObject.Find(currentSw3Dname);
Switch3DRotate sw3Drotate = currentSw3D.GetComponent<Switch3DRotate>();
if (sw3Drotate != null)
// sw3Drotate.RotateVertikalSwitch(btnList.Length - 1, int.Parse(this.name.Substring(this.name.Length - 1)));
sw3Drotate.RotateVertikalSwitch(int.Parse(this.name.Substring(this.name.Length - 1))-1); // добавили в передаваемое значение -1. Спрайты имеют концовку 1,2,3, а numpos в редакторе начинается с нуля
}
/*Функция связывает горизонтальные выключатели 2D и 3D */
public void ConnectWith3DSwitchHorizontal()
{
Transform[] btnList = this.transform.parent.gameObject.GetComponentsInChildren<Transform>();
string currentSw3DHname = this.name.Substring(0, this.name.Length - 1) + "3D";
GameObject currentSw3DH = GameObject.Find(currentSw3DHname);
Switch3DHRotate sw3DHrotate = currentSw3DH.GetComponent<Switch3DHRotate>();
if (sw3DHrotate != null)
//sw3DHrotate.RotateHorizontalSwitch(btnList.Length - 1, int.Parse(this.name.Substring(this.name.Length - 1)));
sw3DHrotate.RotateHorizontalSwitch(int.Parse(this.name.Substring(this.name.Length - 1)) - 1);
}
public void switchOn()
{
Transform[] btnList = this.transform.parent.gameObject.GetComponentsInChildren<Transform>();
for (int i = 0; i < btnList.Length; i++)
{
if (i == 0) continue;
if (btnList[i].gameObject.GetComponent<Image>() != null)
btnList[i].gameObject.GetComponent<Image>().enabled = false;
else
btnList[i].gameObject.GetComponent<SpriteRenderer>().enabled = false;
}
//this.gameObject.GetComponent<Image>().enabled = true;
if (this.gameObject.GetComponent<Image>() != null)
this.gameObject.GetComponent<Image>().enabled = true;
else
this.gameObject.GetComponent<SpriteRenderer>().enabled = true;
//GetComponent<Switch3DRotate>().pos = btnList.Length;
//GetComponent<Switch3DRotate>().numpos = int.Parse(this.name.Substring(this.name.Length - 1));
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 85d5b311fb0d04e45be05ab7ce5ac995
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,106 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ToggleScript : MonoBehaviour
{
public GameObject[] tog;
int mouseY_;
int curMouseY_;
bool defTog;
// Start is called before the first frame update
void Start()
{
OnTog0();
}
public void OnClick()
{
if (tog.Length < 3)
{
OnTog2();
}
else
{
OnTog0();
}
}
void OnTog0()
{
tog[0].SetActive(true);
defTog = true;
for (int i = 1; i < tog.Length; i++)
{
tog[i].SetActive(false);
}
}
void OnTog2()
{
for (int i = 0; i < tog.Length; i++)
{
if (tog[i].activeSelf == true)
{
tog[i].SetActive(false);
}
else
{
tog[i].SetActive(true);
}
}
}
public void OnMouseDown()
{
mouseY_ = (int)Input.mousePosition.y;
//Debug.Log($"mouseY {mouseY_}");
}
public void OnMouseUp()
{
curMouseY_ = (int)Input.mousePosition.y;
if (curMouseY_ != mouseY_)
{
//Debug.Log($"curMouseY {curMouseY_}");
int dMY = mouseY_ - curMouseY_;
if (tog.Length < 3)
{
OnTog2();
}
else
{
if(defTog == true)
{
defTog = false;
if (dMY < 0)
{
tog[0].SetActive(false);
tog[1].SetActive(true);
tog[2].SetActive(false);
}
else
{
tog[0].SetActive(false);
tog[1].SetActive(false);
tog[2].SetActive(true);
}
}
else
{
OnTog0();
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 85951b9d667fdf044870056f527871fe
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,110 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class myButton : MonoBehaviour
{
Dictionary<string, GameObject> buttonStatesList = new Dictionary<string, GameObject>();
// int posCount;
// int currentPos;
GameObject goUp;
GameObject goDown;
Manager man;
Image goUp_Img = null, goDown_Img = null;
SpriteRenderer goUp_SR = null, goDown_SR = null;
void Start()
{
man = GameObject.Find("Manager").GetComponent<Manager>();
// Debug.Log(go.name);
Transform[] buttonStates = this.GetComponentsInChildren<Transform>();
// Debug.Log(btnList.Length);
// goUp = new GameObject();
// goDown = new GameObject();
for (int i = 0; i < buttonStates.Length; i++)
{
if (i == 0) continue;
if (string.Compare(buttonStates[i].name.Substring(buttonStates[i].name.Length - 2), "up") == 0) // this.name.Length - 3
{
goUp = buttonStates[i].gameObject;
}
if (string.Compare(buttonStates[i].name.Substring(buttonStates[i].name.Length - 4), "down") == 0) // this.name.Length - 3
{
goDown = buttonStates[i].gameObject;
}
}
if (goUp == null || goDown == null)
return;
goUp_Img = goUp.GetComponent<Image>();
goUp_SR = goUp.GetComponent<SpriteRenderer>();
goDown_Img = goDown.GetComponent<Image>();
goDown_SR = goDown.GetComponent<SpriteRenderer>();
if (goUp_Img != null && goDown_Img != null)
{
goUp_Img.enabled = true;
goDown_Img.enabled = false;
}
else
{
goUp_SR.enabled = true;
goDown_SR.enabled = false;
}
}
public void OnMouseDown()
{
if (man.mode == "scedit" || man.mode == "play")
return;
OnDown();
man.player.SetObjectState(man.objects.Find(this.gameObject.name), 1);
}
public void OnDown()
{
if (goUp == null || goDown == null)
return;
if (goUp_Img != null && goDown_Img != null)
{
goUp_Img.enabled = false;
goDown_Img.enabled = true;
}
else
{
goDown_SR.enabled = true;
goUp_SR.enabled = false;
}
}
void OnMouseUp()
{
if (man.mode == "scedit" || man.mode == "play")
return;
OnUp();
}
public void OnUp()
{
if (goUp == null || goDown == null)
return;
try
{
if (goUp_Img != null && goDown_Img != null)
{
goUp_Img.enabled = true;
goDown_Img.enabled = false;
}
else
{
goUp_SR.enabled = true;
goDown_SR.enabled = false;
}
}
catch(Exception e)
{
Debug.LogError(e.Message);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 26f1aa70a7d15714faee773fab0fa971
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,36 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class pedals : MonoBehaviour
{
private Vector3 mousePosition;
public float moveSpeed = 1.2f;
void OnMouseDrag()
{
//mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
mousePosition = Camera.current.ScreenToWorldPoint(Input.mousePosition);
// вычисляем разницу между текущим положением и положением мыши
Vector3 difference = mousePosition - transform.position;
difference.Normalize();
// вычисляемый необходимый угол поворота
float rotation_z = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;
// Применяем поворот вокруг оси Z
if (rotation_z<45 && rotation_z>-45)
{
transform.localRotation = Quaternion.Euler(0f, 0f, rotation_z);
//int angle_int = Mathf.RoundToInt(rotation_z);
Debug.Log("угол"+ rotation_z);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b0cc7128114335742bda5725b7601257
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 753f74211eaaa0245a9c1678ced3d384
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,74 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Cover3DHrotate : MonoBehaviour
{
/* private string animationName = "horLeft";
Animation anim;
AnimationClip open;*/
// Start is called before the first frame update
public int numpos;
[SerializeField]
float eulerAngX;
[SerializeField]
float eulerAngY;
[SerializeField]
float eulerAngZ;
public float angle = 80;
void Start()
{
//anim = GetComponent<Animation>();
//anim.Play("horLeft");
//AnimationClip open = anim.GetClip("horLeft");
//Debug.Log("загрузил " + open);
//.Play("horLeft");
//anim.Play(open.name);
//anim.Play("horLeft");
eulerAngX = transform.localEulerAngles.x;
eulerAngY = transform.localEulerAngles.y;
eulerAngZ = transform.localEulerAngles.z;
}
void OnMouseDown()
{
//this.GetComponent<Animation>().Play(animationName);
////anim.Play();
/*if (!animation.IsPlaying(animationName))
{
animation.Play(animationName);
}
Debug.Log("Cube " + this.name + " clicked!");*/
}
public void RotateH(int numpos)
{
if (eulerAngX != 0 && eulerAngX > 0 && eulerAngX < 360)
{
if (numpos == 1) this.transform.localRotation = Quaternion.Euler(eulerAngX + angle, eulerAngY, eulerAngZ);
//if (numpos == 2) this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY, eulerAngZ);
}
else if (eulerAngY != 0 && eulerAngY > 0 && eulerAngY < 360)
{
if (numpos == 1 && this.name != "Cover1_0203_3D" && this.name != "Cover1_0201_3D")
this.transform.localRotation = Quaternion.Euler(eulerAngX + angle, eulerAngY, eulerAngZ);
//if (numpos == 2) this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY, eulerAngZ);
else
this.transform.localRotation = Quaternion.Euler(eulerAngX - angle, eulerAngY, eulerAngZ); // Делаем исключение для вращаемых крышек 0203 и 0201, которые в другую сторону поворачиваем
}
else if (eulerAngZ != 0 && eulerAngZ > 0 && eulerAngZ < 360)
{
if (numpos == 1) this.transform.localRotation = Quaternion.Euler(eulerAngX + angle, eulerAngY, eulerAngZ);
}
if (numpos == 2) this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY, eulerAngZ);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e05fb5d535f9bf84c882933bb13daf58
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,50 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Cover3DVrotate : MonoBehaviour
{
public int numpos;
[SerializeField]
float eulerAngX;
[SerializeField]
float eulerAngY;
[SerializeField]
float eulerAngZ;
public float angle = 80;
void Start()
{
eulerAngX = transform.localEulerAngles.x;
eulerAngY = transform.localEulerAngles.y;
eulerAngZ = transform.localEulerAngles.z;
}
public void Rotate(int numpos)
{
if (numpos == 1 && this.name == "Cover1_0701_3D" || this.name == "Cover2_0701_3D")
this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY + angle, eulerAngZ);
else if (numpos == 1 && this.name == "Cover1_0702_3D" || this.name == "Cover2_0702_3D")
this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY - angle, eulerAngZ);
else if (numpos == 1 && this.name == "Cover3_0701_3D" || this.name == "Cover3_0702_3D")
this.transform.localRotation = Quaternion.Euler(eulerAngX-2*angle, eulerAngY, eulerAngZ);
else if (eulerAngX != 0 && eulerAngX >0 && eulerAngX < 360)
{
if (numpos == 1) this.transform.localRotation = Quaternion.Euler(eulerAngX + angle, eulerAngY, eulerAngZ);
//if (numpos == 2) this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY, eulerAngZ);
}
else if (eulerAngY != 0 && eulerAngY > 0 && eulerAngY < 360)
{
if (numpos == 1) this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY + angle, eulerAngZ);
//if (numpos == 2) this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY, eulerAngZ);
}
else if (eulerAngZ != 0 && eulerAngZ > 0 && eulerAngZ < 360)
{
if (numpos == 1) this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY, eulerAngZ + angle);
}
if (numpos == 2)
this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY, eulerAngZ);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b201e97c6020152439cc4fd26197b225
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,515 @@
<<<<<<< HEAD
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
using System.Linq;
public class MakeActive : MonoBehaviour //, IPointerEnterHandler
{
// public Color _defaultRender;
Material activeMaterial;
public Dictionary<string, GameObject> switchesList3D = new Dictionary<string, GameObject>(); // Обычные переключатели 3D
public Dictionary<string, GameObject> switchesList3Dh = new Dictionary<string, GameObject>(); // Переключатели 3D горизонтальные
public List<Material> materials = new List<Material>();
public List<Material> greenMaterials = new List<Material>();
public Renderer[] renderers;
public bool materialsReplaced = false;
Manager man;
public Material door_03_rend;
public Material door_03_mat;
//**** для подсказок
private GameObject hint3D;
public GameObject go;
private string t;
private GameObject canvasM;
//****
//void Start() // Вернуть потом назад
public void Start()
{
activeMaterial = Resources.Load<Material>("materials/Зелен");
man = GameObject.Find("Manager").GetComponent<Manager>();
//Debug.Log(activeMaterial);
renderers = this.transform.parent.GetComponentsInChildren<Renderer>();
RecordChildrenMaterials();
FindAndAddCoverVertical(); //Ищем крышки которые поворачиваются вертикально по тегу и вешаем скрипт поворота
FindAndAddCoverHorizontal(); //Ищем крышки которые поворачиваются горизонтально по тегу и вешаем скрипт поворота
FindAndAddSwitchVertikal(); //Ищем переключатели, вешаем скрипт поворота Switch3DRotate.cs
FindAndAddSwitchHorizontal();
canvasM = GameObject.Find("CanvasMenu");
go = man.prefabHint;
t = "";
foreach (KeyValuePair<string, string> p in panelName.allPanelsList)
{
if (String.Compare(p.Key, this.transform.parent.name) == 0)
{
t = panelName.allPanelsList[this.transform.parent.name];
}
}
}
//private void OnMouseEnter()
public void OnMouseEnter()
{
/* foreach (Transform child in this.transform.parent) //получить всех детей
{
//_defaultRender = child.GetComponent<Renderer>().material.color;
// child.GetComponent<Renderer>().material.color = Color.green;
}*/
ReplaceMaterialsWithActive();
//if (man.mode == "scedit" || man.mode == "play") return;
if (hint.IsHint && t != "")
{
hint3D = OnHint(this.gameObject, go, t);
}
}
public GameObject OnHint(GameObject btn, GameObject objGo, string t)
{
Vector3 mousePos = Input.mousePosition;
Vector2 hintPos = new Vector2(mousePos.x, mousePos.y);
GameObject hintObj = Instantiate(objGo, canvasM.transform);
hintObj.transform.position = hintPos;
Text txt = hintObj.GetComponentInChildren<Text>();
txt.text = t;
var hintBase = hintObj.GetComponentInChildren<Image>();
var s = txt.text.Length;
var upper = 0;
foreach (char letter in t.Where(char.IsUpper))
upper++;
var sizeX = (s- upper) * 11.2f+(upper*15.5f);
if ((sizeX + hintBase.transform.position.x) > 1920)
{
float pos = hintObj.transform.localPosition.x - sizeX;
if (pos < 0) pos = -30;
hintObj.transform.localPosition = new Vector2(pos, hintObj.transform.localPosition.y);
}
return hintObj;
}
//private void OnMouseExit()
public void OnMouseExit()
{
if (!hlight.l)
{
RestoreChildrenMaterials();
}
Destroy(hint3D);
}
private void RecordChildrenMaterials()
{
materials.Clear(); greenMaterials.Clear();
foreach (var renderer in renderers)
{
materials.Add(renderer.material);
if (this.name == "door_03")
{
Material[] door_03_rend = GameObject.Find("Copter/Fuzeliazh/Door_03/door_03").GetComponent<Renderer>().materials;
Material greenMat = new Material(door_03_rend[1]);
greenMat.SetColor("_EmissionColor", new Color(9f / 255f, 82f / 255f, 4f / 255f));
greenMaterials.Add(greenMat);
}
else if (this.name == "door_04")
{
Material[] door_04_rend = GameObject.Find("Copter/Fuzeliazh/Door_04/door_04").GetComponent<Renderer>().materials;
Material greenMat = new Material(door_04_rend[1]);
greenMat.SetColor("_EmissionColor", new Color(9f / 255f, 82f / 255f, 4f / 255f));
greenMaterials.Add(greenMat);
}
else
{
Material greenMat = new Material(renderer.material); //activeMaterial // renderer.material
greenMat.SetColor("_EmissionColor", new Color(9f / 255f, 82f / 255f, 4f / 255f));
greenMaterials.Add(greenMat);
}
}
}
public void RestoreChildrenMaterials()
{
for (int i = 0; i < renderers.Length; i++)
{
renderers[i].material = materials[i];
}
materialsReplaced = false;
}
public void ReplaceMaterialsWithActive()
{
//Debug.Log("ReplaceMaterialsWithActive: " + this.name);
if (activeMaterial != null)
{
for (int i = 0; i < renderers.Length; i++)
renderers[i].material = greenMaterials[i]; // = activeMaterial;
}
else
{
Debug.LogError("Active Material is not set!");
}
materialsReplaced = true;
}
void OnMouseDown()
{
if (man.mode == "scedit" || man.mode == "play") return;
// Скрываем люки под которыми спрятаны панели. Еще не решили нужно ли
if (this.transform.parent.gameObject.name == "Group019" || this.transform.parent.gameObject.name == "Group020") this.transform.parent.gameObject.SetActive(false);
//if (man.mode == "scedit") return;
//Debug.Log(this.transform.parent.name + " кликаю панель");
//Здесь проверку на not null сделать. Не все активные области являются панелями.
if (string.Compare(this.transform.parent.name.Substring(this.transform.parent.name.Length - 2), "3D") == 0 && this.transform.parent.name != null)
{
string panel2d = this.transform.parent.name.Substring(0, this.transform.parent.name.Length - 3);
//Debug.Log("MakeActive: " + panel2d);
// Может тут подвязать наш канвас и обзорку Максима
//man.cabines2d.SetActive(true);
//man.canvas.SetActive(true);
//man.fusel.SetActive(false);
man.SwitchTo2D(panel2d);
}
}
private void FindAndAddCoverVertical()
{
string s1 = this.transform.parent.name.Substring(this.transform.parent.name.Length - 7); // окончание названия панели например 0506_3D
string s2 = "Cover";
GameObject[] cover3Dv = GameObject.FindGameObjectsWithTag("cover3Dv");
foreach (GameObject _cover3Dv in cover3Dv)
{
if (_cover3Dv.name.EndsWith(s1) && _cover3Dv.name.StartsWith(s2))
{
//Debug.Log(_cover3Dv.name);
_cover3Dv.AddComponent<Cover3DVrotate>();
//switchesList3D.Add(sw.name, sw);
}
}
}
private void FindAndAddCoverHorizontal()
{
string s1 = this.transform.parent.name.Substring(this.transform.parent.name.Length - 7); // окончание названия панели например 0506_3D
string s2 = "Cover";
GameObject[] cover3Dh = GameObject.FindGameObjectsWithTag("cover3Dh");
foreach (GameObject _cover3Dh in cover3Dh)
{
if (_cover3Dh.name.EndsWith(s1) && _cover3Dh.name.StartsWith(s2))
{
//Debug.Log(_cover3Dh.name);
_cover3Dh.AddComponent<Cover3DHrotate>();
//_cover3Dh.AddComponent<Animation>();
//switchesList3D.Add(sw.name, sw);
}
}
}
private void FindAndAddSwitchVertikal()
{
string s1 = this.transform.parent.name.Substring(this.transform.parent.name.Length - 7); // окончание названия панели например 0506_3D
string s2 = "Tumbler";
GameObject[] switches3D = GameObject.FindGameObjectsWithTag("toggle3D");
foreach (GameObject sw in switches3D)
{
if (sw.name.EndsWith(s1) && sw.name.StartsWith(s2))
{
//Debug.Log(sw.name);
sw.AddComponent<Switch3DRotate>();
switchesList3D.Add(sw.name, sw);
}
}
}
private void FindAndAddSwitchHorizontal()
{
string s1 = this.transform.parent.name.Substring(this.transform.parent.name.Length - 7); // окончание названия панели например 0506_3D
string s2 = "Tumbler";
GameObject[] switches3Dh = GameObject.FindGameObjectsWithTag("toggle3Dh");
foreach (GameObject _switches3Dh in switches3Dh)
{
if (_switches3Dh.name.EndsWith(s1) && _switches3Dh.name.StartsWith(s2))
{
//Debug.Log(sw.name);
_switches3Dh.AddComponent<Switch3DHRotate>();
switchesList3Dh.Add(_switches3Dh.name, _switches3Dh);
}
}
}
}
=======
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
using System.Linq;
public class MakeActive : MonoBehaviour //, IPointerEnterHandler
{
// public Color _defaultRender;
Material activeMaterial;
public Dictionary<string, GameObject> switchesList3D = new Dictionary<string, GameObject>(); // Обычные переключатели 3D
public Dictionary<string, GameObject> switchesList3Dh = new Dictionary<string, GameObject>(); // Переключатели 3D горизонтальные
public List<Material> materials = new List<Material>();
public List<Material> greenMaterials = new List<Material>();
public Renderer[] renderers;
public bool materialsReplaced = false;
Manager man;
public Material door_03_rend;
public Material door_03_mat;
//**** для подсказок
private GameObject hint3D;
public GameObject go;
private string t;
private GameObject canvasM;
//****
//void Start() // Вернуть потом назад
public void Start()
{
activeMaterial = Resources.Load<Material>("materials/Зелен");
man = GameObject.Find("Manager").GetComponent<Manager>();
//Debug.Log(activeMaterial);
renderers = this.transform.parent.GetComponentsInChildren<Renderer>();
RecordChildrenMaterials();
FindAndAddCoverVertical(); //Ищем крышки которые поворачиваются вертикально по тегу и вешаем скрипт поворота
FindAndAddCoverHorizontal(); //Ищем крышки которые поворачиваются горизонтально по тегу и вешаем скрипт поворота
FindAndAddSwitchVertikal(); //Ищем переключатели, вешаем скрипт поворота Switch3DRotate.cs
FindAndAddSwitchHorizontal();
canvasM = GameObject.Find("CanvasMenu");
go = man.prefabHint;
t = "";
foreach (KeyValuePair<string, string> p in panelName.allPanelsList)
{
if (String.Compare(p.Key, this.transform.parent.name) == 0)
{
t = panelName.allPanelsList[this.transform.parent.name];
}
}
}
//private void OnMouseEnter()
public void OnMouseEnter()
{
/* foreach (Transform child in this.transform.parent) //получить всех детей
{
//_defaultRender = child.GetComponent<Renderer>().material.color;
// child.GetComponent<Renderer>().material.color = Color.green;
}*/
ReplaceMaterialsWithActive();
//if (man.mode == "scedit" || man.mode == "play") return;
if (hint.IsHint && t != "")
{
hint3D = OnHint(this.gameObject, go, t);
}
}
public GameObject OnHint(GameObject btn, GameObject objGo, string t)
{
Vector3 mousePos = Input.mousePosition;
Vector2 hintPos = new Vector2(mousePos.x, mousePos.y);
GameObject hintObj = Instantiate(objGo, canvasM.transform);
hintObj.transform.position = hintPos;
Text txt = hintObj.GetComponentInChildren<Text>();
txt.text = t;
var hintBase = hintObj.GetComponentInChildren<Image>();
var s = txt.text.Length;
var upper = 0;
foreach (char letter in t.Where(char.IsUpper))
upper++;
var sizeX = (s- upper) * 11.2f+(upper*15.5f);
if ((sizeX + hintBase.transform.position.x) > 1920)
{
float pos = hintObj.transform.localPosition.x - sizeX;
if (pos < 0) pos = -30;
hintObj.transform.localPosition = new Vector2(pos, hintObj.transform.localPosition.y);
}
return hintObj;
}
//private void OnMouseExit()
public void OnMouseExit()
{
if (!hlight.l)
{
RestoreChildrenMaterials();
}
Destroy(hint3D);
}
private void RecordChildrenMaterials()
{
materials.Clear(); greenMaterials.Clear();
foreach (var renderer in renderers)
{
materials.Add(renderer.material);
if (this.name == "door_03")
{
Material[] door_03_rend = GameObject.Find("Copter/Fuzeliazh/Door_03/door_03").GetComponent<Renderer>().materials;
Material greenMat = new Material(door_03_rend[1]);
greenMat.SetColor("_EmissionColor", new Color(9f / 255f, 82f / 255f, 4f / 255f));
greenMaterials.Add(greenMat);
}
else if (this.name == "door_04")
{
Material[] door_04_rend = GameObject.Find("Copter/Fuzeliazh/Door_04/door_04").GetComponent<Renderer>().materials;
Material greenMat = new Material(door_04_rend[1]);
greenMat.SetColor("_EmissionColor", new Color(9f / 255f, 82f / 255f, 4f / 255f));
greenMaterials.Add(greenMat);
}
else
{
Material greenMat = new Material(renderer.material); //activeMaterial // renderer.material
greenMat.SetColor("_EmissionColor", new Color(9f / 255f, 82f / 255f, 4f / 255f));
greenMaterials.Add(greenMat);
}
}
}
public void RestoreChildrenMaterials()
{
for (int i = 0; i < renderers.Length; i++)
{
renderers[i].material = materials[i];
}
materialsReplaced = false;
}
public void ReplaceMaterialsWithActive()
{
//Debug.Log("ReplaceMaterialsWithActive: " + this.name);
if (activeMaterial != null)
{
for (int i = 0; i < renderers.Length; i++)
renderers[i].material = greenMaterials[i]; // = activeMaterial;
}
else
{
Debug.LogError("Active Material is not set!");
}
materialsReplaced = true;
}
void OnMouseDown()
{
if (man.mode == "scedit" || man.mode == "play") return;
// Скрываем люки под которыми спрятаны панели. Еще не решили нужно ли
if (this.transform.parent.gameObject.name == "Group019" || this.transform.parent.gameObject.name == "Group020") this.transform.parent.gameObject.SetActive(false);
//if (man.mode == "scedit") return;
//Debug.Log(this.transform.parent.name + " кликаю панель");
//Здесь проверку на not null сделать. Не все активные области являются панелями.
if (string.Compare(this.transform.parent.name.Substring(this.transform.parent.name.Length - 2), "3D") == 0 && this.transform.parent.name != null)
{
string panel2d = this.transform.parent.name.Substring(0, this.transform.parent.name.Length - 3);
//Debug.Log("MakeActive: " + panel2d);
// Может тут подвязать наш канвас и обзорку Максима
//man.cabines2d.SetActive(true);
//man.canvas.SetActive(true);
//man.fusel.SetActive(false);
man.SwitchTo2D(panel2d);
}
}
private void FindAndAddCoverVertical()
{
string s1 = this.transform.parent.name.Substring(this.transform.parent.name.Length - 7); // окончание названия панели например 0506_3D
string s2 = "Cover";
GameObject[] cover3Dv = GameObject.FindGameObjectsWithTag("cover3Dv");
foreach (GameObject _cover3Dv in cover3Dv)
{
if (_cover3Dv.name.EndsWith(s1) && _cover3Dv.name.StartsWith(s2))
{
//Debug.Log(_cover3Dv.name);
_cover3Dv.AddComponent<Cover3DVrotate>();
//switchesList3D.Add(sw.name, sw);
}
}
}
private void FindAndAddCoverHorizontal()
{
string s1 = this.transform.parent.name.Substring(this.transform.parent.name.Length - 7); // окончание названия панели например 0506_3D
string s2 = "Cover";
GameObject[] cover3Dh = GameObject.FindGameObjectsWithTag("cover3Dh");
foreach (GameObject _cover3Dh in cover3Dh)
{
if (_cover3Dh.name.EndsWith(s1) && _cover3Dh.name.StartsWith(s2))
{
//Debug.Log(_cover3Dh.name);
_cover3Dh.AddComponent<Cover3DHrotate>();
//_cover3Dh.AddComponent<Animation>();
//switchesList3D.Add(sw.name, sw);
}
}
}
private void FindAndAddSwitchVertikal()
{
string s1 = this.transform.parent.name.Substring(this.transform.parent.name.Length - 7); // окончание названия панели например 0506_3D
string s2 = "Tumbler";
GameObject[] switches3D = GameObject.FindGameObjectsWithTag("toggle3D");
foreach (GameObject sw in switches3D)
{
if (sw.name.EndsWith(s1) && sw.name.StartsWith(s2))
{
//Debug.Log(sw.name);
sw.AddComponent<Switch3DRotate>();
switchesList3D.Add(sw.name, sw);
}
}
}
private void FindAndAddSwitchHorizontal()
{
string s1 = this.transform.parent.name.Substring(this.transform.parent.name.Length - 7); // окончание названия панели например 0506_3D
string s2 = "Tumbler";
GameObject[] switches3Dh = GameObject.FindGameObjectsWithTag("toggle3Dh");
foreach (GameObject _switches3Dh in switches3Dh)
{
if (_switches3Dh.name.EndsWith(s1) && _switches3Dh.name.StartsWith(s2))
{
//Debug.Log(sw.name);
_switches3Dh.AddComponent<Switch3DHRotate>();
switchesList3Dh.Add(_switches3Dh.name, _switches3Dh);
}
}
}
}
>>>>>>> 3b1b9479a46e90d056b92897ea9f8422b25fc052

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 3936cb98fd2f75e42ba779b89f806ed6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences:
- activeMaterial: {fileID: 2100000, guid: 93d259866b183904db724121a23f0dfb, type: 2}
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,36 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class OverWriteMaterial
{
public static void RecordChildrenMaterials(Renderer[] renderers, ref List<Material> materials, ref List<Material> greenMaterials)
{
materials.Clear(); greenMaterials.Clear();
foreach (var renderer in renderers)
{
materials.Add(renderer.material);
Material greenMat = new Material(renderer.material);
greenMat.SetColor("_EmissionColor", new Color(9f / 255f, 82f / 255f, 4f / 255f));
greenMaterials.Add(greenMat);
}
}
public static void RestoreChildrenMaterials(Renderer[] renderers, List<Material> materials)
{
for (int i = 0; i < renderers.Length; i++)
{
renderers[i].material = materials[i];
}
}
public static void ReplaceMaterialsWithActive(Renderer[] renderers, List<Material> greenMaterials)
{
for (int i = 0; i < renderers.Length; i++)
{
renderers[i].material = greenMaterials[i];
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f65cb7c4c674b354082b28a92f4af942
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,63 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Switch3DHRotate : MonoBehaviour
{
public int pos;
public int numpos;
[SerializeField]
float eulerAngX;
[SerializeField]
float eulerAngY;
[SerializeField]
float eulerAngZ;
public float angle = 30;
bool isStarted = false;
// Start is called before the first frame update
void Start()
{
if (isStarted) return;
eulerAngX = transform.localEulerAngles.x;
eulerAngY = transform.localEulerAngles.y;
eulerAngZ = transform.localEulerAngles.z;
isStarted = true;
//if (this.name == "Tumbler2_0109_3D")
//{
// Debug.Log("START Tumbler2_0109_3D: eulerAng " + eulerAngX + " " + eulerAngY + " " + eulerAngZ);
//}
}
public void RotateHorizontalSwitch(int numpos) //int pos,
{
//Debug.Log(pos);
/* if (pos == 5)
{
if (numpos == 1) this.transform.localRotation = Quaternion.Euler(eulerAngX + 0, eulerAngY + 0, 0);
if (numpos == 2) this.transform.localRotation = Quaternion.Euler(eulerAngX + 30, eulerAngY + 0, 0);
if (numpos == 3) this.transform.localRotation = Quaternion.Euler(eulerAngX + 0, eulerAngY + 30, 0);
if (numpos == 4) this.transform.localRotation = Quaternion.Euler(eulerAngX - 30, eulerAngY + 0, 0);
if (numpos == 5) this.transform.localRotation = Quaternion.Euler(eulerAngX + 0, eulerAngY - 30, 0);
}
if (pos == 2)
{
if (numpos == 1) this.transform.localRotation = Quaternion.Euler(eulerAngX + angle, eulerAngY , eulerAngZ + 0);
if (numpos == 2) this.transform.localRotation = Quaternion.Euler(eulerAngX - angle, eulerAngY , eulerAngZ + 0);
}*/
if (!isStarted) Start();
if (numpos == 1) this.transform.localRotation = Quaternion.Euler(eulerAngX - angle + 10, eulerAngY, eulerAngZ); // право
if (numpos == 0) this.transform.localRotation = Quaternion.Euler(eulerAngX+angle + 10, eulerAngY, eulerAngZ); // лево
if (numpos == 2) this.transform.localRotation = Quaternion.Euler(eulerAngX + 10, eulerAngY, eulerAngZ); // центр
if (numpos > 2)
Debug.Log("Switch3DHRotate error: numpos > 2");
//if (this.name == "Tumbler2_0109_3D")
//{
// Debug.Log("Tumbler2_0109_3D: localRotation " + this.transform.localEulerAngles.x + " " + this.transform.localEulerAngles.y + " " + this.transform.localEulerAngles.z + " " +
// " eulerAng " + eulerAngX + " " + eulerAngY + " " + eulerAngZ + " ");
//}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: eebfec330c9e2c74d82df8670011e82d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,72 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Switch3DRotate : MonoBehaviour
{
//public int pos;
public int numpos;
[SerializeField]
float eulerAngX ;
[SerializeField]
float eulerAngY ;
[SerializeField]
float eulerAngZ ;
public float angle = 30;
bool isStarted = false;
void Start()
{
if (isStarted) return;
//Debug.Log( this.name + " На ком висим");
// Задаем текущий Rotation объекта по осям
eulerAngX = transform.localEulerAngles.x;
eulerAngY = transform.localEulerAngles.y;
eulerAngZ = transform.localEulerAngles.z;
isStarted = true;
}
public void RotateVertikalSwitch(int numpos) //int pos,
{
//Debug.Log(pos + " сколько позиций");
//Debug.Log(this.name + " кто");
// !!!!!!!!!!!!! Исправить !!!! У нас rotation по Y
/* if (pos == 5)
{
if (numpos == 1) this.transform.localRotation = Quaternion.Euler(eulerAngX+0, eulerAngY+0, 0);
if (numpos == 2) this.transform.localRotation = Quaternion.Euler(eulerAngX+30, eulerAngY+0, 0);
if (numpos == 3) this.transform.localRotation = Quaternion.Euler(eulerAngX+0, eulerAngY+30, 0);
if (numpos == 4) this.transform.localRotation = Quaternion.Euler(eulerAngX-30, eulerAngY+0, 0);
if (numpos == 5) this.transform.localRotation = Quaternion.Euler(eulerAngX+0, eulerAngY-30, 0);
}
if (pos == 2)
{
if (numpos == 1) this.transform.localRotation = Quaternion.Euler(eulerAngX,eulerAngY-30, eulerAngZ+0);
if (numpos == 2) this.transform.localRotation = Quaternion.Euler(eulerAngX,eulerAngY+30, eulerAngZ+0);
}
if (pos == 3)
{
if (numpos == 3) this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY+30, eulerAngZ+0);
if (numpos == 2) this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY-30, eulerAngZ+0);
if (numpos == 1) this.transform.localRotation = Quaternion.Euler(eulerAngX,eulerAngY+0, eulerAngZ+0);
}*/
/* Вариант последний после правок Кирилла по двум передаваемым параметрам,которые заменили на один
if (numpos == 1) this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY + 30 + 10, eulerAngZ + 0); // вверх
if (numpos == 0) this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY - 30 + 10, eulerAngZ + 0); // вниз
if (numpos == 2) this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY + 0 +10, eulerAngZ + 0); // центр
if (numpos > 3) // upd if (numpos > 2) нумерация концовок названий спрайтов с 1 начинается
Debug.Log("Switch3DRotate error: numpos > 3");
*/
if (!isStarted) Start();
if (numpos == 1) this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY + 30 + 10, eulerAngZ + 0); // вверх
if (numpos == 0) this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY - 30 + 10, eulerAngZ + 0); // вниз
if (numpos == 2) this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY + 0 + 10, eulerAngZ + 0); // центр
if (numpos > 2) Debug.Log("Switch3DRotate error: numpos > 3");
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 821505d84cadcc34fac72f738c432572
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,66 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class clickPanel : MonoBehaviour
{
public Color _defaultRender;
public Dictionary<string, GameObject> switchesList3D = new Dictionary<string, GameObject>(); // Обычные переключатели 3D
void Start()
{
/* Mesh myMesh = this.GetComponent<MeshFilter>().mesh;
DestroyImmediate(this.GetComponent<MeshCollider>());
var collider = this.gameObject.AddComponent<MeshCollider>();
collider.sharedMesh = myMesh; */
string s1 = this.name.Substring(this.name.Length - 7); // окончание названия панели например 0506_3D
string s2 = "Tumbler";
GameObject[] switches3D = GameObject.FindGameObjectsWithTag("toggle3D");
foreach (GameObject sw in switches3D)
{
if (sw.name.EndsWith(s1) && sw.name.StartsWith(s2))
{
//Debug.Log(sw.name);
sw.AddComponent<Switch3DRotate>();
switchesList3D.Add(sw.name, sw);
//Debug.Log("Имена 3D переключателей " + sw.name);
//Debug.Log("Кол-во 3D переключателей " + switches3D.Length);
}
}
//Debug.Log(this.name + " Имя этой панели");
}
void OnMouseDown()
{
Debug.Log(this.name + " кликаю панель");
if (string.Compare(this.name.Substring(this.name.Length - 2), "3D") == 0 && this.name != null)
{
string panel2d = this.name.Substring(0, this.name.Length - 3);
GameObject manager = GameObject.Find("Manager");
manager.GetComponent<Manager>().SwitchTo2D(panel2d);
}
}
void OnMouseEnter()
{
_defaultRender = GetComponent<Renderer>().material.color;
GetComponent<Renderer>().material.color = Color.green;
}
void OnMouseExit()
{
GetComponent<Renderer>().material.color = _defaultRender;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f9ecb01ec038da645a13902ccdfd5aa2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,58 @@
/*
Скрипт вращения 3D педалей
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class rotate3DPedals : MonoBehaviour
{
[SerializeField]
float eulerAngX;
[SerializeField]
float eulerAngY;
[SerializeField]
float eulerAngZ;
bool isStarted = false;
Manager man;
void Start()
{
man = GameObject.Find("Manager").GetComponent<Manager>();
eulerAngX = transform.localEulerAngles.x;
eulerAngY = transform.localEulerAngles.y;
eulerAngZ = transform.localEulerAngles.z;
isStarted = true;
}
public void RotatePedals(float angle)
{
if (!isStarted) return;
this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY , eulerAngZ - angle);
}
// Функция связки с 3D ручками, поворот по горизонтали
public void RotateLeverHorizontal(float angle)
{
if (!isStarted) return;
//Debug.Log("при повороте по горизонтали " + angle );
/*this.transform.localRotation = Quaternion.Euler(transform.localRotation.eulerAngles.x, eulerAngY - angle, transform.localRotation.eulerAngles.z);*/
this.transform.localRotation = Quaternion.Euler(eulerAngX + angle, transform.localRotation.eulerAngles.y, transform.localRotation.eulerAngles.z);
}
// Функция связки с 3D ручками, поворот по вертикали
public void RotateLeverVertical(float angle)
{
if (!isStarted) return;
//Debug.Log("при повороте по вертикали " + angle);
this.transform.localRotation = Quaternion.Euler(transform.localRotation.eulerAngles.x, transform.localRotation.eulerAngles.y, eulerAngZ - angle );
}
// Функция связки с 3D одинарными ручками, поворот по вертикали
public void RotateLeverOneVertical(float angle)// используется только для РОШ 0701, 0702
{
if (!isStarted) return;
//Debug.Log("при повороте по вертикали " + angle);
this.transform.localRotation = Quaternion.Euler(transform.localRotation.eulerAngles.x, eulerAngY - angle, eulerAngZ);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f94c5d14513fdd7429c61884ba714c67
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More