PlayerSkillComponentSystem.cs 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. namespace ET.Server
  4. {
  5. [FriendOf(typeof (PlayerSkillComponent))]
  6. public static class PlayerSkillComponentSystem
  7. {
  8. public class PlayerSkillComponentAwakeSystem: AwakeSystem<PlayerSkillComponent>
  9. {
  10. protected override void Awake(PlayerSkillComponent self)
  11. {
  12. Log.Info($"创建玩家技能组件...");
  13. WNPlayer player = self.GetParent<WNPlayer>();
  14. self.Data = new PlayerSkillInfo();
  15. self.Data.Skills = new List<Struct.PlayerSkillBaseData>();
  16. // 初始化技能数据
  17. CharacterConfig config = CharacterConfigCategory.Instance.Get(player.GetPro());
  18. if (config != null && config.InitSkillList.Count > 0)
  19. {
  20. foreach (Struct.IntIntData intIntData in config.InitSkillList.Where(intIntData => intIntData != null))
  21. {
  22. self.Data.Skills.Add(new Struct.PlayerSkillBaseData(intIntData.value1, intIntData.value2, true, 0L));
  23. }
  24. }
  25. // 初始化战斗服缓存数据
  26. self.ToJson4BattleServerSkills = self.GetBattleServerSkills();
  27. }
  28. }
  29. public class PlayerSkillComponentDestroySystem: DestroySystem<PlayerSkillComponent>
  30. {
  31. protected override void Destroy(PlayerSkillComponent self)
  32. {
  33. }
  34. }
  35. /// <summary>
  36. /// 被动技能, 发给bs
  37. /// </summary>
  38. /// <param name="self"></param>
  39. /// <returns></returns>
  40. private static IEnumerable<Struct.SkillInfo> GetPassiveSkillInfoBS(this PlayerSkillComponent self)
  41. {
  42. List<Struct.SkillInfo> list = new List<Struct.SkillInfo>();
  43. foreach (SkillConfig prop in SkillConfigCategory.Instance.GetAll().Values.Where(prop => prop != null))
  44. {
  45. if (prop.ProId != self.GetParent<WNPlayer>().GetPro() || prop.SkillType != (int)SkillType.PLAYER_PASSIVE)
  46. {
  47. continue;
  48. }
  49. Struct.SkillInfo info = new ();
  50. info.type = prop.SkillType;
  51. info.id = prop.Id;
  52. info.level = 1;
  53. info.skillTime = 0L;
  54. info.cdTime = 0;
  55. info.flag = 0;
  56. info.autoLaunch = false;
  57. list.Add(info);
  58. }
  59. return list;
  60. }
  61. /// <summary>
  62. /// 战斗服数据
  63. /// </summary>
  64. /// <param name="self"></param>
  65. /// <returns></returns>
  66. public static List<Struct.SkillInfo> GetBattleServerSkills(this PlayerSkillComponent self)
  67. {
  68. List<Struct.SkillInfo> skills = new List<Struct.SkillInfo>();
  69. foreach (Struct.PlayerSkillBaseData skill in self.Data.Skills.Where(skill => skill != null))
  70. {
  71. if (!skill.unlock)
  72. {
  73. continue;
  74. }
  75. SkillConfig prop = SkillConfigCategory.Instance.Get(skill.id);
  76. if (prop != null && !SkillHelper.IsPassive(prop))
  77. {
  78. skills.Add(SkillHelper.NewSkillInfo(skill));
  79. }
  80. }
  81. // 被动技能战斗服信息
  82. skills.AddRange(self.GetPassiveSkillInfoBS());
  83. return skills;
  84. }
  85. }
  86. }