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.SkillManager.cs 4.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. using GameClass.Skill;
  2. using Preparation.Utility;
  3. using System.Collections.Generic;
  4. using System;
  5. namespace GameClass.GameObj
  6. {
  7. public partial class Character
  8. {
  9. private delegate bool CharacterActiveSkill(Character player); // 返回值:是否成功释放了技能
  10. private delegate void CharacterPassiveSkill(Character player);
  11. private readonly CharacterActiveSkill commonSkill;
  12. private readonly ActiveSkillType commonSkillType;
  13. public ActiveSkillType CommonSkillType => commonSkillType;
  14. private readonly CharacterType characterType;
  15. public CharacterType CharacterType => characterType;
  16. public bool UseCommonSkill()
  17. {
  18. return commonSkill(this);
  19. }
  20. private int timeUntilCommonSkillAvailable = 0; // 还剩多少时间可以使用普通技能
  21. public int TimeUntilCommonSkillAvailable
  22. {
  23. get => timeUntilCommonSkillAvailable;
  24. set
  25. {
  26. lock (gameObjLock)
  27. timeUntilCommonSkillAvailable = value < 0 ? 0 : value;
  28. }
  29. }
  30. readonly CharacterPassiveSkill passiveSkill;
  31. public void UsePassiveSkill()
  32. {
  33. passiveSkill(this);
  34. return;
  35. }
  36. public bool IsGhost()
  37. {
  38. return this.characterType switch
  39. {
  40. CharacterType.Assassin => true,
  41. CharacterType.Vampire => true,
  42. CharacterType.Null => false,
  43. CharacterType.RecoverAfterBattle => false,
  44. CharacterType.SpeedUpWhenLeavingGrass => false,
  45. CharacterType.PSkill4 => false,
  46. CharacterType.PSkill5 => false,
  47. _ => false,
  48. };
  49. }
  50. public Character(XY initPos, int initRadius, PlaceType initPlace, CharacterType characterType, ActiveSkillType commonSkillType) :
  51. base(initPos, initRadius, initPlace, GameObjType.Character)
  52. {
  53. this.CanMove = true;
  54. this.score = 0;
  55. this.propInventory = null;
  56. this.buffManeger = new BuffManeger();
  57. IPassiveSkill? pSkill;
  58. ICommonSkill cSkill;
  59. switch (characterType)
  60. {
  61. case CharacterType.Assassin:
  62. pSkill = null;
  63. break;
  64. case CharacterType.RecoverAfterBattle:
  65. pSkill = new RecoverAfterBattle();
  66. break;
  67. case CharacterType.SpeedUpWhenLeavingGrass:
  68. pSkill = new SpeedUpWhenLeavingGrass();
  69. break;
  70. case CharacterType.Vampire:
  71. pSkill = new Vampire();
  72. break;
  73. default:
  74. pSkill = new NoPassiveSkill();
  75. break;
  76. }
  77. switch (commonSkillType)
  78. {
  79. case ActiveSkillType.BecomeAssassin:
  80. cSkill = new BecomeAssassin();
  81. break;
  82. case ActiveSkillType.BecomeVampire:
  83. cSkill = new BecomeVampire();
  84. break;
  85. case ActiveSkillType.NuclearWeapon:
  86. cSkill = new NuclearWeapon();
  87. break;
  88. case ActiveSkillType.SuperFast:
  89. cSkill = new SuperFast();
  90. break;
  91. default:
  92. cSkill = new NoCommonSkill();
  93. break;
  94. }
  95. this.MaxHp = cSkill.MaxHp;
  96. this.hp = cSkill.MaxHp;
  97. this.OrgMoveSpeed = cSkill.MoveSpeed;
  98. this.moveSpeed = cSkill.MoveSpeed;
  99. this.cd = cSkill.CD;
  100. this.maxBulletNum = cSkill.MaxBulletNum;
  101. this.bulletNum = maxBulletNum;
  102. this.bulletOfPlayer = pSkill.InitBullet;
  103. this.OriBulletOfPlayer = pSkill.InitBullet;
  104. this.passiveSkill = pSkill.SkillEffect;
  105. this.commonSkill = cSkill.SkillEffect;
  106. this.characterType = characterType;
  107. this.commonSkillType = commonSkillType;
  108. // UsePassiveSkill(); //创建player时开始被动技能,这一过程也可以放到gamestart时进行
  109. // 这可以放在AddPlayer中做
  110. Debugger.Output(this, "constructed!");
  111. }
  112. }
  113. }