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 3.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 Character(XY initPos, int initRadius, PlaceType initPlace, CharacterType characterType, ActiveSkillType commonSkillType) :
  37. base(initPos, initRadius, initPlace, GameObjType.Character)
  38. {
  39. this.CanMove = true;
  40. this.score = 0;
  41. this.propInventory = null;
  42. this.buffManeger = new BuffManeger();
  43. IPassiveSkill pSkill;
  44. ICommonSkill cSkill;
  45. switch (passiveSkillType)
  46. {
  47. case this.CharacterType.RecoverAfterBattle:
  48. pSkill = new RecoverAfterBattle();
  49. break;
  50. case this.CharacterType.SpeedUpWhenLeavingGrass:
  51. pSkill = new SpeedUpWhenLeavingGrass();
  52. break;
  53. case this.CharacterType.Vampire:
  54. pSkill = new Vampire();
  55. break;
  56. default:
  57. pSkill = new NoPassiveSkill();
  58. break;
  59. }
  60. switch (commonSkillType)
  61. {
  62. case ActiveSkillType.BecomeAssassin:
  63. cSkill = new BecomeAssassin();
  64. break;
  65. case ActiveSkillType.BecomeVampire:
  66. cSkill = new BecomeVampire();
  67. break;
  68. case ActiveSkillType.NuclearWeapon:
  69. cSkill = new NuclearWeapon();
  70. break;
  71. case ActiveSkillType.SuperFast:
  72. cSkill = new SuperFast();
  73. break;
  74. default:
  75. cSkill = new NoCommonSkill();
  76. break;
  77. }
  78. this.MaxHp = cSkill.MaxHp;
  79. this.hp = cSkill.MaxHp;
  80. this.OrgMoveSpeed = cSkill.MoveSpeed;
  81. this.moveSpeed = cSkill.MoveSpeed;
  82. this.cd = cSkill.CD;
  83. this.maxBulletNum = cSkill.MaxBulletNum;
  84. this.bulletNum = maxBulletNum;
  85. this.bulletOfPlayer = pSkill.InitBullet;
  86. this.OriBulletOfPlayer = pSkill.InitBullet;
  87. this.passiveSkill = pSkill.SkillEffect;
  88. this.commonSkill = cSkill.SkillEffect;
  89. this.passiveSkillType = passiveSkillType;
  90. this.commonSkillType = commonSkillType;
  91. // UsePassiveSkill(); //创建player时开始被动技能,这一过程也可以放到gamestart时进行
  92. // 这可以放在AddPlayer中做
  93. Debugger.Output(this, "constructed!");
  94. }
  95. }
  96. }