mirror of
https://github.com/DerTyp7/fps-citybuild-unity.git
synced 2025-10-30 20:47:08 +01:00
Interactable Class
This commit is contained in:
35
Assets/Scripts/LightSwitch.cs
Normal file
35
Assets/Scripts/LightSwitch.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class LightSwitch : Interactable
|
||||
{
|
||||
public Light m_Light;
|
||||
public bool isOn;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
UpdateLight();
|
||||
}
|
||||
|
||||
private void UpdateLight()
|
||||
{
|
||||
m_Light.enabled = isOn;
|
||||
}
|
||||
|
||||
public override string GetDescription()
|
||||
{
|
||||
if (isOn)
|
||||
{
|
||||
return "Press [E] to turn <color=red>off</color> the light.";
|
||||
}
|
||||
return "Press [E] to turn <color=green>on</color> the light.";
|
||||
}
|
||||
|
||||
public override void Interact()
|
||||
{
|
||||
isOn = !isOn;
|
||||
Debug.Log("Click Light");
|
||||
UpdateLight();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user