You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.7 KiB

8 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 进度实体
/// </summary>
[RequireComponent(typeof(Collider))]
public class ProgressInstance : MonoBehaviour
{
public Progress progress;
public float lineWidth = 0.02f;
private float width;
private MaterialPropertyBlock _materialPropertyBlock;
private void Awake()
{
_materialPropertyBlock = new MaterialPropertyBlock();
GetComponent<Collider>().tag = "Action";
CloseLine();
}
public void OpenLine()
{
width = lineWidth;
GetComponent<MeshRenderer>().enabled = true;
GetComponent<BoxCollider>().enabled = true;
}
public void CloseLine()
{
width = 0;
GetComponent<MeshRenderer>().enabled = false;
GetComponent<BoxCollider>().enabled = false;
}
/// <summary>
/// 开启提示特效
/// </summary>
public void OpenTip()
{
EffectManager.Instance.EnableTipEffect(transform);
}
/// <summary>
/// 开启交互特效
/// </summary>
public void StartInteractEffect(Progress progress)
{
if (progress != this.progress)
{
UI.Instance.help.ShowError(transform.position,"组装顺序错误");
return;
}
EffectManager.Instance.EnableInteractEffect(Camera.main.WorldToScreenPoint(transform.position));
}
public void EndInteractEffect()
{
EffectManager.Instance.DisableInteractEffect();
}
private void Update()
{
_materialPropertyBlock.SetFloat("_LineWidth",width);
GetComponent<MeshRenderer>()?.SetPropertyBlock(_materialPropertyBlock);
}
}