CustomManager.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using GameFramework.Event;
  5. using UnityEngine;
  6. using HumanoidEditor;
  7. namespace MetaClient
  8. {
  9. public class CustomManager : MonoBehaviour
  10. {
  11. public static CustomManager Instance;
  12. public RoleCustomData bodyData;
  13. public const float valueFloating = 1f;
  14. public CustomRoleController testPlayer = null;
  15. private void Awake()
  16. {
  17. Instance = this;
  18. }
  19. public void Init()
  20. {
  21. GameEntry.Event.Subscribe(CustomRoleBodyEventArgs.EventId, UpdateBody);
  22. bodyData = new RoleCustomData();
  23. for (int i = 0; i < 6; i++)
  24. {
  25. bodyData.bodyList.Add(i, new PartData((EditableBodyPart)i, ModifyType.LengthWidthThick));
  26. }
  27. //CustomRoleUtility.ShowFile();
  28. testPlayer = GameObject.Find("biaozhunnv").GetComponent<CustomRoleController>();
  29. }
  30. public void Clear()
  31. {
  32. GameEntry.Event.Unsubscribe(CustomRoleBodyEventArgs.EventId, UpdateBody);
  33. }
  34. private void UpdateBody(object sender, GameEventArgs e)
  35. {
  36. CustomRoleBodyEventArgs crf = (CustomRoleBodyEventArgs)e;
  37. if (crf != null)
  38. {
  39. bodyData.bodyList[(int)crf.Part].floatValue = 1 + (crf.ChangeValue.x - 0.5f) * valueFloating;
  40. if (testPlayer != null)
  41. {
  42. testPlayer.UpdateBoneScale(crf.Part, bodyData.bodyList[(int)crf.Part].floatValue);
  43. }
  44. }
  45. }
  46. public float GetBodyBoneValue(EditableBodyPart part)
  47. {
  48. return 0.5f + (bodyData.bodyList[(int)part].floatValue - 1) / valueFloating;
  49. }
  50. }
  51. }