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.cs 29 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  1. using Preparation.Interface;
  2. using Preparation.Utility;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Threading;
  6. namespace GameClass.GameObj
  7. {
  8. public partial class Character : Moveable, ICharacter // 负责人LHR摆烂终了
  9. {
  10. #region 装弹、攻击相关的基本属性及方法
  11. private readonly object attackLock = new();
  12. public IntNumUpdateByCD BulletNum { get; } = new IntNumUpdateByCD();
  13. private int orgCD;
  14. public int OrgCD
  15. {
  16. get
  17. {
  18. lock (attackLock)
  19. return orgCD;
  20. }
  21. }
  22. public readonly BulletType OriBulletOfPlayer;
  23. private BulletType bulletOfPlayer;
  24. public BulletType BulletOfPlayer
  25. {
  26. get
  27. {
  28. lock (attackLock)
  29. {
  30. return bulletOfPlayer;
  31. }
  32. }
  33. set
  34. {
  35. lock (attackLock)
  36. {
  37. bulletOfPlayer = value;
  38. orgCD = (BulletFactory.BulletCD(value));
  39. BulletNum.SetCD(orgCD);
  40. Debugger.Output(this, string.Format("'s CD has been set to: {0}.", orgCD));
  41. BulletNum.SetPositiveMaxNumAndNum(BulletFactory.BulletNum(value));
  42. }
  43. }
  44. }
  45. /// <summary>
  46. /// 进行一次攻击
  47. /// </summary>
  48. /// <returns>攻击操作发出的子弹</returns>
  49. public Bullet? Attack(double angle)
  50. {
  51. lock (attackLock)
  52. {
  53. if (bulletOfPlayer == BulletType.Null)
  54. return null;
  55. if (BulletNum.TrySub(1) == 1)
  56. {
  57. XY res = Position + new XY // 子弹紧贴人物生成。
  58. (
  59. (int)(Math.Abs((Radius + BulletFactory.BulletRadius(bulletOfPlayer)) * Math.Cos(angle))) * Math.Sign(Math.Cos(angle)),
  60. (int)(Math.Abs((Radius + BulletFactory.BulletRadius(bulletOfPlayer)) * Math.Sin(angle))) * Math.Sign(Math.Sin(angle))
  61. );
  62. Bullet? bullet = BulletFactory.GetBullet(this, res, this.bulletOfPlayer);
  63. if (bullet == null) return null;
  64. if (TryAddAp()) bullet.AP.Add(GameData.ApPropAdd);
  65. FacingDirection = new(angle, bullet.AttackDistance);
  66. return bullet;
  67. }
  68. else
  69. return null;
  70. }
  71. }
  72. #endregion
  73. #region 感知相关的基本属性及方法
  74. private readonly object bgmLock = new();
  75. private Dictionary<BgmType, double> bgmDictionary = new() { { BgmType.GhostIsComing, 0 }, { BgmType.StudentIsApproaching, 0 }, { BgmType.GeneratorIsBeingFixed, 0 } };
  76. public Dictionary<BgmType, double> BgmDictionary
  77. {
  78. get
  79. {
  80. lock (bgmLock)
  81. return bgmDictionary;
  82. }
  83. }
  84. public void AddBgm(BgmType bgm, double value)
  85. {
  86. lock (bgmLock)
  87. bgmDictionary[bgm] = value;
  88. }
  89. private readonly int alertnessRadius;
  90. public int AlertnessRadius => alertnessRadius;
  91. private readonly double concealment;
  92. public double Concealment => concealment;
  93. private readonly int viewRange;
  94. public int ViewRange => viewRange;
  95. #endregion
  96. #region 交互相关的基本属性及方法
  97. private readonly int speedOfOpeningOrLocking;
  98. public int SpeedOfOpeningOrLocking
  99. {
  100. get => speedOfOpeningOrLocking;
  101. }
  102. private readonly int speedOfClimbingThroughWindows;
  103. public int SpeedOfClimbingThroughWindows
  104. {
  105. get => speedOfClimbingThroughWindows;
  106. }
  107. private readonly int speedOfOpenChest;
  108. public int SpeedOfOpenChest
  109. {
  110. get => speedOfOpenChest;
  111. }
  112. #endregion
  113. #region 血量相关的基本属性及方法
  114. public LongWithVariableRange HP { get; }
  115. private readonly object vampireLock = new();
  116. public object VampireLock => vampire;
  117. private double vampire = 0; // 回血率:0-1之间
  118. public double Vampire
  119. {
  120. get
  121. {
  122. lock (vampireLock)
  123. return vampire;
  124. }
  125. set
  126. {
  127. lock (vampireLock)
  128. {
  129. if (value > 1)
  130. vampire = 1;
  131. else if (value < 0)
  132. vampire = 0;
  133. else
  134. vampire = value;
  135. }
  136. }
  137. }
  138. public double OriVampire { get; protected set; }
  139. private readonly object treatLock = new();
  140. private int degreeOfTreatment = 0;
  141. public int DegreeOfTreatment
  142. {
  143. get
  144. {
  145. lock (treatLock)
  146. return degreeOfTreatment;
  147. }
  148. }
  149. public void SetDegreeOfTreatment0()
  150. {
  151. lock (treatLock)
  152. degreeOfTreatment = 0;
  153. }
  154. public bool AddDegreeOfTreatment(int value, Student whoTreatYou)
  155. {
  156. lock (treatLock)
  157. {
  158. degreeOfTreatment += value;
  159. long addV = HP.TryAddAll(degreeOfTreatment);
  160. if (addV == 0)
  161. {
  162. degreeOfTreatment = 0;
  163. return false;
  164. }
  165. if (addV > 0)
  166. {
  167. whoTreatYou.AddScore(GameData.StudentScoreTreat(addV));
  168. degreeOfTreatment = 0;
  169. return true;
  170. }
  171. if (degreeOfTreatment >= GameData.basicTreatmentDegree)
  172. {
  173. whoTreatYou.AddScore(GameData.StudentScoreTreat(GameData.basicTreatmentDegree));
  174. HP.AddPositiveV(GameData.basicTreatmentDegree);
  175. degreeOfTreatment = 0;
  176. return true;
  177. }
  178. return false;
  179. }
  180. }
  181. #endregion
  182. #region 查询状态相关的基本属性与方法
  183. private PlayerStateType playerState = PlayerStateType.Null;
  184. public PlayerStateType PlayerState
  185. {
  186. get
  187. {
  188. lock (actionLock)
  189. {
  190. if (playerState == PlayerStateType.Moving)
  191. return (IsMoving) ? PlayerStateType.Moving : PlayerStateType.Null;
  192. return playerState;
  193. }
  194. }
  195. }
  196. public bool NoHp()
  197. {
  198. lock (actionLock)
  199. return (playerState == PlayerStateType.Deceased || playerState == PlayerStateType.Escaped || playerState == PlayerStateType.Addicted || playerState == PlayerStateType.Rescued);
  200. }
  201. public bool Commandable()
  202. {
  203. lock (actionLock)
  204. {
  205. return (playerState != PlayerStateType.Deceased && playerState != PlayerStateType.Escaped
  206. && playerState != PlayerStateType.Addicted && playerState != PlayerStateType.Rescued
  207. && playerState != PlayerStateType.Swinging && playerState != PlayerStateType.TryingToAttack
  208. && playerState != PlayerStateType.ClimbingThroughWindows
  209. && playerState != PlayerStateType.Stunned && playerState != PlayerStateType.Charmed);
  210. }
  211. }
  212. public bool CanPinDown()
  213. {
  214. lock (actionLock)
  215. {
  216. return (playerState != PlayerStateType.Deceased && playerState != PlayerStateType.Escaped
  217. && playerState != PlayerStateType.Addicted && playerState != PlayerStateType.Rescued
  218. && playerState != PlayerStateType.Stunned && playerState != PlayerStateType.Charmed);
  219. }
  220. }
  221. public bool InteractingWithMapWithoutMoving()
  222. {
  223. lock (actionLock)
  224. {
  225. return (playerState == PlayerStateType.LockingTheDoor || playerState == PlayerStateType.OpeningTheDoor
  226. || playerState == PlayerStateType.Fixing || playerState == PlayerStateType.OpeningTheChest);
  227. }
  228. }
  229. public bool NullOrMoving()
  230. {
  231. lock (actionLock)
  232. {
  233. return (playerState == PlayerStateType.Null || playerState == PlayerStateType.Moving);
  234. }
  235. }
  236. public bool CanBeAwed()
  237. {
  238. lock (actionLock)
  239. return !(playerState == PlayerStateType.Deceased || playerState == PlayerStateType.Escaped
  240. || playerState == PlayerStateType.Addicted
  241. || playerState == PlayerStateType.Rescued || playerState == PlayerStateType.Treated
  242. || playerState == PlayerStateType.Stunned || playerState == PlayerStateType.Charmed
  243. || playerState == PlayerStateType.Null || playerState == PlayerStateType.Moving);
  244. }
  245. #endregion
  246. #region 更改状态相关的属性和方法
  247. private GameObj? whatInteractingWith = null;
  248. public GameObj? WhatInteractingWith
  249. {
  250. get
  251. {
  252. lock (actionLock)
  253. {
  254. return whatInteractingWith;
  255. }
  256. }
  257. }
  258. private long ChangePlayerState(RunningStateType running, PlayerStateType value = PlayerStateType.Null, GameObj? gameObj = null)
  259. {
  260. //只能被SetPlayerState引用
  261. if (runningState == RunningStateType.RunningSleepily)
  262. {
  263. ThreadNum.Release();
  264. }
  265. runningState = running;
  266. whatInteractingWith = gameObj;
  267. playerState = value;
  268. return ++stateNum;
  269. }
  270. private long ChangePlayerStateInOneThread(RunningStateType running, PlayerStateType value = PlayerStateType.Null, GameObj? gameObj = null)
  271. {
  272. if (runningState == RunningStateType.RunningSleepily)
  273. {
  274. ThreadNum.Release();
  275. }
  276. runningState = running;
  277. //只能被SetPlayerState引用
  278. whatInteractingWith = gameObj;
  279. playerState = value;
  280. return stateNum;
  281. }
  282. public long SetPlayerState(RunningStateType runningState, PlayerStateType value = PlayerStateType.Null, IGameObj? obj = null)
  283. {
  284. GameObj? gameObj = (GameObj?)obj;
  285. lock (actionLock)
  286. {
  287. PlayerStateType nowPlayerState = PlayerState;
  288. if (nowPlayerState == value && value != PlayerStateType.UsingSkill) return -1;
  289. GameObj? lastObj = whatInteractingWith;
  290. switch (nowPlayerState)
  291. {
  292. case PlayerStateType.Escaped:
  293. case PlayerStateType.Deceased:
  294. return -1;
  295. case PlayerStateType.Addicted:
  296. if (value == PlayerStateType.Rescued)
  297. return ChangePlayerStateInOneThread(runningState, value, gameObj);
  298. else if (value == PlayerStateType.Null || value == PlayerStateType.Deceased)
  299. return ChangePlayerState(runningState, value, gameObj);
  300. else return -1;
  301. case PlayerStateType.Rescued:
  302. if (value == PlayerStateType.Addicted)
  303. return ChangePlayerStateInOneThread(runningState, value, gameObj);
  304. else if (value == PlayerStateType.Null || value == PlayerStateType.Deceased)
  305. return ChangePlayerState(runningState, value, gameObj);
  306. else return -1;
  307. case PlayerStateType.TryingToAttack:
  308. if (value == PlayerStateType.Addicted || value == PlayerStateType.Swinging
  309. || value == PlayerStateType.Deceased || value == PlayerStateType.Stunned
  310. || value == PlayerStateType.Charmed || value == PlayerStateType.Null)
  311. return ChangePlayerState(runningState, value, gameObj);
  312. else return -1;
  313. case PlayerStateType.Stunned:
  314. case PlayerStateType.Charmed:
  315. if (value == PlayerStateType.Addicted || value == PlayerStateType.Deceased
  316. || value == PlayerStateType.Null)
  317. return ChangePlayerState(runningState, value, gameObj);
  318. else return -1;
  319. case PlayerStateType.Swinging:
  320. if (value == PlayerStateType.Addicted
  321. || value == PlayerStateType.Deceased || value == PlayerStateType.Stunned
  322. || value == PlayerStateType.Charmed || value == PlayerStateType.Null)
  323. return ChangePlayerState(runningState, value, gameObj);
  324. else return -1;
  325. case PlayerStateType.ClimbingThroughWindows:
  326. if (value == PlayerStateType.Addicted
  327. || value == PlayerStateType.Deceased || value == PlayerStateType.Stunned
  328. || value == PlayerStateType.Charmed || value == PlayerStateType.Null)
  329. {
  330. Window window = (Window)lastObj!;
  331. if (window.Stage.x != 0) ReSetPos(window.Stage);
  332. window.FinishClimbing();
  333. return ChangePlayerState(runningState, value, gameObj);
  334. }
  335. else return -1;
  336. case PlayerStateType.OpeningTheChest:
  337. if (value == PlayerStateType.Rescued) return -1;
  338. ((Chest)lastObj!).OpenProgress.Set0();
  339. return ChangePlayerState(runningState, value, gameObj);
  340. case PlayerStateType.OpeningTheDoorway:
  341. if (value == PlayerStateType.Rescued) return -1;
  342. Doorway doorway = (Doorway)lastObj!;
  343. doorway.StopOpenning();
  344. return ChangePlayerState(runningState, value, gameObj);
  345. case PlayerStateType.OpeningTheDoor:
  346. if (value == PlayerStateType.Rescued) return -1;
  347. Door door = (Door)lastObj!;
  348. door.StopOpen();
  349. ReleaseTool(door.KeyType);
  350. return ChangePlayerState(runningState, value, gameObj);
  351. case PlayerStateType.UsingSkill:
  352. {
  353. if (value == PlayerStateType.Rescued) return -1;
  354. switch (CharacterType)
  355. {
  356. case CharacterType.TechOtaku:
  357. {
  358. if (typeof(CraftingBench).IsInstanceOfType(lastObj))
  359. {
  360. ((CraftingBench)lastObj!).StopSkill();
  361. return ChangePlayerState(runningState, value, gameObj);
  362. }
  363. else
  364. {
  365. if (value != PlayerStateType.UsingSkill)
  366. ((UseRobot)FindActiveSkill(ActiveSkillType.UseRobot)).NowPlayerID = (int)PlayerID;
  367. return ChangePlayerState(runningState, value, gameObj);
  368. }
  369. }
  370. case CharacterType.Assassin:
  371. if (value == PlayerStateType.Moving) return StateNum;
  372. else
  373. {
  374. TryDeleteInvisible();
  375. return ChangePlayerState(runningState, value, gameObj);
  376. }
  377. default:
  378. return ChangePlayerState(runningState, value, gameObj);
  379. }
  380. }
  381. default:
  382. if (value == PlayerStateType.Rescued) return -1;
  383. return ChangePlayerState(runningState, value, gameObj);
  384. }
  385. }
  386. }
  387. public long SetPlayerStateNaturally()
  388. {
  389. lock (actionLock)
  390. {
  391. runningState = RunningStateType.Null;
  392. whatInteractingWith = null;
  393. playerState = PlayerStateType.Null;
  394. return ++stateNum;
  395. }
  396. }
  397. public bool ResetPlayerState(long state, RunningStateType running = RunningStateType.Null, PlayerStateType value = PlayerStateType.Null, IGameObj? obj = null)
  398. {
  399. lock (actionLock)
  400. {
  401. if (state != stateNum) return false;
  402. this.runningState = running;
  403. whatInteractingWith = (GameObj?)obj;
  404. playerState = value;
  405. ++stateNum;
  406. return true;
  407. }
  408. }
  409. public bool ResetPlayerStateInOneThread(long state, RunningStateType running = RunningStateType.Null, PlayerStateType value = PlayerStateType.Null, IGameObj? obj = null)
  410. {
  411. lock (actionLock)
  412. {
  413. if (state != stateNum) return false;
  414. this.runningState = running;
  415. whatInteractingWith = (GameObj?)obj;
  416. playerState = value;
  417. return true;
  418. }
  419. }
  420. public bool StartThread(long stateNum, RunningStateType runningState)
  421. {
  422. lock (ActionLock)
  423. {
  424. if (this.StateNum == stateNum)
  425. {
  426. this.runningState = runningState;
  427. return true;
  428. }
  429. }
  430. return false;
  431. }
  432. public bool TryToRemoveFromGame(PlayerStateType playerStateType)
  433. {
  434. lock (actionLock)
  435. {
  436. if (SetPlayerState(RunningStateType.RunningForcibly, playerStateType) == -1) return false;
  437. TryToRemove();
  438. CanMove.SetReturnOri(false);
  439. position = GameData.PosWhoDie;
  440. }
  441. return true;
  442. }
  443. #endregion
  444. private long score = 0;
  445. public long Score
  446. {
  447. get => Interlocked.Read(ref score);
  448. }
  449. /// <summary>
  450. /// 加分
  451. /// </summary>
  452. /// <param name="add">增加量</param>
  453. public virtual void AddScore(long add)
  454. {
  455. Interlocked.Add(ref score, add);
  456. //Debugger.Output(this, " 's score has been added to: " + score.ToString());
  457. }
  458. /// <summary>
  459. /// 角色所属队伍ID
  460. /// </summary>
  461. public AtomicLong TeamID { get; } = new AtomicLong(long.MaxValue);
  462. public AtomicLong PlayerID { get; } = new AtomicLong(long.MaxValue);
  463. #region 道具和buff相关属性、方法
  464. private readonly object inventoryLock = new();
  465. public object InventoryLock => inventoryLock;
  466. private Gadget[] propInventory = new Gadget[GameData.maxNumOfPropInPropInventory]
  467. {new NullProp(), new NullProp(),new NullProp() };
  468. public Gadget[] PropInventory
  469. {
  470. get
  471. {
  472. lock (inventoryLock)
  473. return propInventory;
  474. }
  475. set
  476. {
  477. lock (inventoryLock)
  478. propInventory = value;
  479. }
  480. }
  481. /// <summary>
  482. /// 使用物品栏中的道具
  483. /// </summary>
  484. /// <returns>被使用的道具</returns>
  485. public Gadget ConsumeProp(int indexing)
  486. {
  487. if (indexing < 0 || indexing >= GameData.maxNumOfPropInPropInventory)
  488. return new NullProp();
  489. lock (inventoryLock)
  490. {
  491. Gadget prop = propInventory[indexing];
  492. if (!prop.IsUsable()) return new NullProp();
  493. PropInventory[indexing] = new NullProp();
  494. return prop;
  495. }
  496. }
  497. public Gadget ConsumeProp(PropType propType)
  498. {
  499. if (propType == PropType.Null)
  500. {
  501. lock (inventoryLock)
  502. {
  503. for (int indexing = 0; indexing < GameData.maxNumOfPropInPropInventory; ++indexing)
  504. {
  505. if (PropInventory[indexing].IsUsable())
  506. {
  507. Gadget prop = PropInventory[indexing];
  508. PropInventory[indexing] = new NullProp();
  509. return prop;
  510. }
  511. }
  512. }
  513. }
  514. else
  515. {
  516. lock (inventoryLock)
  517. {
  518. for (int indexing = 0; indexing < GameData.maxNumOfPropInPropInventory; ++indexing)
  519. {
  520. if (PropInventory[indexing].GetPropType() == propType && PropInventory[indexing].IsUsable())
  521. {
  522. Gadget prop = PropInventory[indexing];
  523. PropInventory[indexing] = new NullProp();
  524. return prop;
  525. }
  526. }
  527. }
  528. }
  529. return new NullProp();
  530. }
  531. public bool UseTool(PropType propType)//占用道具,使其不能重复使用和被消耗
  532. {
  533. lock (inventoryLock)
  534. {
  535. for (int indexing = 0; indexing < GameData.maxNumOfPropInPropInventory; ++indexing)
  536. {
  537. if (PropInventory[indexing].GetPropType() == propType && PropInventory[indexing].IsUsable())
  538. {
  539. return ((Tool)PropInventory[indexing]).IsUsed = true;
  540. }
  541. }
  542. }
  543. return false;
  544. }
  545. public void ReleaseTool(PropType propType)
  546. {
  547. lock (inventoryLock)
  548. {
  549. for (int indexing = 0; indexing < GameData.maxNumOfPropInPropInventory; ++indexing)
  550. {
  551. if (PropInventory[indexing].GetPropType() == propType && ((Tool)PropInventory[indexing]).IsUsed)
  552. {
  553. ((Tool)PropInventory[indexing]).IsUsed = false;
  554. break;
  555. }
  556. }
  557. }
  558. }
  559. /// <summary>
  560. /// 如果indexing==GameData.maxNumOfPropInPropInventory表明道具栏为满
  561. /// </summary>
  562. public int IndexingOfAddProp()
  563. {
  564. int indexing = 0;
  565. lock (inventoryLock)
  566. for (; indexing < GameData.maxNumOfPropInPropInventory; ++indexing)
  567. if (propInventory[indexing].GetPropType() == PropType.Null)
  568. break;
  569. return indexing;
  570. }
  571. public void AddMoveSpeed(int buffTime, double add = 1.0) => buffManager.AddMoveSpeed(add, buffTime, newVal =>
  572. { MoveSpeed.SetReturnOri(newVal < GameData.characterMaxSpeed ? newVal : GameData.characterMaxSpeed); },
  573. OrgMoveSpeed);
  574. public bool HasFasterSpeed => buffManager.HasFasterSpeed;
  575. public void AddShield(int shieldTime) => buffManager.AddShield(shieldTime);
  576. public bool HasShield => buffManager.HasShield;
  577. public void AddLife(int LIFETime) => buffManager.AddLife(LIFETime);
  578. public bool HasLIFE => buffManager.HasLIFE;
  579. public void AddAp(int time) => buffManager.AddAp(time);
  580. public bool HasAp => buffManager.HasAp;
  581. public void AddSpear(int spearTime) => buffManager.AddSpear(spearTime);
  582. public bool HasSpear => buffManager.HasSpear;
  583. public void AddClairaudience(int time) => buffManager.AddClairaudience(time);
  584. public bool HasClairaudience => buffManager.HasClairaudience;
  585. public void AddInvisible(int time) => buffManager.AddInvisible(time);
  586. public bool HasInvisible => buffManager.HasInvisible;
  587. private Array buffTypeArray = Enum.GetValues(typeof(BuffType));
  588. public Dictionary<BuffType, bool> Buff
  589. {
  590. get
  591. {
  592. Dictionary<BuffType, bool> buff = new Dictionary<BuffType, bool>();
  593. foreach (BuffType type in buffTypeArray)
  594. {
  595. if (type != BuffType.Null)
  596. buff.Add(type, GetBuffStatus(type));
  597. }
  598. return buff;
  599. }
  600. }
  601. private bool GetBuffStatus(BuffType type)
  602. {
  603. switch (type)
  604. {
  605. case BuffType.Spear:
  606. return this.HasSpear;
  607. case BuffType.AddSpeed:
  608. return this.HasFasterSpeed;
  609. case BuffType.Shield:
  610. return this.HasShield;
  611. case BuffType.AddLife:
  612. return this.HasLIFE;
  613. case BuffType.AddAp:
  614. return this.HasAp;
  615. case BuffType.Clairaudience:
  616. return this.HasClairaudience;
  617. case BuffType.Invisible:
  618. return this.HasInvisible;
  619. default:
  620. return false;
  621. }
  622. }
  623. public void TryActivatingLIFE()
  624. {
  625. if (buffManager.TryActivatingLIFE())
  626. {
  627. AddScore(GameData.ScorePropRemainHp);
  628. HP.SetPositiveV(GameData.RemainHpWhenAddLife);
  629. }
  630. }
  631. public bool TryAddAp()
  632. {
  633. if (buffManager.TryAddAp())
  634. {
  635. AddScore(GameData.ScorePropAddAp);
  636. return true;
  637. }
  638. return false;
  639. }
  640. public bool TryUseSpear()
  641. {
  642. return buffManager.TryUseSpear();
  643. }
  644. public bool TryDeleteInvisible()
  645. {
  646. return buffManager.TryDeleteInvisible();
  647. }
  648. public bool TryUseShield()
  649. {
  650. if (buffManager.TryUseShield())
  651. {
  652. AddScore(GameData.ScorePropUseShield);
  653. return true;
  654. }
  655. return false;
  656. }
  657. #endregion
  658. /* public override void Reset() // 要加锁吗?
  659. {
  660. lock (gameObjLock)
  661. {
  662. // _ = AddDeathCount();
  663. base.Reset();
  664. this.MoveSpeed = OrgMoveSpeed;
  665. HP = MaxHp;
  666. PropInventory = null;
  667. BulletOfPlayer = OriBulletOfPlayer;
  668. lock (gameObjLock)
  669. bulletNum = maxBulletNum;
  670. buffManager.ClearAll();
  671. IsInvisible = false;
  672. this.Vampire = this.OriVampire;
  673. }
  674. }*/
  675. public override bool IsRigid => true;
  676. public override ShapeType Shape => ShapeType.Circle;
  677. public override bool IgnoreCollideExecutor(IGameObj targetObj)
  678. {
  679. if (IsRemoved)
  680. return true;
  681. if (targetObj.Type == GameObjType.Gadget)
  682. {
  683. return true;
  684. }
  685. if (targetObj.Type == GameObjType.Character && XY.DistanceCeil3(targetObj.Position, this.Position) < this.Radius + targetObj.Radius - GameData.adjustLength)
  686. return true;
  687. return false;
  688. }
  689. }
  690. }