using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public enum EUnitBone { Hips = 0, // 盆骨 Spine , // 脊柱 Chest , // 胸腔 UpperChest , // Neck , Head , LEye , REye , Jaw , LShoulder = 20, LUpperArm, LLowerArm, LHand, LFinger00, LFinger01, LFinger02, LFinger10, LFinger11, LFinger12, LFinger20, LFinger21, LFinger22, LFinger30, LFinger31, LFinger32, LFinger40, LFinger41, LFinger42, RShoulder = 40, RUpperArm, RLowerArm, RHand, RFinger00, RFinger01, RFinger02, RFinger10, RFinger11, RFinger12, RFinger20, RFinger21, RFinger22, RFinger30, RFinger31, RFinger32, RFinger40, RFinger41, RFinger42, LUpperLeg = 60, // 大腿 LLowerLeg, // 小腿肚 LFoot, // 左脚 LToes, // 脚趾 //LToe0, // 脚趾0 //LToe1, // 脚趾1 //LToe2, // 脚趾2 //LToe3, // 脚趾3 //LToe4, // 脚趾4 RUpperLeg = 80, // 大腿 RLowerLeg, // 小腿肚 RFoot, // 左脚 RToes, // 脚趾 //RToe0, // 脚趾0 //RToe1, // 脚趾1 //RToe2, // 脚趾2 //RToe3, // 脚趾3 //RToe4, // 脚趾4 } [Serializable] public class UnitBoneDictionary : SerializableDictionary { } public enum EUnitReferencePoint { None = 0, Gunpoint = 1, // 枪口 Gunpoint2, // 枪口 SwordTop = 20, // 剑尖端 SwordBottom, // 剑底端 HitpointHead = 40, HitpointHeadFront, HitpointHeadBack, HitpointNeck, HitpointUpperBody, HitpointUpperBodyFront, HitpointUpperBodyBack, HitpointLowerBody, HitpointLowerBodyFront, HitpointLowerBodyBack, GrabpointChest = 60, // 被抓取的时候的挂点 GrabpointHead, GrabpointLeg, } [Serializable] public class UnitReferencePointDictionary : SerializableDictionary { } // 角色的prefab附加数据 // * afterimage的prefab // * 骨骼映射 // * 武器 [DisallowMultipleComponent] public class UnitDetail : MonoBehaviour { public bool showGizmos; [Tooltip("残影用的prefab")] public string afterImageAvatarPath; public UnitBoneDictionary bones; public UnitReferencePointDictionary referencePoints; //public Vector2 snapshotBound; public float snapshotBound; private SkinnedMeshRenderer m_meshRenderer; public SkinnedMeshRenderer meshRenderer { get { if (!m_meshRenderer) m_meshRenderer = this.gameObject.GetComponentInChildren(); return m_meshRenderer; } } public Vector3 center { get { return meshRenderer.bounds.center; } } public UnitDetail() { bones = new UnitBoneDictionary(); foreach(EUnitBone e in Enum.GetValues(typeof(EUnitBone))) { bones.Add(e, null); } } public Transform GetBone(EUnitBone bone) { if (bones.ContainsKey(bone)) return bones[bone]; return null; } public bool HasBone(EUnitBone bone) { return bones.ContainsKey(bone); } private void OnDrawGizmos() { if (!showGizmos) return; Gizmos.DrawWireCube(center, new Vector3(snapshotBound, snapshotBound, 0)); } }