123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using GameFramework.Event;
- using UnityEngine.UI;
- using RootMotion.FinalIK;
- using System.Linq;
- namespace MetaClient
- {
- public class AniManager : MonoBehaviour
- {
- public static AniManager Instance;
- public Dictionary<string, List<BonePicTarget>> aniBPT = new Dictionary<string, List<BonePicTarget>>();
- public Dictionary<string, List<BoneData>> bonedata = new Dictionary<string, List<BoneData>>();
- public EIKPickOnButtonStyple eIKPickOnButtonStyple = EIKPickOnButtonStyple.None;
- public CCDIK cCDIK = null;
- public float dis = 0.5f;
- public Transform picParent;
- public List<Transform> bones = new List<Transform>();
- public List<BonePicTarget> chooseImage = new List<BonePicTarget>();
- public List<BonePicTarget> bonePicTarget = new List<BonePicTarget>();
- private int nowtime = 0;
- public string nowAniName = "8";
- //private
- // Start is called before the first frame update
- //public Dictionary<string,>
- void Start()
- {
-
- bones.ForEach(i =>
- {
- Vector3 worldPos = i.position;
- Vector3 screenPos = Camera.main.WorldToScreenPoint(worldPos);
- GameObject imgObj = new GameObject();
- GameObject target = new GameObject();
- target.transform.position = i.position;
- var image = imgObj.AddComponent<Image>();
- image.color = Color.red;
- //if (aniBPT.ContainsKey(i.name)||i.name=="8")
- //{
- // i.name = "All";
- //}
- //else
- //{
- imgObj.name = i.name;
- //}
- imgObj.transform.position = screenPos;
- imgObj.transform.SetParent(picParent);
- imgObj.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
- BonePicTarget _bonePicTarget = new BonePicTarget(i, imgObj.transform, target.transform);
- bonePicTarget.Add(_bonePicTarget);
- AniPickOnImage pickOnImage = imgObj.AddComponent<AniPickOnImage>();
- pickOnImage.bonePicTarget = _bonePicTarget;
- pickOnImage.bonePicture = this;
- //BoneRotateByTime boneRotateByTime = i.gameObject.AddComponent<BoneRotateByTime>();
- // boneRotateByTimes.Add(boneRotateByTime);
- });
- }
- private void Awake()
- {
- Instance = this;
- }
- public void Init()
- {
- GameEntry.Event.Subscribe(AniEventArgs.EventId, UpdateAni);
- }
- public void SaveMove(string boneName)
- {
-
- }
- private void UpdateAni(object sender, GameEventArgs e)
- {
- AniEventArgs crf = (AniEventArgs)e;
- if (crf != null)
- {
- switch (crf.Type)
- {
- case EAniEventArgsType.None:
- break;
- case EAniEventArgsType.RotateX:
- break;
- case EAniEventArgsType.RotateY:
- break;
- case EAniEventArgsType.Move:
- break;
- case EAniEventArgsType.PlayKTime:
- break;
- case EAniEventArgsType.MoveKTime:
- break;
- case EAniEventArgsType.CopyKTime:
- break;
- case EAniEventArgsType.DelectKTime:
- break;
- }
- }
- }
- public void SavePart(EAniBodyPart eAniBodyPart,int time)
- {
- switch (eAniBodyPart)
- {
- case EAniBodyPart.None:
- break;
- case EAniBodyPart.Head:
- break;
- case EAniBodyPart.Node:
-
- break;
- case EAniBodyPart.Xiong:
- break;
- case EAniBodyPart.Yao:
- break;
- case EAniBodyPart.FuBu:
- break;
- case EAniBodyPart.LefftHand:
- break;
- case EAniBodyPart.RightHand:
- break;
- case EAniBodyPart.LeftArm:
- break;
- case EAniBodyPart.RightArm:
- break;
- case EAniBodyPart.LeftLeg:
- break;
- case EAniBodyPart.RightLeg:
- break;
- case EAniBodyPart.All:
- break;
- }
- }
- public void Clear() {
- GameEntry.Event.Unsubscribe(AniEventArgs.EventId, UpdateAni);
- }
- // Update is called once per frame
- void Update()
- {
- }
- }
- public class BonePicTarget
- {
- public Transform bone;
- public Transform pic;
- public Transform target;
- public BonePicTarget(Transform _bone, Transform _pic, Transform _target)
- {
- bone = _bone;
- pic = _pic;
- target = _target;
- }
- }
- public enum EIKPickOnButtonStyple
- {
- None,
- Choose,
- Rotate,
- Move
- }
- public enum EAniBodyPart {
- None,
- Head,
- Node,
- Xiong,
- Yao,
- FuBu,
- LeftArm,
- RightArm,
- LefftHand,
- RightHand,
- LeftLeg,
- RightLeg,
- All,
- }
- public class BoneData {
- public string Name;
- public Dictionary<int, Quaternion> Ro;
- public Dictionary<int, Vector3> Pos;
- }
- }
|