54 lines
1.3 KiB
C#
54 lines
1.3 KiB
C#
|
using Interactive;
|
||
|
using Laptop.States;
|
||
|
using Mirror;
|
||
|
using UnityEngine;
|
||
|
using StateMachine;
|
||
|
|
||
|
namespace Laptop
|
||
|
{
|
||
|
public class StartGameButton : NetworkBehaviour, IInteractable
|
||
|
{
|
||
|
private CustomNetworkManager _networkManager;
|
||
|
public Animator Animator;
|
||
|
public readonly StateMachine<LaptopStates> StateMachine = new();
|
||
|
public bool isLooking = false;
|
||
|
public GameObject canvas;
|
||
|
|
||
|
void Start()
|
||
|
{
|
||
|
_networkManager = NetworkManager.singleton.GetComponent<CustomNetworkManager>();
|
||
|
// if (_networkManager.GamePlayers.Count > 0)
|
||
|
// {
|
||
|
// gameObject.SetActive(false);
|
||
|
// }
|
||
|
|
||
|
StateMachine.Add(new Open(this));
|
||
|
StateMachine.Add(new Close(this));
|
||
|
|
||
|
StateMachine.SetCurrentState(LaptopStates.Close);
|
||
|
}
|
||
|
|
||
|
|
||
|
public void Interact()
|
||
|
{
|
||
|
StartGame();
|
||
|
}
|
||
|
|
||
|
public void LookAt()
|
||
|
{
|
||
|
StateMachine.SetCurrentState(LaptopStates.Open);
|
||
|
}
|
||
|
|
||
|
public void LookOut()
|
||
|
{
|
||
|
StateMachine.SetCurrentState(LaptopStates.Close);
|
||
|
}
|
||
|
|
||
|
[Command(requiresAuthority = false)]
|
||
|
void StartGame()
|
||
|
{
|
||
|
_networkManager.StartGame();
|
||
|
}
|
||
|
}
|
||
|
}
|