chip-gameV3/Assets/Scripts/Bootstrap.cs
sega f32d7dd69b Как вот это вот описать...
Было очень много экстренных ситуаций.
И по мне стреляли, и я упал в лужу нахуй блять, и лежал нахуй
2026-07-29 15:05:01 +03:00

129 lines
4.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using PrizeSystem;
using System.Text;
using UnityEngine;
using static UnityEngine.Rendering.DebugUI.Table;
public class Bootstrap : MonoBehaviour
{
private const int DEFAULT_FRAME_RATE = 60;
[SerializeField] private SoundManager soundManager;
[SerializeField] private Board board;
[SerializeField] private NotificationSystem notificationSystem;
[SerializeField] private In inputSystem;
[SerializeField] private PrizeSystemManager prizeSystem;
[SerializeField] private VideoUtility videoUtility;
[SerializeField] private VitrinaCatcher vitrinaCatcher;
[SerializeField] private DualAvatarController avatarController;
[SerializeField] private GameManager gameManager;
private void Awake() => Initialize();
private void Initialize()
{
Application.targetFrameRate = DEFAULT_FRAME_RATE;
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
SettingsManager.Initialize();
soundManager.Initialize();
ConfigManager.Initialize();
UnityMainThreadDispatcher.Initialize();
InitializePrefs();
InitializeDevices();
PaymentSystem.Initialize();
notificationSystem.Initialize();
vitrinaCatcher.Initialize();
inputSystem.Initialize();
prizeSystem.Initialize();
videoUtility.Initialize();
#if !UNITY_EDITOR
Defender.Instance.StartCoroutine(Defender.Instance.CheckLicenseCoroutine());
#endif
DifficultyManager.Instance.dummyBots = false;
//todo: сагрегировать эти объекты
avatarController.GetComponent<AvatarEventBus>().Initialize();
avatarController.Initialize();
gameManager.Initialize();
board.Init();
Destroy(gameObject);
}
private static void InitializePrefs()
{
PlayerPrefs.SetString("Serial", ConfigManager.Config.Serial);
if (!PlayerPrefs.HasKey("Number")) PlayerPrefs.SetString("Number", "70000000000");
if (!PlayerPrefs.HasKey("NumberTech")) PlayerPrefs.SetString("NumberTech", "<Не указано>");
}
private void InitializeDevices()
{
var sb = new StringBuilder();
//ИНИЦИАЛИЗАЦИЯ УСТРОЙСТВ
var devices = ComPortScanner.ScanPorts();
sb.AppendLine($"Найдено устройств: {devices.Count}");
foreach (var device in devices)
{
sb.Append($"{device.Key} : {device.Value}");
}
Debug.Log(sb.ToString());
bool controllerFound = false;
string vitrinaPort = null;
foreach (var device in devices)
{
//Витрина
if (device.Value == ComPortScanner.DeviceType.PrizeShowcase)
{
vitrinaPort = device.Key;
Debug.Log($"нашел витрину на порту, {vitrinaPort}");
}
else if (device.Value == ComPortScanner.DeviceType.ControllerV1)
{
if (!controllerFound)
{
Debug.Log("Нашел периферийник1 открываю.");
ComWrapper.Initialize(device.Key, boardVersion: 1);
controllerFound = true;
}
}
else if (device.Value == ComPortScanner.DeviceType.ControllerV2)
{
if (!controllerFound)
{
Debug.Log("Нашел периферийник2 открываю.");
ComWrapper.Initialize(device.Key, boardVersion: 2);
controllerFound = true;
}
}
else
{
Debug.Log($"неизвестный тип {device.Key}:{device.Value}");
}
}
if (vitrinaPort != null)
{
Debug.Log($"Витрину открываем (порт {vitrinaPort}");
int h = ComNativeWrapper.Serial_Open(vitrinaPort, 115200, 8, 0, 1, 4, 10);
if (h > 0) Debug.Log("Открыл");
else Debug.Log("Не Открыл");
PrizeStandController.Initialize(h, 5);
}
}
}