using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using CommonDefine;
using LitJson;
using System;
public class PlayerAttribute : MonoBehaviour
{
public enum AVATAR_TYPE
{
AVATAR_TYPE_NORMAL, //不带骨骼模型
AVATAR_TYPE_WITH_BONE //带骨骼模型
}
[SerializeField]
public AVATAR_TYPE m_emType;
///
/// 一些基本变量,存放用于换装的Prefab的引用,以及索引下标,bones用来存储Skin合并后的骨骼引用,rootBone用来存储根骨骼
///
//头发
public GameObject[] Hairs;
//头饰
public GameObject[] Headgear;
//眼镜
public GameObject[] Glasess;
//套装
public GameObject[] Suit;
//衣服
public GameObject[] Clothes;
//裤子
public GameObject[] Trousers;
//袜子
public GameObject[] Stockings;
//鞋
public GameObject[] Shoes;
public GameObject m_face;
private int hairIndex = 0;
private int HeadgearIndex = 0;
private int clothesIndex = 0;
private int TrousersIndex = 0;
private int StockingsIndex = 0;
private int ShoesIndex = 0;
public string[] clothdata = new string[6];
private List
private GameObject rootBone;
#region json
//private JsonData m_data = new JsonData();
//private JsonData m_faceControlData = new JsonData();
//private JsonData m_faceData = new JsonData();
//private JsonData m_clothData = new JsonData();
//private JsonData m_decorationData = new JsonData(); //装饰数据
#endregion
private SkinnedMeshRenderer m_faceSmr;
//public void setData(JsonData data)
//{
// Debug.Log("PlayerAttribute setData " + data.ToJson());
// m_data = data;
// m_faceControlData = DataCenter.AsDataByKey(data, CommonDefine.AVATAR_Attribute.FACE_CONTROL_DATA);
// // Debug.Log("加载player:" + m_faceControlData.ToJson());
// m_faceData = DataCenter.AsDataByKey(data, CommonDefine.AVATAR_Attribute.FACE_DATA);
// m_clothData = DataCenter.AsDataByKey(data, CommonDefine.AVATAR_Attribute.CLOTH_DATA);
// m_decorationData = DataCenter.AsDataByKey(data, CommonDefine.AVATAR_Attribute.HOME_DECORATION);
// if (gameObject.transform.Find("DressSpaceCanva") != null)
// {
// Debug.Log("加载friend home 界面:" + m_decorationData.ToJson());
// GameObject space = gameObject.transform.Find("DressSpaceCanva").gameObject;
// if (space.GetComponent
// {
// space.GetComponent
// }
// }
//}
void Start()
{
Debug.Log("PlayerAttribute start");
//找到根骨的节点,此处的Bip001是3Dmax中Bip结构的默认根节点。主干部分的蒙皮导出时带有骨骼,所以可以在Prefab的子节点上找到
rootBone = gameObject.transform.Find("Bip001").gameObject;
bones = new List
if (m_face != null) {
m_faceSmr = m_face.GetComponent
}
// changeCloths();
BuildPlayer();
// changeFace();
}
//void changeCloths()
//{
// clothdata = Attribute.manData;
// string strHairId = DataCenter.AsString(m_faceData, CommonDefine.AVATAR_Attribute.AVATAR_HAIR);
// strHairId = string.IsNullOrEmpty(strHairId) ? "10017" : strHairId;
// string strHeadgearId = DataCenter.AsString(m_faceData, CommonDefine.AVATAR_Attribute.AVATAR_Headgear);
// strHeadgearId = string.IsNullOrEmpty(strHeadgearId) ? "14001" : strHeadgearId;
// string strClothId = DataCenter.AsString(m_faceData, CommonDefine.AVATAR_Attribute.AVATAR_Cloth);
// strClothId = string.IsNullOrEmpty(strClothId) ? "12007" : strClothId;
// string strPantsId = DataCenter.AsString(m_faceData, CommonDefine.AVATAR_Attribute.AVATAR_Pants);
// strPantsId = string.IsNullOrEmpty(strPantsId) ? "15002" : strPantsId;
// string strStockId = DataCenter.AsString(m_faceData, CommonDefine.AVATAR_Attribute.AVATAR_Stock);
// strStockId = string.IsNullOrEmpty(strStockId) ? "17001" : strStockId;
// string strShoeId = DataCenter.AsString(m_faceData, CommonDefine.AVATAR_Attribute.AVATAR_Shoes);
// strShoeId = string.IsNullOrEmpty(strShoeId) ? "16001" : strShoeId;
// string strSuitId = DataCenter.AsString(m_faceData, CommonDefine.AVATAR_Attribute.AVATAR_Suit);
// strSuitId = string.IsNullOrEmpty(strSuitId) ? "0" : strSuitId; //TODO:: LUXINYI
// List
// clothdata = list.ToArray();
// Debug.Log("获取到配置信息" + m_clothData.ToJson());
// ChangeAllClothes
// (Attribute.instance.getGoods(clothdata[0], AVATAR_Attribute.AVATAR_HAIR), Attribute.instance.getGoods(clothdata[1], AVATAR_Attribute.AVATAR_Headgear),
// Attribute.instance.getGoods(clothdata[2], AVATAR_Attribute.AVATAR_Cloth), Attribute.instance.getGoods(clothdata[3], AVATAR_Attribute.AVATAR_Pants),
// Attribute.instance.getGoods(clothdata[4], AVATAR_Attribute.AVATAR_Stock), Attribute.instance.getGoods(clothdata[5], AVATA