70 lines
1.9 KiB
C#
70 lines
1.9 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class CheckCurrent_wanyong : MonoBehaviour
|
|
{
|
|
public Raycast_control_wanyong raycast_Control;
|
|
// public AudioSource audioSource;
|
|
public Transform 交互点;
|
|
|
|
private Vector3 startrot;
|
|
private Vector3 startpos;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
startrot = 交互点.transform.localEulerAngles;
|
|
startpos = 交互点.transform.localPosition;
|
|
}
|
|
/// <summary>
|
|
/// 另外一只笔
|
|
/// </summary>
|
|
public CheckCurrent_wanyong otherDevice;
|
|
/// <summary>
|
|
/// 在使用且有电
|
|
/// </summary>
|
|
public bool InPlaceAndHasEle=false;
|
|
public GameObject 灯;
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (raycast_Control.hitgo != null) {
|
|
|
|
|
|
if (raycast_Control.hitgo.GetComponent<CurrentJudgment>())
|
|
{
|
|
if (raycast_Control.hitgo.GetComponent<CurrentJudgment>().是否带电 == true)
|
|
{
|
|
InPlaceAndHasEle = true;
|
|
// audioSource.gameObject.SetActive(true);
|
|
if (otherDevice.InPlaceAndHasEle)
|
|
{
|
|
灯.gameObject.SetActive(true);
|
|
}
|
|
}
|
|
|
|
交互点.transform.localEulerAngles = raycast_Control.hitgo.transform.forward;
|
|
交互点.transform.position = raycast_Control.hitInfo.point;
|
|
交互点.GetComponent<Collider>().enabled = true;
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
|
|
// audioSource.gameObject.SetActive(false);
|
|
InPlaceAndHasEle = false;
|
|
灯.gameObject.SetActive(false);
|
|
|
|
|
|
交互点.transform.localEulerAngles = startrot;
|
|
交互点.transform.localPosition = startpos;
|
|
交互点.GetComponent<Collider>().enabled = false;
|
|
}
|
|
}
|
|
}
|