121 lines
3.6 KiB
C#
121 lines
3.6 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; //援渴第窐ヶ
|
||
private FirstPersonController firstPersonController;
|
||
void Start()
|
||
{
|
||
allTMDs = toolParent.GetComponentsInChildren<BaseToolOrDevice>(true).ToList();
|
||
firstPersonController = GameObject.FindGameObjectWithTag("Player").GetComponent<FirstPersonController>();
|
||
GameManager.EventMgr.AddEventListener<bool>(Enum_EventType.PlayerCanMove, SwitchFirstPersonControllerMove);
|
||
_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();
|
||
}
|
||
public void SwitchFirstPersonControllerMove(bool isMove)
|
||
{
|
||
firstPersonController.playerCanMove = isMove;
|
||
}
|
||
/// <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 "弊厙假<E58E99>簽":
|
||
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;
|
||
}
|
||
}
|
||
|
||
private void OnDestroy()
|
||
{
|
||
GameManager.EventMgr.RemoveEventListener<bool>(Enum_EventType.PlayerCanMove, SwitchFirstPersonControllerMove);
|
||
}
|
||
|
||
private void OnDisable()
|
||
{
|
||
GameManager.EventMgr.RemoveEventListener<bool>(Enum_EventType.PlayerCanMove, SwitchFirstPersonControllerMove);
|
||
}
|
||
|
||
}
|
||
|
||
/// <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;
|
||
// }
|
||
//}
|