120 lines
3.1 KiB
C#
120 lines
3.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using System;
|
|
|
|
public class PhysicButtonContent : MonoBehaviour
|
|
{
|
|
//public static PhysicButtonContent Instance;
|
|
|
|
public /*static*/ Action Confirm;
|
|
public /*static*/ Action PageUp;
|
|
public /*static*/ Action PageDown;
|
|
public /*static*/ Action Back;
|
|
|
|
public Paddle paddle;
|
|
public bool b_Open;
|
|
public GameObject PowerLight, CloseLigth, OpenLight;
|
|
private Material powerMat, closeMat, openMat;
|
|
|
|
public string SwitchName;
|
|
private void Awake()
|
|
{
|
|
//Instance = this;
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
powerMat = PowerLight.GetComponent<MeshRenderer>().material;
|
|
closeMat = CloseLigth.GetComponent<MeshRenderer>().material;
|
|
openMat = OpenLight.GetComponent<MeshRenderer>().material;
|
|
|
|
//³õʼ״̬
|
|
if (b_Open)
|
|
{
|
|
closeMat.EnableKeyword("_EMISSION");
|
|
openMat.DisableKeyword("_EMISSION");
|
|
}
|
|
else
|
|
{
|
|
closeMat.DisableKeyword("_EMISSION");
|
|
openMat.EnableKeyword("_EMISSION");
|
|
}
|
|
DeviceStateManage.UpdateDeviceState(new DLQ() { Name = SwitchName, Gate = b_Open });
|
|
}
|
|
|
|
public /*static*/ void OnPhysicButtonDown(PhysicButtonType _type)
|
|
{
|
|
Debug.Log("Press Button : " + _type.ToString());
|
|
switch (_type)
|
|
{
|
|
case PhysicButtonType.Confirm:
|
|
Confirm?.Invoke();
|
|
// ·¢Éä·¢ËÍÊý¾Ý
|
|
var target = Confirm.Target;
|
|
var targetType = target.GetType();
|
|
targetType.GetMethod("GetProperty").Invoke(target, null);
|
|
break;
|
|
case PhysicButtonType.PageUp:
|
|
PageUp?.Invoke();
|
|
break;
|
|
case PhysicButtonType.PageDown:
|
|
PageDown?.Invoke();
|
|
break;
|
|
case PhysicButtonType.Back:
|
|
Back?.Invoke();
|
|
break;
|
|
case PhysicButtonType.trialJump:
|
|
//ÊÔÌø
|
|
//Instance.TrialJump();
|
|
TrialJump();
|
|
break;
|
|
case PhysicButtonType.OperateSwitch:
|
|
//·ÖºÏÕ¢
|
|
//Instance.OperationSwitch();
|
|
OperationSwitch();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
void TrialJump()
|
|
{
|
|
Debug.Log("ÊÔÌø");
|
|
}
|
|
|
|
void OperationSwitch()
|
|
{
|
|
Debug.Log("·ÖºÏÕ¢");
|
|
if (paddle.isOpening) return;
|
|
if (!turn)
|
|
{
|
|
turn = true;
|
|
Invoke("Turn", 2f);
|
|
}
|
|
}
|
|
|
|
bool turn;
|
|
/// <summary>
|
|
/// ·ÖÕ¢¡¢ºÏÕ¢Ìø×ª
|
|
/// </summary>
|
|
public void Turn()
|
|
{
|
|
turn = false;
|
|
b_Open = !b_Open;
|
|
|
|
if (b_Open)
|
|
{
|
|
closeMat.EnableKeyword("_EMISSION");
|
|
openMat.DisableKeyword("_EMISSION");
|
|
}
|
|
else
|
|
{
|
|
closeMat.DisableKeyword("_EMISSION");
|
|
openMat.EnableKeyword("_EMISSION");
|
|
}
|
|
DeviceStateManage.UpdateDeviceState(new DLQ() { Name = SwitchName, Gate = b_Open });
|
|
}
|
|
}
|