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.

69 lines
1.6 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum TraficRoadType
{
,
leftT,
rightT,
upT,
downT,
}
public class TraficLightPut : MonoBehaviour
{
public TraficRoadType traficType = TraficRoadType.;
[HideInInspector]
public Vector3 upPoint, downPoint, leftPoint, rightPoint;
[HideInInspector]
public GridInfo gridInfo;
public void Init(Vector3 up,Vector3 down,Vector3 left,Vector3 right, TraficRoadType type, Transform parent=null)
{
upPoint = up;
downPoint = down;
leftPoint = left;
rightPoint =right;
//与放置的道路匹配碰撞与道路类型
traficType = type;
transform.position = parent.position;
transform.eulerAngles = parent.eulerAngles;
transform.SetParent(parent);
//碰撞检测
MeshRenderer meshRenderer = gameObject.AddComponent<MeshRenderer>();
MeshFilter filter = gameObject.AddComponent<MeshFilter>();
filter.mesh = parent.GetComponent<MeshFilter>().mesh;
MeshCollider collider = gameObject.AddComponent<MeshCollider>();
collider.convex = true;
collider.isTrigger = true;
meshRenderer.enabled = false;
//生成提示特效物件
}
private void OnMouseDown()
{
if (TraficLightManager.Instance.isOpenTraficPut == false) return;
TraficLightManager.Instance.ShowTraficSetPanel(traficType, this);
Debug.Log("显示类型为" + traficType + "的设置面板");
}
}