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.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 FindIActiveSkill(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.Robot:
  63. this.occupation = new Robot();
  64. break;
  65. case CharacterType.Teacher:
  66. this.occupation = new Teacher();
  67. break;
  68. case CharacterType.Klee:
  69. this.occupation = new Klee();
  70. break;
  71. case CharacterType.StraightAStudent:
  72. this.occupation = new StraightAStudent();
  73. break;
  74. case CharacterType.ANoisyPerson:
  75. this.occupation = new ANoisyPerson();
  76. break;
  77. case CharacterType.TechOtaku:
  78. this.occupation = new TechOtaku();
  79. break;
  80. case CharacterType.Athlete:
  81. default:
  82. this.occupation = new Athlete();
  83. break;
  84. }
  85. this.MaxHp = this.hp = Occupation.MaxHp;
  86. this.OrgMoveSpeed = this.moveSpeed = Occupation.MoveSpeed;
  87. this.BulletOfPlayer = this.OriBulletOfPlayer = Occupation.InitBullet;
  88. this.concealment = Occupation.Concealment;
  89. this.alertnessRadius = Occupation.AlertnessRadius;
  90. this.ViewRange = Occupation.ViewRange;
  91. this.characterType = characterType;
  92. this.SpeedOfOpeningOrLocking = Occupation.TimeOfOpeningOrLocking;
  93. this.SpeedOfClimbingThroughWindows = Occupation.SpeedOfClimbingThroughWindows;
  94. this.SpeedOfOpenChest = Occupation.SpeedOfOpenChest;
  95. foreach (var activeSkill in this.Occupation.ListOfIActiveSkill)
  96. {
  97. this.TimeUntilActiveSkillAvailable.Add(activeSkill, 0);
  98. this.IActiveSkillDictionary.Add(activeSkill, SkillFactory.FindIActiveSkill(activeSkill));
  99. }
  100. // UsePassiveSkill(); //创建player时开始被动技能,这一过程也可以放到gamestart时进行
  101. // 这可以放在AddPlayer中做
  102. Debugger.Output(this, "constructed!");
  103. }
  104. }
  105. }