smart-interactive-display/Assets/GadGame/Scripts/MainFlow.cs

60 lines
2.0 KiB
C#
Raw Normal View History

using GadGame.Manager;
2024-04-11 01:55:35 -07:00
using GadGame.SO;
using GadGame.State;
2024-04-15 04:10:00 -07:00
using GadGame.State.MainFlowState;
2024-05-24 01:16:15 -07:00
using GadGame.Network;
2024-06-18 23:34:19 -07:00
using UnityEngine;
2024-06-19 02:32:17 -07:00
using System.Net.NetworkInformation;
using GadGame.Event.Type;
2024-04-11 01:55:35 -07:00
2024-04-15 04:10:00 -07:00
namespace GadGame
2024-04-11 01:55:35 -07:00
{
2024-06-19 02:32:17 -07:00
public class MainFlow : StateRunner<MainFlow>
2024-04-11 01:55:35 -07:00
{
public SceneFlowConfig SceneFlowConfig;
2024-06-19 02:32:17 -07:00
public VoidEvent ScanSuccess;
2024-06-19 04:29:32 -07:00
public VoidEvent EngageReady;
2024-06-19 02:32:17 -07:00
public BoolEvent PlayPassByAnim;
public BoolEvent PlayVideo;
public FloatEvent ReadyCountDown;
2024-06-21 01:20:01 -07:00
public StringEvent GenerateImageSuccess;
2024-06-19 20:25:06 -07:00
public StringEvent EncodeImage;
2024-04-11 01:55:35 -07:00
2024-05-24 01:16:15 -07:00
protected override async void Awake()
2024-04-11 01:55:35 -07:00
{
base.Awake();
DontDestroyOnLoad(gameObject);
}
2024-04-25 04:54:33 -07:00
private async void Start()
2024-04-11 01:55:35 -07:00
{
2024-06-27 01:08:10 -07:00
string _macAddress = GetMacAddressString();
Debug.Log(_macAddress);
await P4PGraphqlManager.Instance.LoginMachine(_macAddress);
2024-04-25 04:54:33 -07:00
await LoadSceneManager.Instance.LoadSceneWithTransitionAsync(SceneFlowConfig.PassByScene.ScenePath);
2024-04-15 04:10:00 -07:00
SetState<IdleState>();
2024-04-11 01:55:35 -07:00
}
2024-06-19 02:32:17 -07:00
2024-06-18 23:34:19 -07:00
private string GetMacAddressString()
{
NetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface networkInterface in networkInterfaces)
{
// Filter out loopback and virtual interfaces
if (networkInterface.NetworkInterfaceType != NetworkInterfaceType.Ethernet &&
networkInterface.NetworkInterfaceType != NetworkInterfaceType.Wireless80211)
continue;
PhysicalAddress physicalAddress = networkInterface.GetPhysicalAddress();
byte[] bytes = physicalAddress.GetAddressBytes();
string macAddress = "";
for (int i = 0; i < bytes.Length; i++)
{
macAddress += bytes[i].ToString("X2");
}
return macAddress;
}
return "";
}
2024-04-11 01:55:35 -07:00
}
}