using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
///
/// 家具管理
///
public class Furniture_Manager : MonoBehaviour
{
public static Furniture_Manager Instance;
///
/// 环境控制
///
public Transform Environment;
///
/// 互联
///
public Transform Interconnection;
///
/// 智能家电
///
public Transform Intelligent;
private void Awake()
{
Instance = this;
}
void Start()
{
}
void Update()
{
}
///
/// 查找家具list
///
/// 区域名称
/// 家具类型
///
public List FindHomes(string name, string type)
{
List list = new List();
switch (name)
{
case "环境":
list = FindtypeHomes(type, Environment);
break;
case "互联":
list = FindtypeHomes(type, Interconnection);
break;
case "家电":
list = FindtypeHomes(type, Intelligent);
break;
}
return list;
}
///
/// 查找对应的家具
///
/// 家具类型
/// 对应区域类型
///
private List FindtypeHomes(string type, Transform typetransform)
{
List temp = new List();
temp = typetransform.GetComponentsInChildren().ToList();
List list = new List();
for (int i = 0; i < temp.Count; i++)
{
if (type == "灯" && temp[i].typeoffurniture == Typeoffurniture.灯)
{
list.Add(temp[i].transform);
}
if (type == "空调" && temp[i].typeoffurniture == Typeoffurniture.空调)
{
list.Add(temp[i].transform);
}
if (type == "窗帘" && temp[i].typeoffurniture == Typeoffurniture.窗帘)
{
list.Add(temp[i].transform);
}
if (type == "窗户" && temp[i].typeoffurniture == Typeoffurniture.窗户)
{
list.Add(temp[i].transform);
}
if (type == "电视" && temp[i].typeoffurniture == Typeoffurniture.电视)
{
list.Add(temp[i].transform);
}
}
return list;
}
///
/// 查找家具list
///
/// 区域名称
/// 家具类型
///
public Transform FindHome(string name, string type)
{
Transform transform = null;
switch (name)
{
case "环境":
transform = FindtypeHome(type, Environment);
break;
case "互联":
transform = FindtypeHome(type, Interconnection);
break;
case "家电":
transform = FindtypeHome(type, Intelligent);
break;
}
return transform;
}
///
/// 查找对应的家具
///
/// 家具类型
/// 对应区域类型
///
private Transform FindtypeHome(string type, Transform typetransform)
{
List temp = new List();
temp = typetransform.GetComponentsInChildren().ToList();
Transform list = null;
for (int i = 0; i < temp.Count; i++)
{
if (type == "灯" && temp[i].typeoffurniture == Typeoffurniture.灯)
{
list = temp[i].transform;
}
if (type == "空调" && temp[i].typeoffurniture == Typeoffurniture.空调)
{
list = temp[i].transform;
}
if (type == "窗帘" && temp[i].typeoffurniture == Typeoffurniture.窗帘)
{
list = temp[i].transform;
}
if (type == "窗户" && temp[i].typeoffurniture == Typeoffurniture.窗户)
{
list = temp[i].transform;
}
if (type == "电视" && temp[i].typeoffurniture == Typeoffurniture.电视)
{
list = temp[i].transform;
}
}
return list;
}
}