108 lines
2.9 KiB
C#
108 lines
2.9 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
|
|
public class TooRoomMannger : SingletonMono<TooRoomMannger>
|
|
{
|
|
public List<BaseToolOrDevice> allTMDs;
|
|
public Transform toolParent;
|
|
public Transform headSlot;
|
|
public Transform bodySlot;
|
|
public Transform handSlot;
|
|
public Transform shoesSlot;
|
|
private List<Material> _cancel; //未穿戴材质球
|
|
private List<Material> _wear; //穿戴材质球
|
|
|
|
void Start()
|
|
{
|
|
allTMDs = toolParent.GetComponentsInChildren<BaseToolOrDevice>(true).ToList();
|
|
|
|
|
|
_cancel = new List<Material>();
|
|
_wear = new List<Material>();
|
|
_cancel = Resources.LoadAll<Material>("Materials/CharacterEquip/Cancel").ToList();
|
|
_wear = Resources.LoadAll<Material>("Materials/CharacterEquip/Wear").ToList();
|
|
|
|
foreach (var tmd in allTMDs)
|
|
{
|
|
tmd.GetInfo();
|
|
}
|
|
RemoveRepeat();
|
|
}
|
|
|
|
/// <summary>
|
|
/// /移除重复问题
|
|
/// </summary>
|
|
public void RemoveRepeat()
|
|
{
|
|
var bagDatas = GameManager.PacksackBagMgr.GetCurrentBagData();
|
|
foreach (var item in bagDatas.Values)
|
|
{
|
|
foreach (var itemI in item)
|
|
{
|
|
for (int i = 0; i < allTMDs.Count; i++)
|
|
{
|
|
int index = i;
|
|
if (itemI.selfPosInToolRoom == allTMDs[index].itemInfo.selfPosInToolRoom)
|
|
{
|
|
Destroy(allTMDs[index].gameObject);
|
|
allTMDs.Remove(allTMDs[index]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 与模型联动
|
|
/// </summary>
|
|
/// <param name="equipName"></param>
|
|
/// <param name="isChange"></param>
|
|
public void Wear(string equipName, bool isChange)
|
|
{
|
|
Material ma = null;
|
|
if (isChange)
|
|
{
|
|
ma = _wear.SingleOrDefault(s => s.name == equipName);
|
|
}
|
|
else
|
|
{
|
|
ma = _cancel.SingleOrDefault(s => s.name == equipName);
|
|
}
|
|
|
|
switch (equipName)
|
|
{
|
|
case "国网安全帽":
|
|
headSlot.GetComponent<SkinnedMeshRenderer>().material = ma;
|
|
break;
|
|
case "工作服":
|
|
bodySlot.GetComponent<SkinnedMeshRenderer>().material = ma;
|
|
break;
|
|
case "绝缘手套":
|
|
handSlot.GetComponent<SkinnedMeshRenderer>().material = ma;
|
|
break;
|
|
case "绝缘靴":
|
|
shoesSlot.GetComponent<MeshRenderer>().material = ma;
|
|
break;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 工具架工具配置
|
|
/// </summary>
|
|
//public class ToolRoomSettingData
|
|
//{
|
|
// public string objname;
|
|
// public Vector3 initPostion;
|
|
|
|
// public ToolRoomSettingData(string objname, Vector3 initPostion)
|
|
// {
|
|
// this.e_ToolOrDeviceOrMaterials = e_toolOrDeviceOrMaterials;
|
|
// this.initPostion = initPostion;
|
|
// }
|
|
//}
|