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.

128 lines
4.6 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DragCheck : MonoBehaviour
{
public string AearID = "";
[HideInInspector]
public GameObject shexiang, leida, longmenjia, chuanGanQi, ludeng;
private List<string> activeList = new List<string>();
Transform activeParent;
private void Start()
{
shexiang = transform.Find("SheXiang").gameObject;
leida= transform.Find("LeiDa").gameObject;
longmenjia = transform.Find("LongMenJia").gameObject;
chuanGanQi = transform.Find("ChuanGanQi").gameObject;
ludeng = transform.Find("LuDeng").gameObject;
if (AearID != "")
{
this.gameObject.name = "放置区_" + AearID;
}
activeParent = GameObject.Find("已放置").transform;
}
public void Show()
{
if (activeList.Count < 4)
{
this.gameObject.GetComponent<MeshRenderer>().enabled = true;
}
}
public void Hide()
{
this.gameObject.GetComponent<MeshRenderer>().enabled = false;
this.transform.Find("text").gameObject.SetActive(false);
}
public void ShowItem(ItemType itemType)
{
GameRoot.Instance.gameModeWindow.AddBushuInfo(this.AearID);
switch (itemType)
{
case ItemType.ChuanGanQi:
if (!activeList.Contains(ItemType.ChuanGanQi.ToString()))
{
chuanGanQi.SetActive(true);
chuanGanQi.transform.SetParent(activeParent);
activeList.Add(ItemType.ChuanGanQi.ToString());
GameRoot.Instance.infoWindow.AddAearInfo(this.AearID, AearInfoType.湿);
//安装提示
GameRoot.Instance.AddTipQueue("已成功部署"+this.AearID+"区域气象传感器");
}
else
{
//已存在提示
GameRoot.Instance.AddTipQueue("重复-此区域已放置气象传感器!");
}
break;
case ItemType.ZHLuDeng:
if (!activeList.Contains(ItemType.ZHLuDeng.ToString()))
{
ludeng.SetActive(true);
ludeng.transform.SetParent(activeParent);
activeList.Add(ItemType.ZHLuDeng.ToString());
GameRoot.Instance.infoWindow.AddAearInfo(this.AearID, AearInfoType.PM2_5);
//安装提示
GameRoot.Instance.AddTipQueue("已成功部署" + this.AearID + "智能路灯");
}
else
{
//已存在提示
GameRoot.Instance.AddTipQueue("重复-此区域已放置智慧路灯!");
}
break;
case ItemType.LeiDa:
if (!activeList.Contains(ItemType.LeiDa.ToString()))
{
leida.SetActive(true);
longmenjia.SetActive(true);
leida.transform.SetParent(activeParent);
longmenjia.transform.SetParent(activeParent);
activeList.Add(ItemType.LeiDa.ToString());
GameRoot.Instance.infoWindow.AddAearInfo(this.AearID, AearInfoType.);
//安装提示
GameRoot.Instance.AddTipQueue("已成功部署" + this.AearID + "雷达");
}
else
{
//已存在提示
GameRoot.Instance.AddTipQueue("重复-此区域已放置雷达!");
}
break;
case ItemType.SheXiang:
if (!activeList.Contains(ItemType.SheXiang.ToString()))
{
shexiang.SetActive(true);
longmenjia.SetActive(true);
shexiang.transform.SetParent(activeParent);
longmenjia.transform.SetParent(activeParent);
activeList.Add(ItemType.SheXiang.ToString());
GameRoot.Instance.infoWindow.AddAearInfo(this.AearID, AearInfoType.);
//安装提示
GameRoot.Instance.AddTipQueue("已成功部署" + this.AearID + "高清摄像");
}
else
{
//已存在提示
GameRoot.Instance.AddTipQueue("重复-此区域已放置高清摄像!");
}
break;
}
if (activeList.Count >= 4)
{
Hide();
}
}
}