first commit
This commit is contained in:
commit
df6e2fe069
8
API.meta
Normal file
8
API.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e30640b3abb93642a825989a05339a1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
API/MTEGetMarksLabelsByArrPoint.meta
Normal file
8
API/MTEGetMarksLabelsByArrPoint.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d872f798ef1b3214ea27187d319cce1c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
38
API/MTEGetMarksLabelsByArrPoint/Data.cs
Normal file
38
API/MTEGetMarksLabelsByArrPoint/Data.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts.API.MTEGetMarksLabelsByArrPoint
|
||||
{
|
||||
[System.Serializable]
|
||||
public class ApiResponse
|
||||
{
|
||||
public string error;
|
||||
public ResponseData respose;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class ResponseData
|
||||
{
|
||||
public Item[] items;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class Item
|
||||
{
|
||||
public string aliases;
|
||||
public string block_name;
|
||||
public CenterPoint center_point;
|
||||
public bool is_mark_detect;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class CenterPoint
|
||||
{
|
||||
public float x;
|
||||
public float y;
|
||||
public float z;
|
||||
}
|
||||
}
|
||||
11
API/MTEGetMarksLabelsByArrPoint/Data.cs.meta
Normal file
11
API/MTEGetMarksLabelsByArrPoint/Data.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e4f00a28bac5814fa61edf72f1325b5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
42
MethodJSON.cs
Normal file
42
MethodJSON.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
// Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse);
|
||||
public class Item
|
||||
{
|
||||
public List<string> block_names_aliases { get; set; }
|
||||
public int sn { get; set; }
|
||||
public DateTime time { get; set; }
|
||||
public DateTime time_mo { get; set; }
|
||||
public float x { get; set; }
|
||||
public float x_mo { get; set; }
|
||||
public float y { get; set; }
|
||||
public float y_mo { get; set; }
|
||||
public float z { get; set; }
|
||||
public float z_mo { get; set; }
|
||||
}
|
||||
|
||||
public class MarksTime
|
||||
{
|
||||
public int count_seconds { get; set; }
|
||||
public string name { get; set; }
|
||||
}
|
||||
|
||||
public class ResposeMethod
|
||||
{
|
||||
public List<Item> items { get; set; }
|
||||
public string tag { get; set; }
|
||||
public string time_begin { get; set; }
|
||||
public string time_end { get; set; }
|
||||
public List<MarksTime> marks_time { get; set; }
|
||||
}
|
||||
|
||||
public class MethodJSON
|
||||
{
|
||||
public string error { get; set; }
|
||||
public ResposeMethod respose { get; set; }
|
||||
public int status { get; set; }
|
||||
}
|
||||
|
||||
11
MethodJSON.cs.meta
Normal file
11
MethodJSON.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0be947f1f89f1e2409163368a7209533
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
261
PersonScript.cs
Normal file
261
PersonScript.cs
Normal file
@ -0,0 +1,261 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
public class PersonScript : MonoBehaviour
|
||||
{
|
||||
[Header("Äàííûå ñîòðóäíèêà")]
|
||||
public string FIO; //ÔÈÎ ñîòðóäíèêà
|
||||
public string Tabnomer; //Ñåðèéíûé íîìåð ñîòðóäíèêà
|
||||
[Header("Êîìïîíåíòû ñîòðóäíèêà")]
|
||||
[SerializeField] private Animator PersonAnimator; //Àíèìàòîð
|
||||
[SerializeField] private NavMeshAgent NavMeshAgent; //ÈÈ
|
||||
[SerializeField] private int CurrentPoint; //Òåêóùàÿ òî÷êà
|
||||
[SerializeField] private ThanksStASSForTheNiceMethod Delogger; //Ñêðèïò ñ äàííûìè
|
||||
[SerializeField] private Uiika Uiika;
|
||||
public VisualTreeAsset MainUIPrefab;
|
||||
private Label TimeText; //UI êîìïîíåíòû -->
|
||||
private Label CordsMoText;
|
||||
private Label CordsRTLSText;
|
||||
private Label PointText;
|
||||
private Label TimeLabel;
|
||||
private Label OtmetkaName;
|
||||
private Label FullTime;
|
||||
private Label SlidBegin;
|
||||
private Label SlidEnd;
|
||||
private ProgressBar ProgressBar;
|
||||
private Button PlayButton;
|
||||
private Button StopButton;
|
||||
private Button BackButton;
|
||||
private Slider Slider;
|
||||
private SliderInt SliderTime;
|
||||
private SliderInt SliderMove; // <-- UI êîìïîíåíòû
|
||||
[SerializeField] private GameObject MoPointPrefab; //Ïðåôàá òî÷êè ÌÎ
|
||||
[SerializeField] private GameObject RTLSPointPrefab; //Ïðåôàá òî÷êè ÐÒËÑ
|
||||
[Header("UIDocument")]
|
||||
public UIDocument UI; //UI
|
||||
private GameObject moPoint; //ïàìÿòü î òî÷êå ÌÎ
|
||||
private GameObject rtlsPoint; //ïàìÿòü î òî÷êå ÐÒËÑ
|
||||
[Header("Äàííûå ÈÈ")]
|
||||
public float WaitTime; //Âðåìÿ ïðîâåðêè òî÷êè
|
||||
public float NavAgentSpeed; //Ñêîðîñòü ïåðåìåùåíèÿ ÈÈ
|
||||
public Vector3 VectorDestination; //Òî÷êà íàçíà÷åíèÿ
|
||||
public float RemainingDistance; // îñòàâøååñÿ ðàññòîÿíèå äî òî÷êè
|
||||
[Space]
|
||||
public bool Play; //Ïðîèãðûâàíèå õîæäåíèÿ
|
||||
|
||||
public void InitMePlease() //Èíèöèàëèçàöèÿ UI è óñòàíîâêà íà÷àëüíûõ çíà÷åíèé
|
||||
{
|
||||
var root = UI.rootVisualElement;
|
||||
|
||||
TimeText = root.Q<Label>("TextTime");
|
||||
FullTime = root.Q<Label>("FullTime");
|
||||
CordsMoText = root.Q<Label>("TextCordsMo");
|
||||
CordsRTLSText = root.Q<Label>("TextCordsRTLS");
|
||||
PointText = root.Q<Label>("TextPoint");
|
||||
PointText.visible = false;
|
||||
TimeLabel = root.Q<Label>("TimeLabel");
|
||||
OtmetkaName = root.Q<Label>("OtmetkaName");
|
||||
ProgressBar = root.Q<ProgressBar>("progressbar");
|
||||
ProgressBar.visible = false;
|
||||
PlayButton = root.Q<Button>("playbutton");
|
||||
StopButton = root.Q<Button>("stopbutton");
|
||||
BackButton = root.Q<Button>("BackButton");
|
||||
Slider = root.Q<Slider>("Slider");
|
||||
SliderTime = root.Q<SliderInt>("SliderTime");
|
||||
SliderMove = root.Q<SliderInt>("SliderMove");
|
||||
|
||||
NavMeshAgent.Warp(Delogger.LocationsMO[0]); //Òåëåïîðò ÈÈ íà ïåðâóþ òî÷êó èç èñòîðèè
|
||||
|
||||
string[] strArray = Delogger.Time[0].Split(' ');
|
||||
TimeLabel.text = strArray[1]; //Îòîáðàæåíèå âðåìåíè íà ïîëçóíêå ñíèçó
|
||||
|
||||
OtmetkaName.text = Delogger.BlockNamesAliases[0];
|
||||
|
||||
SliderTime.highValue = Delogger.LocationsMO.Count - 1;
|
||||
ProgressBar.highValue = Delogger.LocationsMO.Count - 1;
|
||||
TimeText.text = "Âðåìÿ: " + Delogger.Time[CurrentPoint];
|
||||
CordsMoText.text = "Êîîðäèíàòû ÌÎ: " + Delogger.LocationsMO[CurrentPoint];
|
||||
CordsRTLSText.text = "Êîîðäèíàòû ÐÒËÑ: " + Delogger.LocationsRTLS[CurrentPoint];
|
||||
PointText.text = "Òåêóùàÿ òî÷êà: " + CurrentPoint + " èç " + (Delogger.LocationsMO.Count - 1);
|
||||
SliderTime.ElementAt(0).ElementAt(0).ElementAt(2).Add(SliderTime.ElementAt(1));
|
||||
|
||||
PlayButton.clicked += PlayButtonPressed; //Áèíä èâåíòà íà íàæàòèå êíîïêè PlayButton
|
||||
StopButton.clicked += StopButtonPressed; //Áèíä èâåíòà íà íàæàòèå êíîïêè StopButton
|
||||
BackButton.clicked += BackButtonPressed;
|
||||
Uiika.MakeTable();
|
||||
FullTime.text = "Ñ "+Delogger.Time[0] +" ïî "+ Delogger.Time[Delogger.Time.Count - 1];
|
||||
if (moPoint == null)
|
||||
{
|
||||
moPoint = Instantiate(MoPointPrefab, Delogger.LocationsMO[CurrentPoint], MoPointPrefab.gameObject.transform.rotation); //Ñïàâí òî÷êè ÌÎ
|
||||
}
|
||||
else if (moPoint.transform.position != Delogger.LocationsMO[CurrentPoint])
|
||||
{
|
||||
Destroy(moPoint); //Óäàëåíèå òî÷êè ÌÎ
|
||||
}
|
||||
Play = true;
|
||||
//if (rtlsPoint == null)
|
||||
//{
|
||||
// rtlsPoint = Instantiate(RTLSPointPrefab, Delogger.LocationsRTLS[CurrentPoint], MoPointPrefab.gameObject.transform.rotation); //Ñïàâí òî÷êè ÐÒËÑ
|
||||
//}
|
||||
//else if (rtlsPoint.transform.position != Delogger.LocationsRTLS[CurrentPoint])
|
||||
//{
|
||||
// Destroy(rtlsPoint); //Óäàëåíèå òî÷êè ÐÒËÑ
|
||||
//}
|
||||
|
||||
|
||||
void BackButtonPressed()
|
||||
{
|
||||
UI.visualTreeAsset = MainUIPrefab;
|
||||
Uiika.RequestButton.SetEnabled(true); //Îòêëþ÷åíèå êíîïêè RequestButton, äëÿ èçáåæàíèÿ ïîâòîðíûõ äàííûõ
|
||||
Uiika.Start();
|
||||
Uiika.Remember();
|
||||
Play = false;
|
||||
NavMeshAgent.SetDestination(gameObject.transform.position);
|
||||
PersonAnimator.SetBool("isMoving", false);
|
||||
Destroy(moPoint); //Óäàëåíèå òî÷êè ÌÎ
|
||||
Destroy(rtlsPoint); //Óäàëåíèå òî÷êè ÐÒËÑ
|
||||
NavMeshAgent.speed = 4;
|
||||
WaitTime = 0.7f;
|
||||
CurrentPoint = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
//Èçìåíåíèå âðåìåíè ïðîâåðêè òî÷êè
|
||||
Slider.RegisterCallback<ChangeEvent<float>>((evt) =>
|
||||
{
|
||||
WaitTime = evt.newValue;
|
||||
});
|
||||
|
||||
//Èçìåíåíèå òî÷êè ïî ïîëçóíêó âíèçó
|
||||
SliderTime.RegisterCallback<ChangeEvent<int>>((zvt) =>
|
||||
{
|
||||
CurrentPoint = zvt.newValue;
|
||||
NavMeshAgent.Warp(Delogger.LocationsMO[CurrentPoint]);
|
||||
|
||||
string[] strArray = Delogger.Time[CurrentPoint].Split(' ');
|
||||
TimeLabel.text = strArray[1];
|
||||
OtmetkaName.text = Delogger.BlockNamesAliases[CurrentPoint];
|
||||
TimeText.text = "Âðåìÿ: " + Delogger.Time[CurrentPoint];
|
||||
CordsMoText.text = "Êîîðäèíàòû ÌÎ: " + Delogger.LocationsMO[CurrentPoint];
|
||||
CordsRTLSText.text = "Êîîðäèíàòû ÐÒËÑ: " + Delogger.LocationsRTLS[CurrentPoint];
|
||||
PointText.text = "Òåêóùàÿ òî÷êà: " + CurrentPoint + " èç " + (Delogger.LocationsMO.Count - 1);
|
||||
ProgressBar.value = CurrentPoint;
|
||||
});
|
||||
|
||||
//Èçìåíåíèå ñêîðîñòè ïåðåìåùåíèÿ ÈÈ
|
||||
SliderMove.RegisterCallback<ChangeEvent<int>>((speed) =>
|
||||
{
|
||||
NavMeshAgent.speed = speed.newValue;
|
||||
});
|
||||
|
||||
//Çàïóñê öèêëà íà ïðîâåðêó òî÷êè
|
||||
StartCoroutine("CheckPosition");
|
||||
}
|
||||
|
||||
void PlayButtonPressed() //Âûçîâ ñ êíîïêè PlayButton
|
||||
{
|
||||
Play = true;
|
||||
NavMeshAgent.SetDestination(Delogger.LocationsMO[CurrentPoint]);
|
||||
PlayButton.SetEnabled(false);
|
||||
StopButton.SetEnabled(true);
|
||||
}
|
||||
void StopButtonPressed() //Âûçîâ ñ êíîïêè StopButton
|
||||
{
|
||||
Play = false;
|
||||
NavMeshAgent.SetDestination(gameObject.transform.position);
|
||||
PersonAnimator.SetBool("isMoving", false);
|
||||
PlayButton.SetEnabled(true);
|
||||
StopButton.SetEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Play)
|
||||
{
|
||||
RemainingDistance = NavMeshAgent.remainingDistance; //Âûâîä îñòàâøååñÿ ðàññòîÿíèÿ äî òî÷êè
|
||||
NavMeshAgent.SetDestination(Delogger.LocationsMO[CurrentPoint]); //Âûñòàâëåíèå òî÷êè äëÿ ÈÈ â çàâèñèìîñòè îò òåêóùåãî èíäåêñà
|
||||
VectorDestination = Delogger.LocationsMO[CurrentPoint]; //Çàïèñü êîîðäèíàò â ïåðåìåííóþ äëÿ ïðîñìîòðà
|
||||
|
||||
CheckPoints(); //Ïðîâåðêà òî÷åê åñòü ëè îíè
|
||||
SetUIParams(); //Óñòàíîâëåíèå ïàðàìåòðîâ â UI
|
||||
|
||||
PersonAnimator.SetBool("isMoving", NavMeshAgent.velocity.magnitude > 0.01f); //Ïðîâåðêà ñêîðîñòè ÈÈ äëÿ îòîáðàæåíèÿ àíèìàöèè
|
||||
NavAgentSpeed = NavMeshAgent.velocity.magnitude; //Òåêóùàÿ ñêîðîñòü ÈÈ
|
||||
}
|
||||
switch (NavMeshAgent.speed)
|
||||
{
|
||||
case 10:
|
||||
WaitTime = 0.1f;
|
||||
break;
|
||||
case 9:
|
||||
WaitTime = 0.2f;
|
||||
break;
|
||||
case 8:
|
||||
WaitTime = 0.3f;
|
||||
break;
|
||||
case 7:
|
||||
WaitTime = 0.4f;
|
||||
break;
|
||||
case 6:
|
||||
WaitTime = 0.5f;
|
||||
break;
|
||||
case 5:
|
||||
WaitTime = 0.6f;
|
||||
break;
|
||||
case 4:
|
||||
WaitTime = 0.7f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
IEnumerator CheckPosition()
|
||||
{
|
||||
if (NavMeshAgent.remainingDistance <= NavMeshAgent.stoppingDistance & Play & CurrentPoint != Delogger.LocationsMO.Count -1) // Ïðîâåðêà íà îñòàâøèååñÿ ðàññòîÿíèå, íà ðàçðåøåíî ëè ïðîèãðûâàíèå, íà òî ÷òî òåêóùàÿ òî÷êà íå ïîñëåäíÿÿ
|
||||
{
|
||||
CurrentPoint++; //Ñëåäóþùàÿ òî÷êà
|
||||
ProgressBar.value = CurrentPoint; //Óñòàíîâêà çíà÷åíèÿ â ProgressBar
|
||||
}
|
||||
yield return new WaitForSecondsRealtime(WaitTime);
|
||||
StartCoroutine("CheckPosition");
|
||||
}
|
||||
private void CheckPoints()
|
||||
{
|
||||
if (moPoint == null)
|
||||
{
|
||||
moPoint = Instantiate(MoPointPrefab, Delogger.LocationsMO[CurrentPoint], MoPointPrefab.gameObject.transform.rotation); //Ñïàâí òî÷êè ÌÎ
|
||||
}
|
||||
else if (moPoint.transform.position != Delogger.LocationsMO[CurrentPoint])
|
||||
{
|
||||
Destroy(moPoint); //Óäàëåíèå òî÷êè ÌÎ
|
||||
}
|
||||
//if (rtlsPoint == null)
|
||||
//{
|
||||
// rtlsPoint = Instantiate(RTLSPointPrefab, Delogger.LocationsRTLS[CurrentPoint], MoPointPrefab.gameObject.transform.rotation); //Ñïàâí òî÷êè ÐÒËÑ
|
||||
//}
|
||||
//else if (rtlsPoint.transform.position != Delogger.LocationsRTLS[CurrentPoint])
|
||||
//{
|
||||
// Destroy(rtlsPoint); //Óäàëåíèå òî÷êè ÐÒËÑ
|
||||
//}
|
||||
}
|
||||
private void SetUIParams()
|
||||
{
|
||||
SliderTime.SetValueWithoutNotify(CurrentPoint);
|
||||
TimeText.text = "Âðåìÿ: " + Delogger.Time[CurrentPoint];
|
||||
CordsMoText.text = "Êîîðäèíàòû ÌÎ: " + Delogger.LocationsMO[CurrentPoint];
|
||||
CordsRTLSText.text = "Êîîðäèíàòû ÐÒËÑ: " + Delogger.LocationsRTLS[CurrentPoint];
|
||||
PointText.text = "Òåêóùàÿ òî÷êà: " + CurrentPoint + " èç " + (Delogger.LocationsMO.Count - 1);
|
||||
|
||||
string[] strArray = Delogger.Time[CurrentPoint].Split(' ');
|
||||
TimeLabel.text = strArray[1];
|
||||
|
||||
OtmetkaName.text = Delogger.BlockNamesAliases[CurrentPoint];
|
||||
}
|
||||
}
|
||||
11
PersonScript.cs.meta
Normal file
11
PersonScript.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3e4a41f535231749a89a6463578ca5a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
40
PlayerScript.cs
Normal file
40
PlayerScript.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerScript : MonoBehaviour
|
||||
{
|
||||
public Transform target;
|
||||
public Vector3 offset;
|
||||
public float sensitivity = 3; // ÷óâñòâèòåëüíîñòü ìûøêè
|
||||
public float limit = 80; // îãðàíè÷åíèå âðàùåíèÿ ïî Y
|
||||
public float zoom = 0.25f; // ÷óâñòâèòåëüíîñòü ïðè óâåëè÷åíèè, êîëåñèêîì ìûøêè
|
||||
public float zoomMax = 10; // ìàêñ. óâåëè÷åíèå
|
||||
public float zoomMin = 3; // ìèí. óâåëè÷åíèå
|
||||
private float X, Y;
|
||||
|
||||
void Start()
|
||||
{
|
||||
limit = Mathf.Abs(limit);
|
||||
if (limit > 90) limit = 90;
|
||||
offset = new Vector3(offset.x, offset.y, -Mathf.Abs(zoomMax) / 2);
|
||||
transform.position = target.position + offset;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetAxis("Mouse ScrollWheel") > 0) offset.z += zoom;
|
||||
else if (Input.GetAxis("Mouse ScrollWheel") < 0) offset.z -= zoom;
|
||||
offset.z = Mathf.Clamp(offset.z, -Mathf.Abs(zoomMax), -Mathf.Abs(zoomMin));
|
||||
|
||||
if (Input.GetMouseButton(0))
|
||||
{
|
||||
X = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivity;
|
||||
Y += Input.GetAxis("Mouse Y") * sensitivity;
|
||||
Y = Mathf.Clamp(Y, -limit, limit);
|
||||
transform.localEulerAngles = new Vector3(-Y, X, 0);
|
||||
}
|
||||
transform.position = transform.localRotation * offset + target.position;
|
||||
|
||||
}
|
||||
}
|
||||
11
PlayerScript.cs.meta
Normal file
11
PlayerScript.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 350d6e72ba3ffbe47bd05553d974b923
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
67
PostgreSQL.cs
Normal file
67
PostgreSQL.cs
Normal file
@ -0,0 +1,67 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Npgsql;
|
||||
|
||||
public class PostgreSQL : MonoBehaviour
|
||||
{
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
Postgres();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
public static void Postgres()
|
||||
{
|
||||
string connectionString =
|
||||
"Port = 5433;" +
|
||||
"Server=192.168.0.157;" +
|
||||
"Database=unity_db;" +
|
||||
"User ID=unity_db;" +
|
||||
"Password=unity_db;";
|
||||
// IDbConnection dbcon; ## CHANGE THIS TO
|
||||
NpgsqlConnection dbcon;
|
||||
|
||||
dbcon = new NpgsqlConnection(connectionString);
|
||||
dbcon.Open();
|
||||
//IDbCommand dbcmd = dbcon.CreateCommand();## CHANGE THIS TO
|
||||
NpgsqlCommand dbcmd = dbcon.CreateCommand();
|
||||
// requires a table to be created named employee
|
||||
// with columns firstname and lastname
|
||||
// such as,
|
||||
// CREATE TABLE employee (
|
||||
// firstname varchar(32),
|
||||
// lastname varchar(32));
|
||||
string sql =
|
||||
"SELECT firstname, lastname " +
|
||||
"FROM employee";
|
||||
dbcmd.CommandText = sql;
|
||||
//IDataReader reader = dbcmd.ExecuteReader(); ## CHANGE THIS TO
|
||||
NpgsqlDataReader reader = dbcmd.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
string FirstName = (reader.IsDBNull(0)) ? "NULL" : reader.GetString(0).ToString();
|
||||
string LastName = (reader.IsDBNull(1)) ? "NULL" : reader.GetString(1).ToString();
|
||||
//string LastName = (string)reader.GetString(1);
|
||||
Debug.Log("FIO:" + FirstName + " " + LastName);
|
||||
//Console.WriteLine();
|
||||
}
|
||||
// clean up
|
||||
reader.Close();
|
||||
reader = null;
|
||||
dbcmd.Dispose();
|
||||
dbcmd = null;
|
||||
dbcon.Close();
|
||||
dbcon = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
11
PostgreSQL.cs.meta
Normal file
11
PostgreSQL.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b124a795d2d60044ab20e8a39e34b251
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
178
ThanksStASSForTheNiceMethod.cs
Normal file
178
ThanksStASSForTheNiceMethod.cs
Normal file
@ -0,0 +1,178 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using UnityEngine.Networking;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine.UIElements;
|
||||
//using UnityEngine.Analytics;
|
||||
|
||||
public class ThanksStASSForTheNiceMethod : MonoBehaviour
|
||||
{
|
||||
[Header("Ññûëêà íà ìåòîä è àâòîðèçàöèÿ")]
|
||||
public string URL;
|
||||
public string Auth;
|
||||
[Header("Ëèñòû ñ äàííûìè")]
|
||||
public List<Vector3> LocationsMO; //Òî÷êè ÌÎ
|
||||
public List<Vector3> LocationsRTLS; //Òî÷êè ÐÒËÑ
|
||||
public List<String> BlockNamesAliases; //Íàçâàíèå îòìåòîê
|
||||
public List<String> Time; //Âðåìÿ
|
||||
public List<String> MarksTime;
|
||||
[Header("UIDocument")]
|
||||
public UIDocument UI;
|
||||
[Header("Ýêðàí ñ ïåðåìåùåíèåì")]
|
||||
public VisualTreeAsset GameUIPrefab; //Ýêðàí ñ ïåðåùåíèåì
|
||||
[Header("ÈÈ")]
|
||||
public PersonScript Personchikn; // ÈÈ
|
||||
[Header("Ñêðèïò âûïîëíÿþùèé çàïðîñ")]
|
||||
public Uiika UIka;
|
||||
|
||||
public void Request()
|
||||
{
|
||||
GenerateRequest();
|
||||
|
||||
}
|
||||
public void ClearList() //Î÷èñòêà äàííûõ
|
||||
{
|
||||
LocationsMO.Clear();
|
||||
LocationsRTLS.Clear();
|
||||
BlockNamesAliases.Clear();
|
||||
Time.Clear();
|
||||
MarksTime.Clear();
|
||||
}
|
||||
void GenerateRequest() //Ãåíåðàöèÿ çàïðîñà
|
||||
{
|
||||
//StartCoroutine(SpawnTestItems());
|
||||
StartCoroutine(ProcessRequest(URL));
|
||||
}
|
||||
private IEnumerator SpawnTestItems()
|
||||
{
|
||||
string uri = "http://localhost:8001/api/v2/marks/getMarksLabelsByArrPoints";
|
||||
|
||||
using (UnityWebRequest request = UnityWebRequest.Get(uri))
|
||||
{
|
||||
//request.SetRequestHeader("Authorization", Auth);
|
||||
//request.SetRequestHeader("Access-Control-Allow-Origin", "*");
|
||||
request.timeout = 60;
|
||||
yield return request.SendWebRequest();
|
||||
|
||||
if (request.result == UnityWebRequest.Result.Success)
|
||||
{
|
||||
var responseObject = JsonConvert.DeserializeObject<Assets.Scripts.API.MTEGetMarksLabelsByArrPoint.ApiResponse>(request.downloadHandler.text);
|
||||
try
|
||||
{
|
||||
foreach (var item in responseObject.respose.items)
|
||||
{
|
||||
Vector3 pos = new Vector3(item.center_point.x, item.center_point.z, item.center_point.y);
|
||||
GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
|
||||
|
||||
sphere.transform.position = pos;
|
||||
// Ñîçäàíèå ìàòåðèàëà
|
||||
Material redMaterial = new Material(Shader.Find("Standard"));
|
||||
redMaterial.color = Color.red;
|
||||
|
||||
// Ïðèìåíåíèå ìàòåðèàëà ê ñôåðå
|
||||
sphere.GetComponent<Renderer>().material = redMaterial;
|
||||
|
||||
}
|
||||
} catch (Exception e)
|
||||
{
|
||||
Debug.LogException(e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Received: " + request.downloadHandler.text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator ProcessRequest(string uri)
|
||||
{
|
||||
|
||||
//Analytics.CustomEvent("check_uri", new Dictionary<string, object>
|
||||
//{
|
||||
// { "level", 1 },
|
||||
// { "player_name", "Player1" }
|
||||
//});
|
||||
|
||||
using (UnityWebRequest request = UnityWebRequest.Get(uri))
|
||||
{
|
||||
//request.SetRequestHeader("Authorization", Auth);
|
||||
//request.SetRequestHeader("Access-Control-Allow-Origin", "*");
|
||||
request.timeout = 60;
|
||||
yield return request.SendWebRequest();
|
||||
|
||||
|
||||
if (request.result != UnityWebRequest.Result.Success)
|
||||
{
|
||||
Debug.Log("Error: " + request.error);
|
||||
UIka.RequestButton.SetEnabled(true);
|
||||
UIka.forcodes.visible = true;
|
||||
UIka.forcodes.text = "Â äàííûé ìîìåíò ñåðâèñ âðåìåííî íåäîñòóïåí.";
|
||||
UIka.loadimg.visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Received: " + request.downloadHandler.text);
|
||||
var MethodJSON = JsonConvert.DeserializeObject<MethodJSON>(request.downloadHandler.text);
|
||||
try
|
||||
{
|
||||
foreach (Item x in MethodJSON.respose.items) //Ïàðñèíã äàííûõ
|
||||
{
|
||||
LocationsMO.Add(new Vector3(x.x_mo, x.z_mo, x.y_mo));
|
||||
LocationsRTLS.Add(new Vector3(x.x, x.z, x.y));
|
||||
Time.Add(x.time.ToLocalTime().ToString());
|
||||
if (x.block_names_aliases.Count > 1)
|
||||
{
|
||||
BlockNamesAliases.Add(x.block_names_aliases[0] + " " + x.block_names_aliases[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
BlockNamesAliases.Add(x.block_names_aliases[0]);
|
||||
}
|
||||
UIka.SetResponseCode(request.responseCode.ToString());
|
||||
}
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
Debug.Log("ItemsNull");
|
||||
UIka.loadimg.visible = false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
foreach (MarksTime y in MethodJSON.respose.marks_time)
|
||||
{
|
||||
MarksTime.Add(y.name + "!" + y.count_seconds);
|
||||
}
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
Debug.Log("MarksTimeNull");
|
||||
UIka.loadimg.visible = false;
|
||||
}
|
||||
|
||||
|
||||
if (LocationsMO.Count > 1)
|
||||
{
|
||||
Debug.Log("No problemo");
|
||||
UIka.SetResponseCode(request.responseCode.ToString()); //Óñòàíîâêà êîäà
|
||||
UI.visualTreeAsset = GameUIPrefab; //Óñòàíîâêà ýêðàíà äëÿ ïåðåìåùåíèÿ
|
||||
Personchikn.InitMePlease(); //Âûçîâ èíèöèàëèçàöèÿ â ÈÈ
|
||||
Debug.Log("Got data, here go");
|
||||
}
|
||||
else
|
||||
{
|
||||
UIka.RequestButton.SetEnabled(true);
|
||||
UIka.forcodes.visible = true;
|
||||
UIka.forcodes.text = "Â äàííûõ îáíàðóæåíà îøèáêà.";
|
||||
UIka.forcodes.text = MethodJSON.error;
|
||||
UIka.loadimg.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
11
ThanksStASSForTheNiceMethod.cs.meta
Normal file
11
ThanksStASSForTheNiceMethod.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6700525e4ea8a824da74d1ea89d4dec9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
173
Uiika.cs
Normal file
173
Uiika.cs
Normal file
@ -0,0 +1,173 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using System;
|
||||
using UnityEngine.Analytics;
|
||||
using Unity.Services.Core;
|
||||
using Unity.Services.Analytics;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public class Uiika : MonoBehaviour
|
||||
{
|
||||
[Header("UIDocument")]
|
||||
public UIDocument UI;
|
||||
public VisualTreeAsset tabletemplate;
|
||||
[Header("Parser")]
|
||||
public ThanksStASSForTheNiceMethod Caller;
|
||||
public Button RequestButton; // UI êîìïîíåíòû -->
|
||||
public TextField datebegin;
|
||||
public TextField dateend;
|
||||
public TextField timebegin;
|
||||
public TextField timeend;
|
||||
public TextField SerialNumber;
|
||||
public IMGUIContainer loadimg;
|
||||
public DropdownField SerialNumberDrop;
|
||||
public Label forcodes; // <-- UI êîìïîíåíòû
|
||||
|
||||
public DateTime DatBegin;
|
||||
public DateTime DatEnd;
|
||||
public TimeSpan TimeBegin;
|
||||
public TimeSpan TimeEnd;
|
||||
public string SerialNumberStr;
|
||||
|
||||
|
||||
// Start is called before the first frame update
|
||||
public async void Start()
|
||||
{
|
||||
var root = UI.rootVisualElement;
|
||||
loadimg = root.Q<IMGUIContainer>("loadimg");
|
||||
forcodes = root.Q<Label>("forcodes");
|
||||
datebegin = root.Q<TextField>("datebegin");
|
||||
dateend = root.Q<TextField>("dateend");
|
||||
timebegin = root.Q<TextField>("timebegin");
|
||||
timeend = root.Q<TextField>("timeend");
|
||||
SerialNumber = root.Q<TextField>("tagsn");
|
||||
SerialNumberDrop = root.Q<DropdownField>("SerialNumberDrop");
|
||||
RequestButton = root.Q<Button>("RequestButton");
|
||||
RequestButton.clicked += RequestButtonPressed; //Áèíä êíîïêè RequestButton
|
||||
|
||||
|
||||
await InitializeUnityServices();
|
||||
|
||||
// Íà÷àëî ñáîðà äàííûõ
|
||||
StartDataCollection();
|
||||
// Îòïðàâêà ñîáûòèÿ 'gameStarted'
|
||||
Analytics.CustomEvent("gameStarted", new Dictionary<string, object>
|
||||
{
|
||||
{ "level", 1 }, // Óðîâåíü, íà êîòîðîì íà÷èíàåòñÿ èãðà
|
||||
{ "player_name", "Player1" } // Èìÿ èãðîêà (ìîæíî çàìåíèòü íà ðåàëüíîå èìÿ èãðîêà)
|
||||
});
|
||||
|
||||
Debug.Log("Event 'gameStarted' sent to Unity Analytics.");
|
||||
}
|
||||
|
||||
private async Task InitializeUnityServices()
|
||||
{
|
||||
try
|
||||
{
|
||||
await UnityServices.InitializeAsync();
|
||||
Debug.Log("Unity Services initialized successfully.");
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError($"Failed to initialize Unity Services: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void StartDataCollection()
|
||||
{
|
||||
try
|
||||
{
|
||||
AnalyticsService.Instance.StartDataCollection();
|
||||
Debug.Log("Data collection started.");
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError($"Failed to start data collection: {e.Message}");
|
||||
}
|
||||
}
|
||||
public void Remember()
|
||||
{
|
||||
datebegin.value = string.Format("{0:dd.MM.yyyy}", DatBegin);
|
||||
dateend.value = string.Format("{0:dd.MM.yyyy}", DatEnd);
|
||||
timebegin.value = string.Format("{0:hh\\:mm\\:ss}", TimeBegin);
|
||||
timeend.value = string.Format("{0:hh\\:mm\\:ss}", TimeEnd);
|
||||
SerialNumber.value = SerialNumberStr;
|
||||
|
||||
}
|
||||
|
||||
static string MakeUrl(DateTime dDateBegin,
|
||||
DateTime dDateEnd,
|
||||
TimeSpan dTimeBegin,
|
||||
TimeSpan dTimeEnd, string tagSerialNumber)
|
||||
{
|
||||
const string sheme = "http";
|
||||
const string host = "10.21.0.167";//"192.168.0.110" ""localhost"" "192.168.10.3" "10.21.0.167";
|
||||
const string port = "8001";//"8008";
|
||||
const string method = "api/v2/service/get_tag_log_mo/?method=GetTagLogMo";
|
||||
string returnValue =
|
||||
$"{sheme}://{host}:{port}/{method}"
|
||||
+ $"&date_start={string.Format("{0:yyyy-MM-dd}", dDateBegin)}%20{string.Format("{0:hh\\:mm\\:ss}", dTimeBegin)}"
|
||||
+ $"&date_end={string.Format("{0:yyyy-MM-dd}", dDateEnd)}%20{string.Format("{0:hh\\:mm\\:ss}", dTimeEnd)}"
|
||||
+ $"&tag={tagSerialNumber}";
|
||||
|
||||
Debug.Log(returnValue);
|
||||
return returnValue;
|
||||
}
|
||||
void RequestButtonPressed()
|
||||
{
|
||||
DateTime dDateBegin;
|
||||
DateTime dDateEnd;
|
||||
TimeSpan dTimeBegin;
|
||||
TimeSpan dTimeEnd;
|
||||
|
||||
RequestButton.SetEnabled(false); //Îòêëþ÷åíèå êíîïêè RequestButton, äëÿ èçáåæàíèÿ ïîâòîðíûõ äàííûõ
|
||||
forcodes.visible = false;
|
||||
Caller.ClearList();
|
||||
Debug.Log(datebegin.text + " " + dateend.text + " " + timebegin.text + " " + timeend.text);
|
||||
if (DateTime.TryParse(datebegin.text, out dDateBegin) && DateTime.TryParse(dateend.text, out dDateEnd) && TimeSpan.TryParse(timebegin.text, out dTimeBegin) && TimeSpan.TryParse(timeend.text, out dTimeEnd))
|
||||
{
|
||||
DatBegin = dDateBegin;
|
||||
DatEnd = dDateEnd;
|
||||
TimeBegin = dTimeBegin;
|
||||
TimeEnd = dTimeEnd;
|
||||
SerialNumberStr = SerialNumber.text;
|
||||
Caller.URL = MakeUrl(DatBegin, DatEnd, TimeBegin, TimeEnd, SerialNumberStr);
|
||||
Caller.Request();
|
||||
Debug.Log("Inputs fields OK");
|
||||
loadimg.visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
RequestButton.SetEnabled(true);
|
||||
Debug.Log("Input fields no OK");
|
||||
forcodes.visible = true;
|
||||
forcodes.text = "Â äàííûõ îáíàðóæåíà îøèáêà.";
|
||||
loadimg.visible = false;
|
||||
}
|
||||
|
||||
}
|
||||
public void SetResponseCode(string Code)
|
||||
{
|
||||
|
||||
forcodes.text = "Îòâåò íà çàïðîñ: " + Code;
|
||||
}
|
||||
public void MakeTable()
|
||||
{
|
||||
foreach(string x in Caller.MarksTime)
|
||||
{
|
||||
TemplateContainer itemTableContainer = tabletemplate.Instantiate();
|
||||
UI.rootVisualElement.Q<ScrollView>("TableBox2").Add(itemTableContainer);
|
||||
string[] strArray = x.Split("!");
|
||||
int second = int.Parse(strArray[1]);
|
||||
TimeSpan timeSpan = TimeSpan.FromSeconds(second);
|
||||
|
||||
itemTableContainer.Q<Label>("MarkTimeSec").text = string.Format("{0:D2}:{1:D2}:{2:D2}ñ", timeSpan.Hours,timeSpan.Minutes,timeSpan.Seconds);
|
||||
itemTableContainer.Q<Label>("MarkOtmetka").text = strArray[0];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
11
Uiika.cs.meta
Normal file
11
Uiika.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c7a631c3475ac364db7d92b84d7fcbaa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
x
Reference in New Issue
Block a user