You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Character.Skill.cs 4.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using Preparation.Utility;
  2. using Preparation.Interface;
  3. using System.Collections.Generic;
  4. using System;
  5. using System.Numerics;
  6. namespace GameClass.GameObj
  7. {
  8. public partial class Character
  9. {
  10. private readonly CharacterType characterType;
  11. public CharacterType CharacterType => characterType;
  12. private readonly IOccupation occupation;
  13. public IOccupation Occupation => occupation;
  14. private Dictionary<ActiveSkillType, int> timeUntilActiveSkillAvailable = new();
  15. public Dictionary<ActiveSkillType, int> TimeUntilActiveSkillAvailable => timeUntilActiveSkillAvailable;
  16. private Dictionary<ActiveSkillType, IActiveSkill> iActiveSkillDictionary = new();
  17. public Dictionary<ActiveSkillType, IActiveSkill> IActiveSkillDictionary => iActiveSkillDictionary;
  18. public IActiveSkill UseIActiveSkill(ActiveSkillType activeSkillType)
  19. {
  20. if (Occupation.ListOfIActiveSkill.Contains(activeSkillType))
  21. {
  22. return IActiveSkillDictionary[activeSkillType];
  23. }
  24. return new NullSkill();
  25. }
  26. public bool SetTimeUntilActiveSkillAvailable(ActiveSkillType activeSkillType, int timeUntilActiveSkillAvailable)
  27. {
  28. if (TimeUntilActiveSkillAvailable.ContainsKey(activeSkillType))
  29. {
  30. lock (gameObjLock)
  31. this.timeUntilActiveSkillAvailable[activeSkillType] = (timeUntilActiveSkillAvailable > 0) ? timeUntilActiveSkillAvailable : 0;
  32. return true;
  33. }
  34. return false;
  35. }
  36. public bool AddTimeUntilActiveSkillAvailable(ActiveSkillType activeSkillType, int addTimeUntilActiveSkillAvailable)
  37. {
  38. if (TimeUntilActiveSkillAvailable.ContainsKey(activeSkillType))
  39. {
  40. lock (gameObjLock)
  41. this.timeUntilActiveSkillAvailable[activeSkillType] = (timeUntilActiveSkillAvailable[activeSkillType] + addTimeUntilActiveSkillAvailable > 0) ? timeUntilActiveSkillAvailable[activeSkillType] + addTimeUntilActiveSkillAvailable : 0;
  42. return true;
  43. }
  44. return false;
  45. }
  46. public bool IsGhost()
  47. {
  48. return GameData.IsGhost(CharacterType);
  49. }
  50. protected Character(XY initPos, int initRadius, CharacterType characterType) :
  51. base(initPos, initRadius, GameObjType.Character)
  52. {
  53. this.place = PlaceType.Null;
  54. this.CanMove = true;
  55. this.score = 0;
  56. this.buffManager = new BuffManager();
  57. switch (characterType)
  58. {
  59. case CharacterType.Assassin:
  60. this.occupation = new Assassin();
  61. break;
  62. case CharacterType.Athlete:
  63. default:
  64. this.occupation = new Athlete();
  65. break;
  66. }
  67. this.MaxHp = Occupation.MaxHp;
  68. this.hp = Occupation.MaxHp;
  69. this.OrgMoveSpeed = Occupation.MoveSpeed;
  70. this.moveSpeed = Occupation.MoveSpeed;
  71. this.OrgCD = this.cd = BulletFactory.BulletCD(Occupation.InitBullet);
  72. this.maxBulletNum = Occupation.MaxBulletNum;
  73. this.bulletNum = maxBulletNum;
  74. this.bulletOfPlayer = Occupation.InitBullet;
  75. this.OriBulletOfPlayer = Occupation.InitBullet;
  76. this.concealment = Occupation.Concealment;
  77. this.alertnessRadius = Occupation.AlertnessRadius;
  78. this.ViewRange = Occupation.ViewRange;
  79. this.characterType = characterType;
  80. this.SpeedOfOpeningOrLocking = Occupation.TimeOfOpeningOrLocking;
  81. this.SpeedOfClimbingThroughWindows = Occupation.SpeedOfClimbingThroughWindows;
  82. this.SpeedOfOpenChest = Occupation.TimeOfOpenChest;
  83. foreach (var activeSkill in this.Occupation.ListOfIActiveSkill)
  84. {
  85. this.TimeUntilActiveSkillAvailable.Add(activeSkill, 0);
  86. this.IActiveSkillDictionary.Add(activeSkill, SkillFactory.FindIActiveSkill(activeSkill));
  87. }
  88. // UsePassiveSkill(); //创建player时开始被动技能,这一过程也可以放到gamestart时进行
  89. // 这可以放在AddPlayer中做
  90. Debugger.Output(this, "constructed!");
  91. }
  92. }
  93. }