chip-game/Assets/Scenes/StandTester.cs

68 lines
1.7 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEditor.Experimental.GraphView;
using UnityEngine;
public class StandTester : MonoBehaviour
{
int h;
bool initialized = false;
void Start()
{
PrizeStandController.InitializationComplete += PrizeStandController_InitializationComplete;
PrizeStandController.OpeningFinished += PrizeStandController_OpeningFinished;
ComNativeWrapper.Serial_CloseAll();
h = ComNativeWrapper.Serial_Open("COM3", 115200, 8, 0, 1, 4, 10);
Debug.Log(h);
PrizeStandController.Initialize(h, 5, null);
}
private void OnDisable()
{
ComNativeWrapper.Serial_CloseAll();
}
private void PrizeStandController_InitializationComplete(bool arg1, string arg2)
{
if (arg1)
{
initialized = true;
}
Debug.Log($"Èíèöèàëèçàöèÿ. Result {arg1}; Message {arg2}");
}
private void PrizeStandController_OpeningFinished(bool arg1, string arg2)
{
Debug.Log($"Îòêðûòèå. Result {arg1}; Message {arg2}");
}
void Update()
{
if (!initialized) return;
if (Input.GetKeyDown(KeyCode.Alpha0))
{
}
if (Input.GetKeyDown(KeyCode.Alpha1))
{
Debug.Log("=====Îòêðûòü 1=====");
_ = PrizeStandController.OpenBoxAsync(1);
}
if (Input.GetKeyDown(KeyCode.Alpha2))
{
Debug.Log("=====Îòêðûòü 2=====");
_ = PrizeStandController.OpenBoxAsync(2);
}
if (Input.GetKeyDown(KeyCode.Alpha3))
{
Debug.Log("=====Îòêðûòü 3=====");
_ = PrizeStandController.OpenBoxAsync(3);
}
}
}