68 lines
1.1 KiB
C#
68 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class LampSwitchController : vp_Interactable
|
|
{
|
|
[SerializeField]
|
|
private List<InteractableLamp> _lamps;
|
|
|
|
[SerializeField]
|
|
private GameObject _cursorTurnLights;
|
|
|
|
public bool canInteract = true;
|
|
|
|
private bool _turnedOn = true;
|
|
|
|
private new void Start()
|
|
{
|
|
TurnOn(true);
|
|
}
|
|
|
|
public void TurnOn(bool value)
|
|
{
|
|
foreach (InteractableLamp lamp in _lamps)
|
|
{
|
|
lamp.TurnOn(value);
|
|
}
|
|
_turnedOn = value;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (UtilitiesInput.GetButtonDown("BOAT_ENTER") && TryInteract(null))
|
|
{
|
|
TurnOn(!_turnedOn);
|
|
}
|
|
}
|
|
|
|
public override void UpdateSeeing(bool isSeeing)
|
|
{
|
|
if (isSeeingMe != isSeeing)
|
|
{
|
|
_cursorTurnLights.gameObject.SetActive(isSeeing);
|
|
base.UpdateSeeing(isSeeing);
|
|
}
|
|
}
|
|
|
|
public override bool TryInteract(vp_PlayerEventHandler player)
|
|
{
|
|
if (player != null)
|
|
{
|
|
return false;
|
|
}
|
|
if (!isSeeingMe)
|
|
{
|
|
return false;
|
|
}
|
|
if (!canInteract)
|
|
{
|
|
return false;
|
|
}
|
|
if (!UtilitiesInput.GetButtonDown("BOAT_ENTER"))
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
}
|