77 lines
1.6 KiB
C#
77 lines
1.6 KiB
C#
using AibisDream;
|
|
using UnityEngine;
|
|
using System;
|
|
|
|
public class Socket : MonoBehaviour, ISocket
|
|
{
|
|
public bool IsAvailable { get; set; } = true;
|
|
public Vector2 InsertionPoint => transform.position;
|
|
private Plug plug = null;
|
|
private YarnOption _option;
|
|
private bool waitYarnCommand = false;
|
|
|
|
// private int heatNum=0;
|
|
|
|
// public int HeatNum()
|
|
// {
|
|
// return heatNum;
|
|
// }
|
|
|
|
public bool WaitYarnCommand
|
|
{
|
|
get { return waitYarnCommand; }
|
|
}
|
|
|
|
public bool notAlowedDeep = false;
|
|
[HideInInspector] public TargetPointData targetData; // 新增属性
|
|
|
|
|
|
public YarnOption Option
|
|
{
|
|
set => _option = value;
|
|
}
|
|
|
|
|
|
public void Start()
|
|
{
|
|
targetData = transform.GetComponent<TargetPointData>();
|
|
}
|
|
|
|
public void Update()
|
|
{
|
|
if (plug != null)
|
|
{
|
|
plug.transform.position = transform.position;
|
|
}
|
|
}
|
|
|
|
public void InsertPlug(Plug p)
|
|
{
|
|
if (IsAvailable)
|
|
{
|
|
IsAvailable = false;
|
|
}
|
|
|
|
AudioManager.RandomPlayInteraction("plug_in");
|
|
plug = p;
|
|
plug.CableRef.End = plug.transform;
|
|
// 可插入就可以触发对话
|
|
}
|
|
|
|
public void RemovePlug(Plug p)
|
|
{
|
|
IsAvailable = true;
|
|
AudioManager.RandomPlayInteraction("plug_out");
|
|
if (plug != null)
|
|
{
|
|
plug.CableRef.End = plug.transform.GetChild(0).transform;
|
|
plug.currentSocket = null;
|
|
plug = null;
|
|
}
|
|
}
|
|
|
|
public Vector2 GetPosition()
|
|
{
|
|
return transform.position;
|
|
}
|
|
} |