FCloneEvent.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Security;
  4. using UnityEngine;
  5. namespace Flux
  6. {
  7. [FEvent("Skill/策划/克隆")]
  8. public class FCloneEvent : FEvent
  9. {
  10. [HideInInspector]
  11. [SerializeField]
  12. private int _npcId;
  13. public int NpcId
  14. {
  15. get { return _npcId; }
  16. }
  17. [HideInInspector]
  18. [SerializeField]
  19. private int _npcPos;
  20. public int NpcPos
  21. {
  22. get { return _npcPos; }
  23. }
  24. [HideInInspector]
  25. [SerializeField]
  26. private int _bornEffectId;
  27. public int BornEffectId
  28. {
  29. get { return _bornEffectId; }
  30. }
  31. [HideInInspector]
  32. [SerializeField]
  33. private GameObject _bornEffectPrefab = null;
  34. public GameObject BornEffectPrefab
  35. {
  36. get { return _bornEffectPrefab; }
  37. }
  38. [HideInInspector]
  39. [SerializeField]
  40. private Vector3 _bornPos = Vector3.zero;
  41. public Vector3 BornPos
  42. {
  43. get { return _bornPos; }
  44. }
  45. [HideInInspector]
  46. [SerializeField]
  47. private Vector3 _bornRot = Vector3.zero;
  48. public Vector3 BornRot
  49. {
  50. get { return _bornRot; }
  51. }
  52. public FCloneEvent()
  53. {
  54. _eventType = SkillActionFrameEventType.FE_Clone;
  55. }
  56. protected override void OnTrigger(float timeSinceTrigger)
  57. {
  58. base.OnTrigger(timeSinceTrigger);
  59. }
  60. protected override void OnPause()
  61. {
  62. base.OnPause();
  63. }
  64. protected override void OnResume()
  65. {
  66. base.OnResume();
  67. }
  68. protected override void OnFinish()
  69. {
  70. base.OnFinish();
  71. }
  72. protected override void OnStop()
  73. {
  74. base.OnStop();
  75. }
  76. public override int GetMaxLength()
  77. {
  78. return base.GetMaxLength();
  79. }
  80. public override string Text
  81. {
  82. get { return "克隆"; }
  83. set { }
  84. }
  85. public override SecurityElement SaveToXml()
  86. {
  87. SecurityElement node = base.SaveToXml();
  88. SecurityElement paramNode = WriteParamNode("npcId", _npcId.ToString(), "int");
  89. node.AddChild(paramNode);
  90. paramNode = WriteParamNode("npcPos", _npcPos.ToString(), "int");
  91. node.AddChild(paramNode);
  92. paramNode = WriteParamNode("effect", _bornEffectId.ToString(), "int");
  93. node.AddChild(paramNode);
  94. if(_bornEffectPrefab!=null)
  95. {
  96. #if UNITY_EDITOR
  97. paramNode = WriteParamNode("effectPrefab", UnityEditor.AssetDatabase.GetAssetPath(_bornEffectPrefab), "string");
  98. node.AddChild(paramNode);
  99. #endif
  100. }
  101. paramNode = WriteParamNode("position", StringUtil.ConvertVector2Str(_bornPos), "string");
  102. node.AddChild(paramNode);
  103. paramNode = WriteParamNode("rotation", StringUtil.ConvertVector2Str(_bornRot), "string");
  104. node.AddChild(paramNode);
  105. return node;
  106. }
  107. public override void LoadFromXml(SecurityElement eventNode)
  108. {
  109. base.LoadFromXml(eventNode);
  110. _npcId = GetNParam("npcId");
  111. _npcPos = GetNParam("npcPos");
  112. _bornEffectId = GetNParam("effect");
  113. string bornEffectPath = GetSParam("effectPrefab");
  114. if (!string.IsNullOrEmpty(bornEffectPath))
  115. {
  116. #if UNITY_EDITOR
  117. _bornEffectPrefab = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>(bornEffectPath);
  118. #endif
  119. }
  120. _bornPos = GetVParam("position");
  121. _bornRot = GetVParam("rotation");
  122. }
  123. }
  124. }